DEV: Change flaky spec to provide more information when it fails (#418)

This spec has been detected to be flaky by
https://github.com/discourse/flaky-tests-detective which we run
internally. However, I could not reproduce the flakiness after multiple
attempts so I rewrote the assertions such that we set up the
expectations of what `Assignment#assigned_to_id` should be before and
after the triggering of the DiscourseEvent.
This commit is contained in:
Alan Guo Xiang Tan 2023-01-04 07:27:23 +08:00 committed by GitHub
parent 4777d0179c
commit 4fe2ded608
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -110,14 +110,17 @@ describe "integration tests" do
end
it "assigns topic" do
DiscourseEvent.trigger(:assign_topic, topic, user1, admin)
expect(topic.assignment.assigned_to_id).to eq(user1.id)
expect do DiscourseEvent.trigger(:assign_topic, topic, user1, admin) end.to change {
Assignment.where(topic: topic).pluck_first(:assigned_to_id)
}.from(nil).to(user1.id)
DiscourseEvent.trigger(:assign_topic, topic, user2, admin)
expect(topic.assignment.assigned_to_id).to eq(user1.id)
expect do DiscourseEvent.trigger(:assign_topic, topic, user2, admin) end.to_not change {
Assignment.where(topic: topic).pluck_first(:assigned_to_id)
}.from(user1.id)
DiscourseEvent.trigger(:assign_topic, topic, user2, admin, true)
expect(topic.assignment.assigned_to_id).to eq(user2.id)
expect do DiscourseEvent.trigger(:assign_topic, topic, user2, admin, true) end.to change {
Assignment.where(topic: topic).pluck_first(:assigned_to_id)
}.from(user1.id).to(user2.id)
end
it "triggers a webhook for assigned and unassigned" do