mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:21:18 +08:00
DEV: Use staged user check instead (#24578)
This change refactors the check `user.groups.any?` and instead uses `user.staged?` to check if the user is staged or not. Also fixes several tests to ensure the users have their auto trust level groups created. Follow up to: - 8a45f84277e6e13bc48b8f4e40350a9cbd5cd2ee - 447d9b210556e64c14f9ca9f8f9b52f54090cd41 - c89edd9e86870f97a770816210d71400f09181f2
This commit is contained in:
@ -1704,6 +1704,7 @@ RSpec.describe Email::Receiver do
|
||||
:user,
|
||||
trust_level: SiteSetting.email_in_min_trust,
|
||||
user_emails: [Fabricate.build(:secondary_email, email: "existing@bar.com")],
|
||||
refresh_auto_groups: true,
|
||||
)
|
||||
|
||||
expect { process(:existing_user) }.to change(Topic, :count).by(1)
|
||||
@ -2079,7 +2080,7 @@ RSpec.describe Email::Receiver do
|
||||
end
|
||||
|
||||
it "should skip validations for regular users" do
|
||||
Fabricate(:user, email: "alice@foo.com")
|
||||
Fabricate(:user, email: "alice@foo.com", refresh_auto_groups: true)
|
||||
expect { process(:mailinglist_short_message) }.to change { Topic.count }
|
||||
end
|
||||
|
||||
@ -2088,8 +2089,8 @@ RSpec.describe Email::Receiver do
|
||||
category.set_permissions(everyone: :readonly)
|
||||
category.save!
|
||||
|
||||
Fabricate(:user, email: "alice@foo.com")
|
||||
Fabricate(:user, email: "bob@bar.com")
|
||||
Fabricate(:user, email: "alice@foo.com", refresh_auto_groups: true)
|
||||
Fabricate(:user, email: "bob@bar.com", refresh_auto_groups: true)
|
||||
end
|
||||
|
||||
it "should allow creating topic within read-only category" do
|
||||
@ -2106,7 +2107,7 @@ RSpec.describe Email::Receiver do
|
||||
|
||||
it "ignores unsubscribe email" do
|
||||
SiteSetting.unsubscribe_via_email = true
|
||||
Fabricate(:user, email: "alice@foo.com")
|
||||
Fabricate(:user, email: "alice@foo.com", refresh_auto_groups: true)
|
||||
|
||||
expect { process("mailinglist_unsubscribe") }.to_not change {
|
||||
ActionMailer::Base.deliveries.count
|
||||
|
Reference in New Issue
Block a user