diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-10-25 11:09:53 +0100 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-10-25 11:36:26 +0100 |
commit | 679d9b21b7aac55796ef59d5694b7d2e0fb40b35 (patch) | |
tree | 0ce28ce2326a231aa2c65d324dea9168c17b024d /spec | |
parent | f8ee07d9ee6d01b255902ad976a07beef59a95fb (diff) | |
download | gitlab-ce-679d9b21b7aac55796ef59d5694b7d2e0fb40b35.tar.gz |
Removes idenfitication by commit from Gitlab::Identifier51335-fail-early-when-user-cannot-be-identified
Before we would need to identify a user when pushing
through the GitLab UI. Since this is no longer the case
we can remove the identification by commit and instead,
use the identify_using_user
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/identifier_spec.rb | 49 | ||||
-rw-r--r-- | spec/workers/post_receive_spec.rb | 11 |
2 files changed, 15 insertions, 45 deletions
diff --git a/spec/lib/gitlab/identifier_spec.rb b/spec/lib/gitlab/identifier_spec.rb index 0385dd762c2..1e583f4cee2 100644 --- a/spec/lib/gitlab/identifier_spec.rb +++ b/spec/lib/gitlab/identifier_spec.rb @@ -11,11 +11,8 @@ describe Gitlab::Identifier do describe '#identify' do context 'without an identifier' do - it 'identifies the user using a commit' do - expect(identifier).to receive(:identify_using_commit) - .with(project, '123') - - identifier.identify('', project, '123') + it 'returns nil' do + expect(identifier.identify('')).to be nil end end @@ -24,7 +21,7 @@ describe Gitlab::Identifier do expect(identifier).to receive(:identify_using_user) .with("user-#{user.id}") - identifier.identify("user-#{user.id}", project, '123') + identifier.identify("user-#{user.id}") end end @@ -33,49 +30,11 @@ describe Gitlab::Identifier do expect(identifier).to receive(:identify_using_ssh_key) .with("key-#{key.id}") - identifier.identify("key-#{key.id}", project, '123') + identifier.identify("key-#{key.id}") end end end - describe '#identify_using_commit' do - it "returns the User for an existing commit author's Email address" do - commit = double(:commit, author: user, author_email: user.email) - - expect(project).to receive(:commit).with('123').and_return(commit) - - expect(identifier.identify_using_commit(project, '123')).to eq(user) - end - - it 'returns nil when no user could be found' do - allow(project).to receive(:commit).with('123').and_return(nil) - - expect(identifier.identify_using_commit(project, '123')).to be_nil - end - - it 'returns nil when the commit does not have an author Email' do - commit = double(:commit, author_email: nil) - - expect(project).to receive(:commit).with('123').and_return(commit) - - expect(identifier.identify_using_commit(project, '123')).to be_nil - end - - it 'caches the found users per Email' do - commit = double(:commit, author: user, author_email: user.email) - - expect(project).to receive(:commit).with('123').twice.and_return(commit) - - 2.times do - expect(identifier.identify_using_commit(project, '123')).to eq(user) - end - end - - it 'returns nil if the project & ref are not present' do - expect(identifier.identify_using_commit(nil, nil)).to be_nil - end - end - describe '#identify_using_user' do it 'returns the User for an existing ID in the identifier' do found = identifier.identify_using_user("user-#{user.id}") diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index 1184bd9492a..9176eb12b12 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -41,6 +41,17 @@ describe PostReceive do end end + context 'unidentified user' do + let!(:key_id) { "" } + + it 'returns false' do + expect(GitPushService).not_to receive(:new) + expect(GitTagPushService).not_to receive(:new) + + expect(described_class.new.perform(gl_repository, key_id, base64_changes)).to be false + end + end + context 'with changes' do before do allow_any_instance_of(Gitlab::GitPostReceive).to receive(:identify).and_return(project.owner) |