mirror of
https://github.com/discourse/discourse.git
synced 2025-05-26 06:01:43 +08:00
DEV: Remove full group refreshes from tests (#25414)
We have all these calls to Group.refresh_automatic_groups! littered throughout the tests. Including tests that are seemingly unrelated to groups. This is because automatic group memberships aren't fabricated when making a vanilla user. There are two places where you'd want to use this: You have fabricated a user that needs a certain trust level (which is now based on group membership.) You need the system user to have a certain trust level. In the first case, we can pass refresh_auto_groups: true to the fabricator instead. This is a more lightweight operation that only considers a single user, instead of all users in all groups. The second case is no longer a thing after #25400.
This commit is contained in:
@ -4,8 +4,15 @@ require "rails_helper"
|
||||
|
||||
describe Chat::Mailer do
|
||||
fab!(:chatters_group) { Fabricate(:group) }
|
||||
fab!(:sender) { Fabricate(:user, group_ids: [chatters_group.id]) }
|
||||
fab!(:user_1) { Fabricate(:user, group_ids: [chatters_group.id], last_seen_at: 15.minutes.ago) }
|
||||
fab!(:sender) { Fabricate(:user, group_ids: [chatters_group.id], refresh_auto_groups: true) }
|
||||
fab!(:user_1) do
|
||||
Fabricate(
|
||||
:user,
|
||||
group_ids: [chatters_group.id],
|
||||
last_seen_at: 15.minutes.ago,
|
||||
refresh_auto_groups: true,
|
||||
)
|
||||
end
|
||||
fab!(:chat_channel) { Fabricate(:category_channel) }
|
||||
fab!(:chat_message) { Fabricate(:chat_message, user: sender, chat_channel: chat_channel) }
|
||||
fab!(:user_1_chat_channel_membership) do
|
||||
@ -17,7 +24,6 @@ describe Chat::Mailer do
|
||||
)
|
||||
end
|
||||
fab!(:private_chat_channel) do
|
||||
Group.refresh_automatic_groups!
|
||||
result =
|
||||
Chat::CreateDirectMessageChannel.call(
|
||||
guardian: sender.guardian,
|
||||
|
Reference in New Issue
Block a user