diff --git a/spec/fabricators/user_fabricator.rb b/spec/fabricators/user_fabricator.rb index 858e4e30c79dd..2a463d0255973 100644 --- a/spec/fabricators/user_fabricator.rb +++ b/spec/fabricators/user_fabricator.rb @@ -1,7 +1,7 @@ Fabricator(:user_stat) do end -Fabricator(:user_single_email, class_name: :user) do +Fabricator(:user, class_name: :user) do name 'Bruce Wayne' username { sequence(:username) { |i| "bruce#{i}" } } email { sequence(:email) { |i| "bruce#{i}@wayne.com" } } @@ -11,7 +11,7 @@ active true end -Fabricator(:user, from: :user_single_email) do +Fabricator(:user_with_secondary_email, from: :user) do after_create { |user| Fabricate(:secondary_email, user: user) } end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index c70570411b534..5c196e90483fb 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -272,7 +272,7 @@ def real_staff group = Group.refresh_automatic_group!(:staff) expect(group.name).to eq('staff') - Fabricate(:user_single_email, username: I18n.t('groups.default_names.moderators').upcase) + Fabricate(:user, username: I18n.t('groups.default_names.moderators').upcase) group = Group.refresh_automatic_group!(:moderators) expect(group.name).to eq('moderators') end diff --git a/spec/models/user_email_spec.rb b/spec/models/user_email_spec.rb index 22690c9bc30b4..a2f34fdb11c73 100644 --- a/spec/models/user_email_spec.rb +++ b/spec/models/user_email_spec.rb @@ -4,14 +4,14 @@ describe UserEmail do context "validation" do it "allows only one primary email" do - user = Fabricate(:user_single_email) + user = Fabricate(:user) expect { Fabricate(:secondary_email, user: user, primary: true) }.to raise_error(ActiveRecord::RecordInvalid) end it "allows multiple secondary emails" do - user = Fabricate(:user_single_email) + user = Fabricate(:user) Fabricate(:secondary_email, user: user, primary: false) Fabricate(:secondary_email, user: user, primary: false) expect(user.user_emails.count).to eq 3 @@ -20,14 +20,14 @@ context "indexes" do it "allows only one primary email" do - user = Fabricate(:user_single_email) + user = Fabricate(:user) expect { Fabricate.build(:secondary_email, user: user, primary: true).save(validate: false) }.to raise_error(ActiveRecord::RecordNotUnique) end it "allows multiple secondary emails" do - user = Fabricate(:user_single_email) + user = Fabricate(:user) Fabricate.build(:secondary_email, user: user, primary: false).save(validate: false) Fabricate.build(:secondary_email, user: user, primary: false).save(validate: false) expect(user.user_emails.count).to eq 3 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 4bf3c572b1d68..a2b2d59fad358 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -713,7 +713,7 @@ def assert_good(username) it 'email whitelist should be used when email is being changed' do SiteSetting.email_domains_whitelist = 'vaynermedia.com' - u = Fabricate(:user_single_email, email: 'good@vaynermedia.com') + u = Fabricate(:user, email: 'good@vaynermedia.com') u.email = 'nope@mailinator.com' expect(u).not_to be_valid end @@ -1812,7 +1812,7 @@ def filter_by(method) end describe "#secondary_emails" do - let(:user) { Fabricate(:user_single_email) } + let(:user) { Fabricate(:user) } it "only contains secondary emails" do expect(user.user_emails.secondary).to eq([]) diff --git a/spec/serializers/admin_user_list_serializer_spec.rb b/spec/serializers/admin_user_list_serializer_spec.rb index ec9e648737879..984a9f9031bc1 100644 --- a/spec/serializers/admin_user_list_serializer_spec.rb +++ b/spec/serializers/admin_user_list_serializer_spec.rb @@ -17,9 +17,9 @@ end context "emails" do - let(:admin) { Fabricate(:user_single_email, admin: true, email: "admin@email.com") } - let(:moderator) { Fabricate(:user_single_email, moderator: true, email: "moderator@email.com") } - let(:user) { Fabricate(:user_single_email, email: "user@email.com") } + let(:admin) { Fabricate(:user, admin: true, email: "admin@email.com") } + let(:moderator) { Fabricate(:user, moderator: true, email: "moderator@email.com") } + let(:user) { Fabricate(:user, email: "user@email.com") } def serialize(user, viewed_by, opts = nil) AdminUserListSerializer.new( diff --git a/spec/services/anonymous_shadow_creator_spec.rb b/spec/services/anonymous_shadow_creator_spec.rb index 99a448ccd624c..fcd6dfb700e1d 100644 --- a/spec/services/anonymous_shadow_creator_spec.rb +++ b/spec/services/anonymous_shadow_creator_spec.rb @@ -10,7 +10,7 @@ before { SiteSetting.allow_anonymous_posting = true } - let(:user) { Fabricate(:user_single_email, trust_level: 3) } + let(:user) { Fabricate(:user, 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) diff --git a/spec/services/user_anonymizer_spec.rb b/spec/services/user_anonymizer_spec.rb index aa18688701a39..afeb76beaa2bf 100644 --- a/spec/services/user_anonymizer_spec.rb +++ b/spec/services/user_anonymizer_spec.rb @@ -24,7 +24,7 @@ describe "make_anonymous" do let(:original_email) { "edward@example.net" } - let(:user) { Fabricate(:user_single_email, username: "edward", email: original_email) } + let(:user) { Fabricate(:user, username: "edward", email: original_email) } let(:another_user) { Fabricate(:evil_trout) } subject(:make_anonymous) { described_class.make_anonymous(user, admin) } diff --git a/spec/services/user_destroyer_spec.rb b/spec/services/user_destroyer_spec.rb index da654bb2db6e8..eca824be09305 100644 --- a/spec/services/user_destroyer_spec.rb +++ b/spec/services/user_destroyer_spec.rb @@ -19,7 +19,7 @@ describe 'destroy' do before do @admin = Fabricate(:admin) - @user = Fabricate(:user) + @user = Fabricate(:user_with_secondary_email) end it 'raises an error when user is nil' do diff --git a/spec/services/user_merger_spec.rb b/spec/services/user_merger_spec.rb index 4f5cdbf4dd1af..2eefbf9a62e3d 100644 --- a/spec/services/user_merger_spec.rb +++ b/spec/services/user_merger_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' describe UserMerger do - let!(:target_user) { Fabricate(:user_single_email, username: 'alice', email: 'alice@example.com') } - let!(:source_user) { Fabricate(:user_single_email, username: 'alice1', email: 'alice@work.com') } + let!(:target_user) { Fabricate(:user, username: 'alice', email: 'alice@example.com') } + let!(:source_user) { Fabricate(:user, username: 'alice1', email: 'alice@work.com') } let(:walter) { Fabricate(:walter_white) } def merge_users!(source = nil, target = nil) @@ -838,7 +838,7 @@ def create_badge(badge, user, opts = {}) it "skips merging email adresses when a secondary email address exists" do merge_users!(source_user, target_user) - alice2 = Fabricate(:user_single_email, username: 'alice2', email: 'alice@foo.com') + alice2 = Fabricate(:user, username: 'alice2', email: 'alice@foo.com') merge_users!(alice2, target_user) emails = UserEmail.where(user_id: target_user.id).pluck(:email, :primary)