diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-29 19:57:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-29 19:57:17 +0000 |
commit | 37e3c3bb33c3d331fceb2840cf3c1d3c466dcfa9 (patch) | |
tree | 9d3739f627b491b42ede6424acd11b589beed25f /spec/lib | |
parent | b55baf593e63db9be3f446ea0cca0281a69dd2e2 (diff) | |
download | gitlab-ce-37e3c3bb33c3d331fceb2840cf3c1d3c466dcfa9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/auth/user_access_denied_reason_spec.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer_spec.rb | 9 |
2 files changed, 16 insertions, 1 deletions
diff --git a/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb b/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb index a2a0eb5428a..5cbd22827c9 100644 --- a/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb +++ b/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb @@ -41,5 +41,13 @@ RSpec.describe Gitlab::Auth::UserAccessDeniedReason do it { is_expected.to eq "Your account has been deactivated by your administrator. Please log back in from a web browser to reactivate your account at #{Gitlab.config.gitlab.url}" } end + + context 'when the user is unconfirmed' do + before do + user.update!(confirmed_at: nil) + end + + it { is_expected.to match /Your primary email address is not confirmed/ } + end end end diff --git a/spec/lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer_spec.rb b/spec/lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer_spec.rb index c9928edb8e8..07f4429f7d9 100644 --- a/spec/lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer_spec.rb +++ b/spec/lib/gitlab/background_migration/wrongfully_confirmed_email_unconfirmer_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Gitlab::BackgroundMigration::WrongfullyConfirmedEmailUnconfirmer, schema: 20200615111857 do let(:users) { table(:users) } let(:emails) { table(:emails) } + let(:user_synced_attributes_metadata) { table(:user_synced_attributes_metadata) } let(:confirmed_at_2_days_ago) { 2.days.ago } let(:confirmed_at_3_days_ago) { 3.days.ago } let(:one_year_ago) { 1.year.ago } @@ -14,6 +15,8 @@ RSpec.describe Gitlab::BackgroundMigration::WrongfullyConfirmedEmailUnconfirmer, let!(:user_does_not_need_migration) { users.create!(name: 'user3', email: 'test3@test.com', state: 'active', projects_limit: 1) } let!(:inactive_user) { users.create!(name: 'user4', email: 'test4@test.com', state: 'blocked', projects_limit: 1, confirmed_at: confirmed_at_3_days_ago, confirmation_sent_at: one_year_ago) } let!(:alert_bot_user) { users.create!(name: 'user5', email: 'test5@test.com', state: 'active', user_type: 2, projects_limit: 1, confirmed_at: confirmed_at_3_days_ago, confirmation_sent_at: one_year_ago) } + let!(:user_has_synced_email) { users.create!(name: 'user6', email: 'test6@test.com', state: 'active', projects_limit: 1, confirmed_at: confirmed_at_2_days_ago, confirmation_sent_at: one_year_ago) } + let!(:synced_attributes_metadata_for_user) { user_synced_attributes_metadata.create!(user_id: user_has_synced_email.id, email_synced: true) } let!(:bad_email_1) { emails.create!(user_id: user_needs_migration_1.id, email: 'other1@test.com', confirmed_at: confirmed_at_2_days_ago, confirmation_sent_at: one_year_ago) } let!(:bad_email_2) { emails.create!(user_id: user_needs_migration_2.id, email: 'other2@test.com', confirmed_at: confirmed_at_3_days_ago, confirmation_sent_at: one_year_ago) } @@ -24,8 +27,10 @@ RSpec.describe Gitlab::BackgroundMigration::WrongfullyConfirmedEmailUnconfirmer, let!(:good_email_2) { emails.create!(user_id: user_needs_migration_2.id, email: 'other4@test.com', confirmed_at: nil) } let!(:good_email_3) { emails.create!(user_id: user_does_not_need_migration.id, email: 'other5@test.com', confirmed_at: confirmed_at_2_days_ago, confirmation_sent_at: one_year_ago) } + let!(:second_email_for_user_with_synced_email) { emails.create!(user_id: user_has_synced_email.id, email: 'other6@test.com', confirmed_at: confirmed_at_2_days_ago, confirmation_sent_at: one_year_ago) } + subject do - email_ids = [bad_email_1, bad_email_2, good_email_1, good_email_2, good_email_3].map(&:id) + email_ids = [bad_email_1, bad_email_2, good_email_1, good_email_2, good_email_3, second_email_for_user_with_synced_email].map(&:id) described_class.new.perform(email_ids.min, email_ids.max) end @@ -61,10 +66,12 @@ RSpec.describe Gitlab::BackgroundMigration::WrongfullyConfirmedEmailUnconfirmer, expect(user_does_not_need_migration.reload.confirmed_at).to be_nil expect(inactive_user.reload.confirmed_at).to be_within(1.second).of(confirmed_at_3_days_ago) expect(alert_bot_user.reload.confirmed_at).to be_within(1.second).of(confirmed_at_3_days_ago) + expect(user_has_synced_email.reload.confirmed_at).to be_within(1.second).of(confirmed_at_2_days_ago) expect(user_does_not_need_migration.reload.confirmation_sent_at).to be_nil expect(inactive_user.reload.confirmation_sent_at).to be_within(1.second).of(one_year_ago) expect(alert_bot_user.reload.confirmation_sent_at).to be_within(1.second).of(one_year_ago) + expect(user_has_synced_email.confirmation_sent_at).to be_within(1.second).of(one_year_ago) end it 'updates confirmation_sent_at column' do |