diff --git a/app/services/anonymous_shadow_creator.rb b/app/services/anonymous_shadow_creator.rb index fc602b8255c..d28f89e2103 100644 --- a/app/services/anonymous_shadow_creator.rb +++ b/app/services/anonymous_shadow_creator.rb @@ -36,6 +36,7 @@ class AnonymousShadowCreator shadow = User.create!( password: SecureRandom.hex, email: "#{SecureRandom.hex}@anon.#{Discourse.current_hostname}", + skip_email_validation: true, name: username, # prevents error when names are required username: username, active: true, diff --git a/spec/services/anonymous_shadow_creator_spec.rb b/spec/services/anonymous_shadow_creator_spec.rb index 0cc425b946c..e658be53b23 100644 --- a/spec/services/anonymous_shadow_creator_spec.rb +++ b/spec/services/anonymous_shadow_creator_spec.rb @@ -10,7 +10,7 @@ describe AnonymousShadowCreator do before { SiteSetting.allow_anonymous_posting = true } - let(:user) { Fabricate(:user, trust_level: 3) } + let(:user) { Fabricate(:user_single_email, trust_level: 3) } it "returns no shadow if trust level is not met" do expect(AnonymousShadowCreator.get(Fabricate.build(:user, trust_level: 0))).to eq(nil) @@ -67,6 +67,11 @@ describe AnonymousShadowCreator do expect { AnonymousShadowCreator.get(user) }.to_not raise_error end + it "works when there is an email whitelist" do + SiteSetting.email_domains_whitelist = "wayne.com" + + expect { AnonymousShadowCreator.get(user) }.to_not raise_error + end end end