diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 03:07:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 03:07:51 +0300 |
commit | 4e375367b78bb44bd00957522cd9fc3e6d403fef (patch) | |
tree | 059b1ce541e4128bf03683407d7b5bbbc2094ed5 /spec/models/commit_spec.rb | |
parent | 99ddca0d88f1e4e49d61b1aa9d41b5785528d1dc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/commit_spec.rb')
-rw-r--r-- | spec/models/commit_spec.rb | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 37c8484d69b..1c1b550c69b 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -80,6 +80,17 @@ describe Commit do expect(commit.author).to eq(user) end + context 'with a user with an unconfirmed e-mail' do + before do + user = create(:user) + create(:email, user: user, email: commit.author_email) + end + + it 'returns no user' do + expect(commit.author).to be_nil + end + end + context 'using eager loading' do let!(:alice) { create(:user, email: 'alice@example.com') } let!(:bob) { create(:user, email: 'hunter2@example.com') } @@ -115,7 +126,7 @@ describe Commit do let!(:commits) { [alice_commit, bob_commit, eve_commit, jeff_commit] } before do - create(:email, user: bob, email: 'bob@example.com') + create(:email, :confirmed, user: bob, email: 'bob@example.com') end it 'executes only two SQL queries' do @@ -179,6 +190,32 @@ describe Commit do end end + describe '#committer' do + context 'with a confirmed e-mail' do + it 'returns the user' do + user = create(:user, email: commit.committer_email) + + expect(commit.committer).to eq(user) + end + end + + context 'with an unconfirmed e-mail' do + let(:user) { create(:user) } + + before do + create(:email, user: user, email: commit.committer_email) + end + + it 'returns no user' do + expect(commit.committer).to be_nil + end + + it 'returns the user' do + expect(commit.committer(confirmed: false)).to eq(user) + end + end + end + describe '#to_reference' do let(:project) { create(:project, :repository, path: 'sample-project') } |