diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-01 00:08:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-01 00:08:05 +0300 |
commit | abae8f34f377519946a91101ef7abf504454531c (patch) | |
tree | 359fab0082860b6850d4a0a492b8f12eb3d4eb0b /spec/controllers | |
parent | 580622bdb3c762a8e89facd8a3946881ee480442 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
27 files changed, 88 insertions, 80 deletions
diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb index ea51f3fcdf4..33764818f79 100644 --- a/spec/controllers/admin/application_settings_controller_spec.rb +++ b/spec/controllers/admin/application_settings_controller_spec.rb @@ -23,7 +23,7 @@ describe Admin::ApplicationSettingsController do it 'returns 404' do get :usage_data, format: :html - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -37,7 +37,7 @@ describe Admin::ApplicationSettingsController do get :usage_data, format: :html expect(response.body).to start_with('<span') - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end it 'returns JSON data' do @@ -46,7 +46,7 @@ describe Admin::ApplicationSettingsController do body = json_response expect(body["version"]).to eq(Gitlab::VERSION) expect(body).to include('counts') - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end end diff --git a/spec/controllers/admin/clusters_controller_spec.rb b/spec/controllers/admin/clusters_controller_spec.rb index 1f5c33d8022..bd6d5614ccd 100644 --- a/spec/controllers/admin/clusters_controller_spec.rb +++ b/spec/controllers/admin/clusters_controller_spec.rb @@ -261,7 +261,7 @@ describe Admin::ClustersController do cluster = Clusters::Cluster.instance_type.first - expect(response.status).to eq(201) + expect(response).to have_gitlab_http_status(:created) expect(response.location).to eq(admin_cluster_path(cluster)) expect(cluster).to be_aws expect(cluster).to be_kubernetes @@ -277,7 +277,7 @@ describe Admin::ClustersController do it 'does not create a cluster' do expect { post_create_aws }.not_to change { Clusters::Cluster.count } - expect(response.status).to eq(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) expect(response.content_type).to eq('application/json') expect(response.body).to include('is invalid') end @@ -389,7 +389,7 @@ describe Admin::ClustersController do it 'creates an Aws::Role record' do expect { go }.to change { Aws::Role.count } - expect(response.status).to eq 200 + expect(response).to have_gitlab_http_status(:ok) role = Aws::Role.last expect(role.user).to eq admin @@ -403,7 +403,7 @@ describe Admin::ClustersController do it 'does not create a record' do expect { go }.not_to change { Aws::Role.count } - expect(response.status).to eq 422 + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end diff --git a/spec/controllers/autocomplete_controller_spec.rb b/spec/controllers/autocomplete_controller_spec.rb index 1ebbeecc583..f3d4234a558 100644 --- a/spec/controllers/autocomplete_controller_spec.rb +++ b/spec/controllers/autocomplete_controller_spec.rb @@ -173,7 +173,7 @@ describe AutocompleteController do it 'gives an array of users' do get :users, params: { todo_filter: true } - expect(response.status).to eq 200 + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_kind_of(Array) end end diff --git a/spec/controllers/concerns/lfs_request_spec.rb b/spec/controllers/concerns/lfs_request_spec.rb index 67c81156ca6..f771a3438cf 100644 --- a/spec/controllers/concerns/lfs_request_spec.rb +++ b/spec/controllers/concerns/lfs_request_spec.rb @@ -48,7 +48,7 @@ describe LfsRequest do it 'returns 403' do get :show, params: { id: project.id } - expect(response.status).to eq(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -57,7 +57,7 @@ describe LfsRequest do it 'returns 404' do get :show, params: { id: 'does not exist' } - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -67,7 +67,7 @@ describe LfsRequest do it 'returns 404' do get :show, params: { id: project.id } - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/dashboard/todos_controller_spec.rb b/spec/controllers/dashboard/todos_controller_spec.rb index 0823afe410d..cea0ea75e5d 100644 --- a/spec/controllers/dashboard/todos_controller_spec.rb +++ b/spec/controllers/dashboard/todos_controller_spec.rb @@ -68,7 +68,7 @@ describe Dashboard::TodosController do create(:todo, project: project, author: author, user: user, target: merge_request_2) expect { get :index }.not_to exceed_query_limit(control) - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end end diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb index 0c1089dc7a8..a8e78524910 100644 --- a/spec/controllers/graphql_controller_spec.rb +++ b/spec/controllers/graphql_controller_spec.rb @@ -50,7 +50,7 @@ describe GraphqlController do post :execute - expect(response.status).to eq(403) + expect(response).to have_gitlab_http_status(:forbidden) expect(response).to render_template('errors/access_denied') end end diff --git a/spec/controllers/groups/clusters_controller_spec.rb b/spec/controllers/groups/clusters_controller_spec.rb index cdb45e1946e..28a174560dd 100644 --- a/spec/controllers/groups/clusters_controller_spec.rb +++ b/spec/controllers/groups/clusters_controller_spec.rb @@ -388,7 +388,7 @@ describe Groups::ClustersController do cluster = group.clusters.first - expect(response.status).to eq(201) + expect(response).to have_gitlab_http_status(:created) expect(response.location).to eq(group_cluster_path(group, cluster)) expect(cluster).to be_aws expect(cluster).to be_kubernetes @@ -404,7 +404,7 @@ describe Groups::ClustersController do it 'does not create a cluster' do expect { post_create_aws }.not_to change { Clusters::Cluster.count } - expect(response.status).to eq(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) expect(response.content_type).to eq('application/json') expect(response.body).to include('is invalid') end @@ -451,7 +451,7 @@ describe Groups::ClustersController do it 'creates an Aws::Role record' do expect { go }.to change { Aws::Role.count } - expect(response.status).to eq 200 + expect(response).to have_gitlab_http_status(:ok) role = Aws::Role.last expect(role.user).to eq user @@ -465,7 +465,7 @@ describe Groups::ClustersController do it 'does not create a record' do expect { go }.not_to change { Aws::Role.count } - expect(response.status).to eq 422 + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 22427f581d4..7bd0f6bd6b8 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -32,7 +32,7 @@ describe GroupsController do get :new, params: { parent_id: group.id } expect(response).not_to render_template(:new) - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -373,7 +373,7 @@ describe GroupsController do delete :destroy, params: { id: group.to_param } - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/controllers/metrics_controller_spec.rb b/spec/controllers/metrics_controller_spec.rb index 331eafba0d3..75509cc509f 100644 --- a/spec/controllers/metrics_controller_spec.rb +++ b/spec/controllers/metrics_controller_spec.rb @@ -33,7 +33,7 @@ describe MetricsController, :request_store do it 'returns prometheus metrics' do get :index - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.body).to match(/^prometheus_counter 1$/) end @@ -45,7 +45,7 @@ describe MetricsController, :request_store do it 'returns proper response' do get :index - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.body).to eq("# Metrics are disabled, see: http://test.host/help/administration/monitoring/prometheus/gitlab_metrics#gitlab-prometheus-metrics\n") end end @@ -75,7 +75,7 @@ describe MetricsController, :request_store do it 'returns the expected error response' do get :index - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/notification_settings_controller_spec.rb b/spec/controllers/notification_settings_controller_spec.rb index 7b19c67cad3..f3b608aee0c 100644 --- a/spec/controllers/notification_settings_controller_spec.rb +++ b/spec/controllers/notification_settings_controller_spec.rb @@ -50,7 +50,7 @@ describe NotificationSettingsController do notification_setting: { level: :participating } } - expect(response.status).to eq 200 + expect(response).to have_gitlab_http_status(:ok) expect(notification_setting.level).to eq("participating") expect(notification_setting.user_id).to eq(user.id) expect(notification_setting.source_id).to eq(project.id) @@ -65,7 +65,7 @@ describe NotificationSettingsController do notification_setting: { level: :custom }.merge(custom_events) } - expect(response.status).to eq 200 + expect(response).to have_gitlab_http_status(:ok) expect(notification_setting.level).to eq("custom") custom_events.each do |event, value| @@ -85,7 +85,7 @@ describe NotificationSettingsController do notification_setting: { level: :watch } } - expect(response.status).to eq 200 + expect(response).to have_gitlab_http_status(:ok) expect(notification_setting.level).to eq("watch") expect(notification_setting.user_id).to eq(user.id) expect(notification_setting.source_id).to eq(group.id) @@ -100,7 +100,7 @@ describe NotificationSettingsController do notification_setting: { level: :custom }.merge(custom_events) } - expect(response.status).to eq 200 + expect(response).to have_gitlab_http_status(:ok) expect(notification_setting.level).to eq("custom") custom_events.each do |event, value| @@ -157,7 +157,7 @@ describe NotificationSettingsController do notification_setting: { level: :participating } } - expect(response.status).to eq 200 + expect(response).to have_gitlab_http_status(:ok) end context 'and setting custom notification setting' do @@ -176,7 +176,7 @@ describe NotificationSettingsController do notification_setting: { level: :participating, events: custom_events } } - expect(response.status).to eq 200 + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/controllers/oauth/token_info_controller_spec.rb b/spec/controllers/oauth/token_info_controller_spec.rb index 35ad0dcf98c..4b3539879df 100644 --- a/spec/controllers/oauth/token_info_controller_spec.rb +++ b/spec/controllers/oauth/token_info_controller_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Oauth::TokenInfoController do it 'responds with a 401' do get :show - expect(response.status).to eq 401 + expect(response).to have_gitlab_http_status(:unauthorized) expect(JSON.parse(response.body)).to include('error' => 'invalid_request') end end @@ -22,7 +22,7 @@ RSpec.describe Oauth::TokenInfoController do it 'responds with the token info' do get :show, params: { access_token: access_token.token } - expect(response.status).to eq 200 + expect(response).to have_gitlab_http_status(:ok) expect(JSON.parse(response.body)).to eq( 'scope' => %w[api], 'scopes' => %w[api], @@ -39,7 +39,7 @@ RSpec.describe Oauth::TokenInfoController do it 'responds with a 401' do get :show, params: { access_token: 'unknown_token' } - expect(response.status).to eq 401 + expect(response).to have_gitlab_http_status(:unauthorized) expect(JSON.parse(response.body)).to include('error' => 'invalid_request') end end @@ -52,7 +52,7 @@ RSpec.describe Oauth::TokenInfoController do it 'responds with a 401' do get :show, params: { access_token: access_token.token } - expect(response.status).to eq 401 + expect(response).to have_gitlab_http_status(:unauthorized) expect(JSON.parse(response.body)).to include('error' => 'invalid_request') end end @@ -63,7 +63,7 @@ RSpec.describe Oauth::TokenInfoController do it 'responds with a 401' do get :show, params: { access_token: access_token.token } - expect(response.status).to eq 401 + expect(response).to have_gitlab_http_status(:unauthorized) expect(JSON.parse(response.body)).to include('error' => 'invalid_request') end end diff --git a/spec/controllers/omniauth_callbacks_controller_spec.rb b/spec/controllers/omniauth_callbacks_controller_spec.rb index 71cdba12147..9537ff62f8b 100644 --- a/spec/controllers/omniauth_callbacks_controller_spec.rb +++ b/spec/controllers/omniauth_callbacks_controller_spec.rb @@ -234,7 +234,7 @@ describe OmniauthCallbacksController, type: :controller, do_not_mock_admin_mode: post 'auth0' expect(request.env['warden']).not_to be_authenticated - expect(response.status).to eq(302) + expect(response).to have_gitlab_http_status(:found) expect(controller).to set_flash[:alert].to('Wrong extern UID provided. Make sure Auth0 is configured correctly.') end end @@ -249,7 +249,7 @@ describe OmniauthCallbacksController, type: :controller, do_not_mock_admin_mode: post 'salesforce' expect(request.env['warden']).not_to be_authenticated - expect(response.status).to eq(302) + expect(response).to have_gitlab_http_status(:found) expect(controller).to set_flash[:alert].to('Email not verified. Please verify your email in Salesforce.') end end diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index f0d83bb6bbd..d6d2c73d049 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -14,7 +14,7 @@ describe ProfilesController, :request_store do params: { user: { password: 'hello12345', password_confirmation: 'hello12345' } } end.not_to change { user.reload.encrypted_password } - expect(response.status).to eq(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -27,7 +27,7 @@ describe ProfilesController, :request_store do user.reload - expect(response.status).to eq(302) + expect(response).to have_gitlab_http_status(:found) expect(user.unconfirmed_email).to eq('john@gmail.com') end @@ -41,7 +41,7 @@ describe ProfilesController, :request_store do user.reload - expect(response.status).to eq(302) + expect(response).to have_gitlab_http_status(:found) expect(user.unconfirmed_email).to eq nil end @@ -58,7 +58,7 @@ describe ProfilesController, :request_store do ldap_user.reload - expect(response.status).to eq(302) + expect(response).to have_gitlab_http_status(:found) expect(ldap_user.unconfirmed_email).not_to eq('john@gmail.com') end @@ -75,7 +75,7 @@ describe ProfilesController, :request_store do ldap_user.reload - expect(response.status).to eq(302) + expect(response).to have_gitlab_http_status(:found) expect(ldap_user.unconfirmed_email).not_to eq('john@gmail.com') expect(ldap_user.name).not_to eq('John') expect(ldap_user.location).to eq('City, Country') @@ -114,7 +114,7 @@ describe ProfilesController, :request_store do user.reload - expect(response.status).to eq(302) + expect(response).to have_gitlab_http_status(:found) expect(user.username).to eq(new_username) end @@ -127,7 +127,7 @@ describe ProfilesController, :request_store do }, format: :json - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['message']).to eq(s_('Profiles|Username successfully changed')) end @@ -140,7 +140,7 @@ describe ProfilesController, :request_store do }, format: :json - expect(response.status).to eq(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) expect(json_response['message']).to match(/Username change failed/) end @@ -162,7 +162,7 @@ describe ProfilesController, :request_store do user.reload - expect(response.status).to eq(302) + expect(response).to have_gitlab_http_status(:found) expect(gitlab_shell.repository_exists?(project.repository_storage, "#{new_username}/#{project.path}.git")).to be_truthy end end @@ -180,7 +180,7 @@ describe ProfilesController, :request_store do user.reload - expect(response.status).to eq(302) + expect(response).to have_gitlab_http_status(:found) expect(gitlab_shell.repository_exists?(project.repository_storage, "#{project.disk_path}.git")).to be_truthy expect(before_disk_path).to eq(project.disk_path) end diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb index a224a2101d3..a5683a27837 100644 --- a/spec/controllers/projects/clusters_controller_spec.rb +++ b/spec/controllers/projects/clusters_controller_spec.rb @@ -387,7 +387,7 @@ describe Projects::ClustersController do cluster = project.clusters.first - expect(response.status).to eq(201) + expect(response).to have_gitlab_http_status(:created) expect(response.location).to eq(project_cluster_path(project, cluster)) expect(cluster).to be_aws expect(cluster).to be_kubernetes @@ -403,7 +403,7 @@ describe Projects::ClustersController do it 'does not create a cluster' do expect { post_create_aws }.not_to change { Clusters::Cluster.count } - expect(response.status).to eq(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) expect(response.content_type).to eq('application/json') expect(response.body).to include('is invalid') end @@ -450,7 +450,7 @@ describe Projects::ClustersController do it 'creates an Aws::Role record' do expect { go }.to change { Aws::Role.count } - expect(response.status).to eq 200 + expect(response).to have_gitlab_http_status(:ok) role = Aws::Role.last expect(role.user).to eq user @@ -464,7 +464,7 @@ describe Projects::ClustersController do it 'does not create a record' do expect { go }.not_to change { Aws::Role.count } - expect(response.status).to eq 422 + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end diff --git a/spec/controllers/projects/group_links_controller_spec.rb b/spec/controllers/projects/group_links_controller_spec.rb index f8271bc8e8a..28999257957 100644 --- a/spec/controllers/projects/group_links_controller_spec.rb +++ b/spec/controllers/projects/group_links_controller_spec.rb @@ -59,7 +59,7 @@ describe Projects::GroupLinksController do include_context 'link project to group' it 'renders 404' do - expect(response.status).to eq 404 + expect(response).to have_gitlab_http_status(:not_found) end it 'does not share project with that group' do @@ -73,7 +73,7 @@ describe Projects::GroupLinksController do include_context 'link project to group' it 'renders 404' do - expect(response.status).to eq 404 + expect(response).to have_gitlab_http_status(:not_found) end it 'does not share project with that group' do diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index 2b1890f6cbd..5104c83283d 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -1557,7 +1557,7 @@ describe Projects::MergeRequestsController do post_rebase - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -1572,7 +1572,7 @@ describe Projects::MergeRequestsController do post_rebase - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -1583,7 +1583,7 @@ describe Projects::MergeRequestsController do post_rebase - expect(response.status).to eq(409) + expect(response).to have_gitlab_http_status(:conflict) expect(json_response['merge_error']).to eq('Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later.') end end @@ -1605,7 +1605,7 @@ describe Projects::MergeRequestsController do post_rebase - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -1621,7 +1621,7 @@ describe Projects::MergeRequestsController do post_rebase - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -1639,7 +1639,7 @@ describe Projects::MergeRequestsController do it 'returns 200' do get :discussions, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid } - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end context 'highlight preloading' do diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index 74931fcdeb2..0368130118f 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -923,10 +923,18 @@ describe Projects::PipelinesController do end context 'ref provided' do + render_views + before do create(:ci_pipeline, ref: 'master', project: project) end + it 'shows a 404 if no pipeline exists' do + get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: 'non-existence' } + + expect(response).to have_gitlab_http_status(:not_found) + end + it 'shows the latest pipeline for the provided ref' do get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: branch_secondary.name } diff --git a/spec/controllers/projects/project_members_controller_spec.rb b/spec/controllers/projects/project_members_controller_spec.rb index 09420cc8556..f354bba902a 100644 --- a/spec/controllers/projects/project_members_controller_spec.rb +++ b/spec/controllers/projects/project_members_controller_spec.rb @@ -392,7 +392,7 @@ describe Projects::ProjectMembersController do end it 'responds with not found' do - expect(response.status).to eq 404 + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/protected_branches_controller_spec.rb b/spec/controllers/projects/protected_branches_controller_spec.rb index 0ebbb4b581f..262f77a7328 100644 --- a/spec/controllers/projects/protected_branches_controller_spec.rb +++ b/spec/controllers/projects/protected_branches_controller_spec.rb @@ -103,7 +103,7 @@ describe Projects::ProtectedBranchesController do it "prevents deletion of the protected branch rule" do delete(:destroy, params: base_params) - expect(response.status).to eq(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end diff --git a/spec/controllers/projects/releases_controller_spec.rb b/spec/controllers/projects/releases_controller_spec.rb index 4c957e22d24..45f4433ed0a 100644 --- a/spec/controllers/projects/releases_controller_spec.rb +++ b/spec/controllers/projects/releases_controller_spec.rb @@ -36,7 +36,7 @@ describe Projects::ReleasesController do it 'renders a 200' do get_index - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end context 'when the project is private' do @@ -54,7 +54,7 @@ describe Projects::ReleasesController do get_index - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -66,7 +66,7 @@ describe Projects::ReleasesController do get_index - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/templates_controller_spec.rb b/spec/controllers/projects/templates_controller_spec.rb index b4b04878181..fcd9b4aa8bd 100644 --- a/spec/controllers/projects/templates_controller_spec.rb +++ b/spec/controllers/projects/templates_controller_spec.rb @@ -15,7 +15,7 @@ describe Projects::TemplatesController do it do get(:show, params: { namespace_id: project.namespace, template_type: 'issue', key: 'issue_template', project_id: project }, format: :json) - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['name']).to eq('issue_template') expect(json_response['content']).to eq('issue content') end @@ -25,7 +25,7 @@ describe Projects::TemplatesController do it do get(:show, params: { namespace_id: project.namespace, template_type: 'merge_request', key: 'merge_request_template', project_id: project }, format: :json) - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['name']).to eq('merge_request_template') expect(json_response['content']).to eq('merge request content') end @@ -35,7 +35,7 @@ describe Projects::TemplatesController do it do get(:show, params: { namespace_id: project.namespace, template_type: 'issue', key: 'issue_template', project_id: project }, format: :json) - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -43,7 +43,7 @@ describe Projects::TemplatesController do it do get(:show, params: { namespace_id: project.namespace, template_type: 'merge_request', key: 'merge_request_template', project_id: project }, format: :json) - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -57,13 +57,13 @@ describe Projects::TemplatesController do it 'renders 404 when the format type is invalid' do get(:show, params: { namespace_id: project.namespace, template_type: 'issue', key: 'issue_template', project_id: project }, format: :html) - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'renders 404 when the key is unknown' do get(:show, params: { namespace_id: project.namespace, template_type: 'issue', key: 'unknown_template', project_id: project }, format: :json) - expect(response.status).to eq(404) + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 53a57937e9b..d0e0dabc9f2 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -294,7 +294,7 @@ describe ProjectsController do get :show, params: { namespace_id: project.namespace, id: project } - expect(response.status).to eq 404 + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index d7fe3e87056..0b4ecb68cf7 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -334,7 +334,7 @@ describe RegistrationsController do def expect_failure(message) expect(flash[:alert]).to eq(message) - expect(response.status).to eq(303) + expect(response).to have_gitlab_http_status(:see_other) expect(response).to redirect_to profile_account_path end @@ -348,7 +348,7 @@ describe RegistrationsController do def expect_success expect(flash[:notice]).to eq s_('Profiles|Account scheduled for removal.') - expect(response.status).to eq(303) + expect(response).to have_gitlab_http_status(:see_other) expect(response).to redirect_to new_user_session_path end diff --git a/spec/controllers/repositories/git_http_controller_spec.rb b/spec/controllers/repositories/git_http_controller_spec.rb index 0bd2305ff85..de14384eb6f 100644 --- a/spec/controllers/repositories/git_http_controller_spec.rb +++ b/spec/controllers/repositories/git_http_controller_spec.rb @@ -23,7 +23,7 @@ describe Repositories::GitHttpController do it 'returns 403' do head :info_refs, params: params - expect(response.status).to eq(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -39,7 +39,7 @@ describe Repositories::GitHttpController do get :info_refs, params: params - expect(response.status).to eq(401) + expect(response).to have_gitlab_http_status(:unauthorized) end context 'with authorized user' do @@ -50,7 +50,7 @@ describe Repositories::GitHttpController do it 'returns 200' do get :info_refs, params: params - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end it 'updates the user activity' do @@ -72,7 +72,7 @@ describe Repositories::GitHttpController do get :info_refs, params: params - expect(response.status).to eq(503) + expect(response).to have_gitlab_http_status(:service_unavailable) end it 'returns 503 with timeout error' do @@ -80,7 +80,7 @@ describe Repositories::GitHttpController do get :info_refs, params: params - expect(response.status).to eq(503) + expect(response).to have_gitlab_http_status(:service_unavailable) expect(response.body).to eq 'Gitlab::GitAccess::TimeoutError' end end diff --git a/spec/controllers/sent_notifications_controller_spec.rb b/spec/controllers/sent_notifications_controller_spec.rb index b4b867f5c66..a0a18f66b0c 100644 --- a/spec/controllers/sent_notifications_controller_spec.rb +++ b/spec/controllers/sent_notifications_controller_spec.rb @@ -76,7 +76,7 @@ describe SentNotificationsController do end it 'renders unsubscribe page' do - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template :unsubscribe end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index f3e2ea50913..af2e452c0ca 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -153,7 +153,7 @@ describe SessionsController do it 'returns status 403' do post(:create, params: { user: user_params }) - expect(response.status).to eq 403 + expect(response).to have_gitlab_http_status(:forbidden) end end diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb index e41deae0e89..05c48fb190c 100644 --- a/spec/controllers/snippets_controller_spec.rb +++ b/spec/controllers/snippets_controller_spec.rb @@ -720,7 +720,7 @@ describe SnippetsController do post(:toggle_award_emoji, params: { id: personal_snippet.to_param, name: "thumbsup" }) end.to change { personal_snippet.award_emoji.count }.from(0).to(1) - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end it "removes the already awarded emoji" do @@ -730,7 +730,7 @@ describe SnippetsController do post(:toggle_award_emoji, params: { id: personal_snippet.to_param, name: "thumbsup" }) end.to change { personal_snippet.award_emoji.count }.from(1).to(0) - expect(response.status).to eq(200) + expect(response).to have_gitlab_http_status(:ok) end end end |