diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-04 03:06:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-04 03:06:15 +0300 |
commit | e2334f3613aae1c0f5b99d908e1c51213bfd7635 (patch) | |
tree | 8fd02806b70ffe4d49633412bfa2c7b58304095c /spec | |
parent | 4529c19950e412f0461910585414f8633d3b1b18 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/user_finder_spec.rb | 22 | ||||
-rw-r--r-- | spec/lib/api/support/git_access_actor_spec.rb | 15 | ||||
-rw-r--r-- | spec/requests/api/internal/base_spec.rb | 11 |
3 files changed, 21 insertions, 27 deletions
diff --git a/spec/finders/user_finder_spec.rb b/spec/finders/user_finder_spec.rb index c20d7850d68..b89b422aa2c 100644 --- a/spec/finders/user_finder_spec.rb +++ b/spec/finders/user_finder_spec.rb @@ -176,26 +176,4 @@ describe UserFinder do end end end - - describe '#find_by_ssh_key_id' do - let_it_be(:ssh_key) { create(:key, user: user) } - - it 'returns the user when passing the ssh key id' do - found = described_class.new(ssh_key.id).find_by_ssh_key_id - - expect(found).to eq(user) - end - - it 'returns the user when passing the ssh key id (string)' do - found = described_class.new(ssh_key.id.to_s).find_by_ssh_key_id - - expect(found).to eq(user) - end - - it 'returns nil when the id does not exist' do - found = described_class.new(-1).find_by_ssh_key_id - - expect(found).to be_nil - end - end end diff --git a/spec/lib/api/support/git_access_actor_spec.rb b/spec/lib/api/support/git_access_actor_spec.rb index 63f5966faea..69637947c79 100644 --- a/spec/lib/api/support/git_access_actor_spec.rb +++ b/spec/lib/api/support/git_access_actor_spec.rb @@ -9,17 +9,26 @@ describe API::Support::GitAccessActor do subject { described_class.new(user: user, key: key) } describe '.from_params' do + let(:key) { create(:key) } + context 'with params that are valid' do it 'returns an instance of API::Support::GitAccessActor' do - params = { key_id: create(:key).id } + params = { key_id: key.id } expect(described_class.from_params(params)).to be_instance_of(described_class) end end context 'with params that are invalid' do - it 'returns nil' do - expect(described_class.from_params({})).to be_nil + it "returns an instance of #{described_class}" do + expect(described_class.from_params({})).to be_instance_of(described_class) + end + end + + context 'when passing an identifier used gitaly' do + it 'finds the user based on an identifier' do + expect(described_class).to receive(:identify).and_call_original + expect(described_class.from_params(identifier: "key-#{key.id}").user).to eq(key.user) end end end diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index fd3d1ebee20..7292e7a6a4e 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -193,7 +193,15 @@ describe API::Internal::Base do end it 'responds successfully when a user is not found' do - get(api("/internal/discover"), params: { username: 'noone', secret_token: secret_token }) + get(api('/internal/discover'), params: { username: 'noone', secret_token: secret_token }) + + expect(response).to have_gitlab_http_status(200) + + expect(response.body).to eq('null') + end + + it 'response successfully when passing invalid params' do + get(api('/internal/discover'), params: { nothing: 'to find a user', secret_token: secret_token }) expect(response).to have_gitlab_http_status(200) @@ -819,7 +827,6 @@ describe API::Internal::Base do before do project.add_developer(user) - allow(described_class).to receive(:identify).and_return(user) allow_any_instance_of(Gitlab::Identifier).to receive(:identify).and_return(user) end |