DEV: fix flakey spec in handle_category_udpated (#21488)

This commit is contained in:
Joffrey JAFFEUX 2023-05-11 08:01:02 +02:00 committed by GitHub
parent dee8c759eb
commit aab6fb13a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 6 deletions

View File

@ -66,8 +66,6 @@ RSpec.describe Chat::AutoRemove::HandleCategoryUpdated do
end
context "when the category still has category_group records" do
let(:action) { UserHistory.where(custom_type: "chat_auto_remove_membership").last }
before do
[user_1, user_2, admin_1, admin_2].each do |user|
channel_1.add(user)
@ -142,10 +140,24 @@ RSpec.describe Chat::AutoRemove::HandleCategoryUpdated do
it "logs a staff action" do
result
expect(action).to have_attributes(
details: "users_removed: 1\nchannel_id: #{channel_2.id}\nevent: category_updated",
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: 1\nchannel_id: #{channel_1.id}\nevent: category_updated",
acting_user_id: Discourse.system_user.id,
},
{
details: "users_removed: 1\nchannel_id: #{channel_2.id}\nevent: category_updated",
acting_user_id: Discourse.system_user.id,
},
],
)
end
end