DEV: more resilient auto remove spec (#22472)
We have no guarantees on the last record here, it's easier and more stable to check all created records.
This commit is contained in:
parent
c0808b2537
commit
d41fa579c8
|
@ -33,8 +33,6 @@ RSpec.describe Chat::AutoRemove::HandleUserRemovedFromGroup do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the user is no longer in any of the chat_allowed_groups" do
|
context "when the user is no longer in any of the chat_allowed_groups" do
|
||||||
let(:action) { UserHistory.where(custom_type: "chat_auto_remove_membership").last }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
SiteSetting.chat_allowed_groups = Fabricate(:group).id
|
SiteSetting.chat_allowed_groups = Fabricate(:group).id
|
||||||
public_channel_1.add(removed_user)
|
public_channel_1.add(removed_user)
|
||||||
|
@ -88,13 +86,20 @@ RSpec.describe Chat::AutoRemove::HandleUserRemovedFromGroup do
|
||||||
).to eq(true)
|
).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "logs a staff action" do
|
it "logs staff actions" do
|
||||||
result
|
result
|
||||||
expect(action).to have_attributes(
|
|
||||||
details:
|
expect(
|
||||||
"users_removed: 1\nchannel_id: #{public_channel_2.id}\nevent: user_removed_from_group",
|
UserHistory
|
||||||
acting_user_id: Discourse.system_user.id,
|
.where(
|
||||||
custom_type: "chat_auto_remove_membership",
|
acting_user_id: Discourse.system_user.id,
|
||||||
|
custom_type: "chat_auto_remove_membership",
|
||||||
|
)
|
||||||
|
.last(2)
|
||||||
|
.map(&:details),
|
||||||
|
).to contain_exactly(
|
||||||
|
"users_removed: 1\nchannel_id: #{public_channel_1.id}\nevent: user_removed_from_group",
|
||||||
|
"users_removed: 1\nchannel_id: #{public_channel_2.id}\nevent: user_removed_from_group",
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue