Skip to content

Commit

Permalink
DEV: fix flakey spec (#21515)
Browse files Browse the repository at this point in the history
Similar fix to the one made in aab6fb1

Instead of checking last object, check against all modified objects in no specific order.
  • Loading branch information
jjaffeux committed May 11, 2023
1 parent f20be4b commit e10b262
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

context "when new_allowed_groups is empty" do
let(:new_allowed_groups) { "" }
let(:action) { UserHistory.where(custom_type: "chat_auto_remove_membership").last }

before do
public_channel_1.add(user_1)
Expand Down Expand Up @@ -95,11 +94,26 @@

it "logs a staff action" do
result
expect(action).to have_attributes(
details:
"users_removed: 2\nchannel_id: #{public_channel_2.id}\nevent: chat_allowed_groups_changed",
acting_user_id: Discourse.system_user.id,
custom_type: "chat_auto_remove_membership",

changes =
UserHistory
.where(custom_type: "chat_auto_remove_membership")
.all
.map { |uh| uh.slice(:details, :acting_user_id) }

expect(changes).to match_array(
[
{
details:
"users_removed: 2\nchannel_id: #{public_channel_1.id}\nevent: chat_allowed_groups_changed",
acting_user_id: Discourse.system_user.id,
},
{
details:
"users_removed: 2\nchannel_id: #{public_channel_2.id}\nevent: chat_allowed_groups_changed",
acting_user_id: Discourse.system_user.id,
},
],
)
end
end
Expand Down

1 comment on commit e10b262

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/could-someone-please-let-me-know-the-version-of-discourse-as-of-may-11-2023/306173/2

Please sign in to comment.