summaryrefslogtreecommitdiff
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
authorBrett Walker <brett@digitalmoksha.com>2017-09-20 14:51:27 +0200
committerBrett Walker <brett@digitalmoksha.com>2017-09-23 15:26:04 +0200
commitd7d335c05b9ae359b72f59c31bbe5ed059df7f52 (patch)
tree97922d2edab090408efffd6f968bd2b765e971c3 /spec/models/user_spec.rb
parent945667abd85b3b832159acda3bf1e3886175da46 (diff)
downloadgitlab-ce-d7d335c05b9ae359b72f59c31bbe5ed059df7f52.tar.gz
add primary email as a secondary email whenever the primary is changed
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 83addbb809e..839b1f5da79 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -374,7 +374,7 @@ describe User do
end
end
- describe 'after update hook' do
+ describe 'after commit hook' do
describe '.update_invalid_gpg_signatures' do
let(:user) do
create(:user, email: 'tula.torphy@abshire.ca').tap do |user|
@@ -388,7 +388,7 @@ describe User do
end
it 'synchronizes the gpg keys when the email is updated' do
- expect(user).to receive(:update_invalid_gpg_signatures)
+ expect(user).to receive(:update_invalid_gpg_signatures).at_most(:twice)
user.update_attributes!(email: 'shawnee.ritchie@denesik.com')
end
end
@@ -407,11 +407,11 @@ describe User do
@user.update_attributes!(email: 'new_primary@example.com')
end
- it 'does not add old primary to secondary emails' do
+ it 'adds old primary to secondary emails when secondary is a new email ' do
@user.update_attributes!(email: 'new_primary@example.com')
@user.reload
- expect(@user.emails.count).to eq 1
- expect(@user.emails.first.email).to eq @secondary.email
+ expect(@user.emails.count).to eq 2
+ expect(@user.emails.pluck(:email)).to match_array([@secondary.email, 'primary@example.com'])
end
it 'adds old primary to secondary emails if secondary is becoming a primary' do