diff options
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/deploy_keys_spec.rb | 54 | ||||
-rw-r--r-- | spec/requests/jwt_controller_spec.rb | 9 |
2 files changed, 3 insertions, 60 deletions
diff --git a/spec/requests/api/deploy_keys_spec.rb b/spec/requests/api/deploy_keys_spec.rb index 1baa18b53ce..e8cc6bc71ae 100644 --- a/spec/requests/api/deploy_keys_spec.rb +++ b/spec/requests/api/deploy_keys_spec.rb @@ -8,7 +8,7 @@ describe API::DeployKeys do let(:admin) { create(:admin) } let(:project) { create(:project, creator_id: user.id) } let(:project2) { create(:project, creator_id: user.id) } - let(:deploy_key) { create(:deploy_key, public: true, user: user) } + let(:deploy_key) { create(:deploy_key, public: true) } let!(:deploy_keys_project) do create(:deploy_keys_project, project: project, deploy_key: deploy_key) @@ -40,32 +40,6 @@ describe API::DeployKeys do expect(json_response).to be_an Array expect(json_response.first['id']).to eq(deploy_keys_project.deploy_key.id) end - - it 'returns all deploy keys with comments replaced with'\ - 'a simple identifier of username + hostname' do - get api('/deploy_keys', admin) - - expect(response).to have_gitlab_http_status(:ok) - expect(response).to include_pagination_headers - expect(json_response).to be_an Array - - keys = json_response.map { |key_detail| key_detail['key'] } - expect(keys).to all(include("#{user.name} (#{Gitlab.config.gitlab.host}")) - end - - context 'N+1 queries' do - before do - get api('/deploy_keys', admin) - end - - it 'avoids N+1 queries', :request_store do - control_count = ActiveRecord::QueryRecorder.new { get api('/deploy_keys', admin) }.count - - create_list(:deploy_key, 2, public: true, user: create(:user)) - - expect { get api('/deploy_keys', admin) }.not_to exceed_query_limit(control_count) - end - end end end @@ -82,25 +56,6 @@ describe API::DeployKeys do expect(json_response).to be_an Array expect(json_response.first['title']).to eq(deploy_key.title) end - - context 'N+1 queries' do - before do - get api("/projects/#{project.id}/deploy_keys", admin) - end - - it 'avoids N+1 queries', :request_store do - control_count = ActiveRecord::QueryRecorder.new do - get api("/projects/#{project.id}/deploy_keys", admin) - end.count - - deploy_key = create(:deploy_key, user: create(:user)) - create(:deploy_keys_project, project: project, deploy_key: deploy_key) - - expect do - get api("/projects/#{project.id}/deploy_keys", admin) - end.not_to exceed_query_limit(control_count) - end - end end describe 'GET /projects/:id/deploy_keys/:key_id' do @@ -111,13 +66,6 @@ describe API::DeployKeys do expect(json_response['title']).to eq(deploy_key.title) end - it 'exposes key comment as a simple identifier of username + hostname' do - get api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin) - - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['key']).to include("#{deploy_key.user_name} (#{Gitlab.config.gitlab.host})") - end - it 'returns 404 Not Found with invalid ID' do get api("/projects/#{project.id}/deploy_keys/404", admin) diff --git a/spec/requests/jwt_controller_spec.rb b/spec/requests/jwt_controller_spec.rb index d860179f0a7..617587e2fa6 100644 --- a/spec/requests/jwt_controller_spec.rb +++ b/spec/requests/jwt_controller_spec.rb @@ -3,19 +3,14 @@ require 'spec_helper' describe JwtController do + include_context 'parsed logs' + let(:service) { double(execute: {}) } let(:service_class) { double(new: service) } let(:service_name) { 'test' } let(:parameters) { { service: service_name } } - let(:log_output) { StringIO.new } - let(:logger) do - Logger.new(log_output).tap { |logger| logger.formatter = ->(_, _, _, msg) { msg } } - end - let(:log_data) { Gitlab::Json.parse(log_output.string) } before do - Lograge.logger = logger - stub_const('JwtController::SERVICES', service_name => service_class) end |