diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index 58716f6b65d..004c76c1f41 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -859,7 +859,7 @@ module Email user ||= stage_from_user - if user.groups.any? && !user.in_any_groups?(SiteSetting.email_in_allowed_groups_map) && + if !user.staged? && !user.in_any_groups?(SiteSetting.email_in_allowed_groups_map) && !sent_to_mailinglist_mirror? raise InsufficientTrustLevelError end diff --git a/lib/new_post_manager.rb b/lib/new_post_manager.rb index d6716057f48..73505c74142 100644 --- a/lib/new_post_manager.rb +++ b/lib/new_post_manager.rb @@ -92,12 +92,12 @@ class NewPostManager return :post_count end - if user.groups.any? && !user.in_any_groups?(SiteSetting.approve_unless_allowed_groups_map) + if !user.staged? && !user.in_any_groups?(SiteSetting.approve_unless_allowed_groups_map) return :group end if ( - manager.args[:title].present? && user.groups.any? && + manager.args[:title].present? && !user.staged? && !user.in_any_groups?(SiteSetting.approve_new_topics_unless_allowed_groups_map) ) return :new_topics_unless_allowed_groups diff --git a/plugins/poll/spec/controllers/posts_controller_spec.rb b/plugins/poll/spec/controllers/posts_controller_spec.rb index bf5533bab57..4dd8a4d1995 100644 --- a/plugins/poll/spec/controllers/posts_controller_spec.rb +++ b/plugins/poll/spec/controllers/posts_controller_spec.rb @@ -3,13 +3,17 @@ require "rails_helper" RSpec.describe PostsController do - let!(:user) { log_in } + let!(:user) { Fabricate(:user, refresh_auto_groups: true) } let!(:title) { "Testing Poll Plugin" } - before { SiteSetting.min_first_post_typing_time = 0 } + before do + SiteSetting.min_first_post_typing_time = 0 + log_in_user(user) + end describe "polls" do it "works" do + Group.refresh_automatic_groups! post :create, params: { title: title, raw: "[poll]\n- A\n- B\n[/poll]" }, format: :json expect(response.status).to eq(200) @@ -375,7 +379,7 @@ RSpec.describe PostsController do before { SiteSetting.poll_minimum_trust_level_to_create = 2 } it "invalidates the post" do - log_in_user(Fabricate(:user, trust_level: 1)) + log_in_user(Fabricate(:user, trust_level: 1, refresh_auto_groups: true)) post :create, params: { title: title, raw: "[poll]\n- A\n- B\n[/poll]" }, format: :json @@ -408,7 +412,7 @@ RSpec.describe PostsController do before { SiteSetting.poll_minimum_trust_level_to_create = 2 } it "validates the post" do - log_in_user(Fabricate(:user, trust_level: 2)) + log_in_user(Fabricate(:user, trust_level: 2, refresh_auto_groups: true)) post :create, params: { title: title, raw: "[poll]\n- A\n- B\n[/poll]" }, format: :json @@ -423,7 +427,7 @@ RSpec.describe PostsController do before { SiteSetting.poll_minimum_trust_level_to_create = 2 } it "validates the post" do - log_in_user(Fabricate(:user, trust_level: 3)) + log_in_user(Fabricate(:user, trust_level: 3, refresh_auto_groups: true)) post :create, params: { title: title, raw: "[poll]\n- A\n- B\n[/poll]" }, format: :json @@ -453,7 +457,7 @@ RSpec.describe PostsController do before { SiteSetting.poll_minimum_trust_level_to_create = 2 } it "validates the post" do - log_in_user(Fabricate(:user, trust_level: 1)) + log_in_user(Fabricate(:user, trust_level: 1, refresh_auto_groups: true)) post :create, params: { title: title, raw: title }, format: :json diff --git a/spec/lib/email/receiver_spec.rb b/spec/lib/email/receiver_spec.rb index 986c3b8aded..5313fcb10e2 100644 --- a/spec/lib/email/receiver_spec.rb +++ b/spec/lib/email/receiver_spec.rb @@ -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