summaryrefslogtreecommitdiff
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 00:10:13 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 00:10:13 +0000
commit82cd20acf9f4cceecf222abe718a9e23cef55687 (patch)
tree4587ee980cd01ceaeeeaa4ad3de5d94a1d9166e8 /spec/models/user_spec.rb
parenta7d1db72c912ef512c25724392f1c903e8d3bd7e (diff)
downloadgitlab-ce-82cd20acf9f4cceecf222abe718a9e23cef55687.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb32
1 files changed, 21 insertions, 11 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index cd84bf54e8f..05415754a1c 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1943,18 +1943,28 @@ describe User, :do_not_mock_admin_mode do
describe '#all_emails' do
let(:user) { create(:user) }
+ let!(:email_confirmed) { create :email, user: user, confirmed_at: Time.now }
+ let!(:email_unconfirmed) { create :email, user: user }
+
+ context 'when `include_private_email` is true' do
+ it 'returns all emails' do
+ expect(user.reload.all_emails).to contain_exactly(
+ user.email,
+ user.private_commit_email,
+ email_unconfirmed.email,
+ email_confirmed.email
+ )
+ end
+ end
- it 'returns all emails' do
- email_confirmed = create :email, user: user, confirmed_at: Time.now
- email_unconfirmed = create :email, user: user
- user.reload
-
- expect(user.all_emails).to contain_exactly(
- user.email,
- user.private_commit_email,
- email_unconfirmed.email,
- email_confirmed.email
- )
+ context 'when `include_private_email` is false' do
+ it 'does not include the private commit email' do
+ expect(user.reload.all_emails(include_private_email: false)).to contain_exactly(
+ user.email,
+ email_unconfirmed.email,
+ email_confirmed.email
+ )
+ end
end
end