diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 12:08:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 12:08:44 +0000 |
commit | db24ab2b72dbff24c201410a0561e929ae7e8061 (patch) | |
tree | 67297286aad8cc590ae325330a0bfe1e2a7e51dc /spec/controllers | |
parent | 7e8278c0f46cf6058efad5afd0aef177977bd663 (diff) | |
download | gitlab-ce-db24ab2b72dbff24c201410a0561e929ae7e8061.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
42 files changed, 317 insertions, 297 deletions
diff --git a/spec/controllers/projects/artifacts_controller_spec.rb b/spec/controllers/projects/artifacts_controller_spec.rb index 126bb1c9822..7aaaa363faa 100644 --- a/spec/controllers/projects/artifacts_controller_spec.rb +++ b/spec/controllers/projects/artifacts_controller_spec.rb @@ -156,7 +156,7 @@ describe Projects::ArtifactsController do it 'returns 404' do download_artifact(file_type: file_type) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -236,7 +236,7 @@ describe Projects::ArtifactsController do it 'renders the file view' do get :file, params: { namespace_id: project.namespace, project_id: project, job_id: job, path: 'ci_artifacts.txt' } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -302,7 +302,7 @@ describe Projects::ArtifactsController do it 'renders the file view' do get :file, params: { namespace_id: private_project.namespace, project_id: private_project, job_id: job, path: 'ci_artifacts.txt' } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end @@ -317,7 +317,7 @@ describe Projects::ArtifactsController do it 'serves the file using workhorse' do subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(send_data).to start_with('artifacts-entry:') expect(params.keys).to eq(%w(Archive Entry)) diff --git a/spec/controllers/projects/autocomplete_sources_controller_spec.rb b/spec/controllers/projects/autocomplete_sources_controller_spec.rb index fc8fe1ac4f6..d35192b2ccb 100644 --- a/spec/controllers/projects/autocomplete_sources_controller_spec.rb +++ b/spec/controllers/projects/autocomplete_sources_controller_spec.rb @@ -65,7 +65,7 @@ describe Projects::AutocompleteSourcesController do get :milestones, format: :json, params: { namespace_id: group.path, project_id: project.path } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/avatars_controller_spec.rb b/spec/controllers/projects/avatars_controller_spec.rb index d463619ad0b..1d844c847d6 100644 --- a/spec/controllers/projects/avatars_controller_spec.rb +++ b/spec/controllers/projects/avatars_controller_spec.rb @@ -16,7 +16,7 @@ describe Projects::AvatarsController do it 'shows 404' do subject - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -31,7 +31,7 @@ describe Projects::AvatarsController do it 'sends the avatar' do subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.header['Content-Disposition']).to eq('inline') expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:') expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true" diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index aa1dcdd9f1d..225538dcc45 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -232,7 +232,7 @@ describe Projects::BlobController do end it 'redirects to blob show' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -246,7 +246,7 @@ describe Projects::BlobController do end it 'redirects to blob show' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/controllers/projects/boards_controller_spec.rb b/spec/controllers/projects/boards_controller_spec.rb index 543479d8dd5..ebfdb997974 100644 --- a/spec/controllers/projects/boards_controller_spec.rb +++ b/spec/controllers/projects/boards_controller_spec.rb @@ -39,7 +39,7 @@ describe Projects::BoardsController do it 'returns a not found 404 response' do list_boards - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response.content_type).to eq 'text/html' end end @@ -82,7 +82,7 @@ describe Projects::BoardsController do it 'returns a not found 404 response' do list_boards format: :json - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response.content_type).to eq 'application/json' end end @@ -94,7 +94,7 @@ describe Projects::BoardsController do it 'returns a not found 404 response' do list_boards - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -137,7 +137,7 @@ describe Projects::BoardsController do it 'returns a not found 404 response' do read_board board: board - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response.content_type).to eq 'text/html' end end @@ -174,7 +174,7 @@ describe Projects::BoardsController do it 'returns a not found 404 response' do read_board board: board, format: :json - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response.content_type).to eq 'application/json' end end @@ -186,7 +186,7 @@ describe Projects::BoardsController do read_board board: another_board - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index 5b59534cb49..85d3044993e 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -217,7 +217,7 @@ describe Projects::BranchesController do } expect(response.location).to include(project_new_blob_path(project, branch)) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -238,7 +238,7 @@ describe Projects::BranchesController do } expect(response.location).to include(project_new_blob_path(project, branch)) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -289,7 +289,7 @@ describe Projects::BranchesController do it 'returns a successful 200 response' do create_branch name: 'my-branch', ref: 'master' - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'returns the created branch' do @@ -303,7 +303,7 @@ describe Projects::BranchesController do it 'returns an unprocessable entity 422 response' do create_branch name: "<script>alert('merge');</script>", ref: "<script>alert('ref');</script>" - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end @@ -335,7 +335,7 @@ describe Projects::BranchesController do project_id: project } - expect(response).to have_gitlab_http_status(303) + expect(response).to have_gitlab_http_status(:see_other) end end @@ -361,28 +361,28 @@ describe Projects::BranchesController do context "valid branch name, valid source" do let(:branch) { "feature" } - it { expect(response).to have_gitlab_http_status(200) } + it { expect(response).to have_gitlab_http_status(:ok) } it { expect(response.body).to be_blank } end context "valid branch name with unencoded slashes" do let(:branch) { "improve/awesome" } - it { expect(response).to have_gitlab_http_status(200) } + it { expect(response).to have_gitlab_http_status(:ok) } it { expect(response.body).to be_blank } end context "valid branch name with encoded slashes" do let(:branch) { "improve%2Fawesome" } - it { expect(response).to have_gitlab_http_status(200) } + it { expect(response).to have_gitlab_http_status(:ok) } it { expect(response.body).to be_blank } end context "invalid branch name, valid ref" do let(:branch) { "no-branch" } - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } it { expect(response.body).to be_blank } end end @@ -398,7 +398,7 @@ describe Projects::BranchesController do expect(json_response).to eql("message" => 'Branch was deleted') end - it { expect(response).to have_gitlab_http_status(200) } + it { expect(response).to have_gitlab_http_status(:ok) } end context 'valid branch name with unencoded slashes' do @@ -408,7 +408,7 @@ describe Projects::BranchesController do expect(json_response).to eql('message' => 'Branch was deleted') end - it { expect(response).to have_gitlab_http_status(200) } + it { expect(response).to have_gitlab_http_status(:ok) } end context "valid branch name with encoded slashes" do @@ -418,7 +418,7 @@ describe Projects::BranchesController do expect(json_response).to eql('message' => 'Branch was deleted') end - it { expect(response).to have_gitlab_http_status(200) } + it { expect(response).to have_gitlab_http_status(:ok) } end context 'invalid branch name, valid ref' do @@ -428,7 +428,7 @@ describe Projects::BranchesController do expect(json_response).to eql('message' => 'No such branch') end - it { expect(response).to have_gitlab_http_status(404) } + it { expect(response).to have_gitlab_http_status(:not_found) } end end @@ -478,7 +478,7 @@ describe Projects::BranchesController do it 'responds with status 404' do destroy_all_merged - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -519,7 +519,7 @@ describe Projects::BranchesController do state: 'all' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -537,7 +537,7 @@ describe Projects::BranchesController do state: 'all' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -594,7 +594,7 @@ describe Projects::BranchesController do names: %w[fix add-pdf-file branch-merged] } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to eq( "fix" => { "behind" => 29, "ahead" => 2 }, "branch-merged" => { "behind" => 1, "ahead" => 0 }, @@ -612,7 +612,7 @@ describe Projects::BranchesController do project_id: project } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response.count).to be > 1 end @@ -629,7 +629,7 @@ describe Projects::BranchesController do project_id: project } - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) expect(json_response['error']).to eq("Specify at least one and at most #{Kaminari.config.default_per_page} branch names") end @@ -642,7 +642,7 @@ describe Projects::BranchesController do names: %w[fix add-pdf-file branch-merged] } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response.count).to be > 1 end end diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb index 642932e2935..c6345a2153c 100644 --- a/spec/controllers/projects/clusters_controller_spec.rb +++ b/spec/controllers/projects/clusters_controller_spec.rb @@ -648,7 +648,7 @@ describe Projects::ClustersController do go(format: :json) cluster.reload - expect(response).to have_http_status(:no_content) + expect(response).to have_gitlab_http_status(:no_content) expect(cluster.enabled).to be_falsey expect(cluster.name).to eq('my-new-cluster-name') expect(cluster).not_to be_managed @@ -671,7 +671,7 @@ describe Projects::ClustersController do it "rejects changes" do go(format: :json) - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end end diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb index 95112cfeabe..c8ddd181d10 100644 --- a/spec/controllers/projects/commit_controller_spec.rb +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -179,7 +179,7 @@ describe Projects::CommitController do }) expect(response).not_to be_successful - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -236,7 +236,7 @@ describe Projects::CommitController do }) expect(response).not_to be_successful - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -322,7 +322,7 @@ describe Projects::CommitController do end it 'returns a 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -334,7 +334,7 @@ describe Projects::CommitController do end it 'returns a 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -345,7 +345,7 @@ describe Projects::CommitController do end it 'returns a 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -393,7 +393,7 @@ describe Projects::CommitController do end it 'returns a 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb index 9afc46c4be9..bd50811726a 100644 --- a/spec/controllers/projects/compare_controller_spec.rb +++ b/spec/controllers/projects/compare_controller_spec.rb @@ -108,7 +108,7 @@ describe Projects::CompareController do show_request expect(flash[:alert]).to eq('Invalid branch name') - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -120,7 +120,7 @@ describe Projects::CompareController do show_request expect(flash[:alert]).to eq('Invalid branch name') - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end @@ -164,7 +164,7 @@ describe Projects::CompareController do end it 'returns a 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -176,7 +176,7 @@ describe Projects::CompareController do end it 'returns a 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -187,7 +187,7 @@ describe Projects::CompareController do end it 'returns a 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -197,7 +197,7 @@ describe Projects::CompareController do end it 'returns a 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -301,7 +301,7 @@ describe Projects::CompareController do it 'returns only the commit with a signature' do signatures_request - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) signatures = json_response['signatures'] expect(signatures.size).to eq(1) @@ -318,7 +318,7 @@ describe Projects::CompareController do it 'returns a 404' do signatures_request - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -330,7 +330,7 @@ describe Projects::CompareController do it 'returns no signatures' do signatures_request - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['signatures']).to be_empty end end @@ -342,7 +342,7 @@ describe Projects::CompareController do it 'returns no signatures' do signatures_request - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['signatures']).to be_empty end end diff --git a/spec/controllers/projects/deploy_keys_controller_spec.rb b/spec/controllers/projects/deploy_keys_controller_spec.rb index 2c7c99eabf6..25e3e8e37a9 100644 --- a/spec/controllers/projects/deploy_keys_controller_spec.rb +++ b/spec/controllers/projects/deploy_keys_controller_spec.rb @@ -122,7 +122,7 @@ describe Projects::DeployKeysController do put :enable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } end.not_to change { DeployKeysProject.count } - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(new_user_session_path) end end @@ -137,7 +137,7 @@ describe Projects::DeployKeysController do put :enable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } end.not_to change { DeployKeysProject.count } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -152,14 +152,14 @@ describe Projects::DeployKeysController do end.to change { DeployKeysProject.count }.by(1) expect(DeployKeysProject.where(project_id: project.id, deploy_key_id: deploy_key.id).count).to eq(1) - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) end it 'returns 404' do put :enable, params: { id: 0, namespace_id: project.namespace, project_id: project } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -174,7 +174,7 @@ describe Projects::DeployKeysController do end.to change { DeployKeysProject.count }.by(1) expect(DeployKeysProject.where(project_id: project.id, deploy_key_id: deploy_key.id).count).to eq(1) - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) end end @@ -192,7 +192,7 @@ describe Projects::DeployKeysController do it 'redirects to login' do put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(new_user_session_path) expect(DeployKey.find(deploy_key.id)).to eq(deploy_key) end @@ -206,7 +206,7 @@ describe Projects::DeployKeysController do it 'returns 404' do put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(DeployKey.find(deploy_key.id)).to eq(deploy_key) end end @@ -215,7 +215,7 @@ describe Projects::DeployKeysController do it 'returns 302' do put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) expect { DeployKey.find(deploy_key.id) }.to raise_error(ActiveRecord::RecordNotFound) @@ -224,7 +224,7 @@ describe Projects::DeployKeysController do it 'returns 404' do put :disable, params: { id: 0, namespace_id: project.namespace, project_id: project } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -238,7 +238,7 @@ describe Projects::DeployKeysController do put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } end.to change { DeployKey.count }.by(-1) - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) expect { DeployKey.find(deploy_key.id) }.to raise_error(ActiveRecord::RecordNotFound) diff --git a/spec/controllers/projects/deployments_controller_spec.rb b/spec/controllers/projects/deployments_controller_spec.rb index b360319c6b1..bf80346c63a 100644 --- a/spec/controllers/projects/deployments_controller_spec.rb +++ b/spec/controllers/projects/deployments_controller_spec.rb @@ -61,7 +61,7 @@ describe Projects::DeploymentsController do it 'returns a empty response 204 resposne' do get :metrics, params: deployment_params(id: deployment.to_param) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect(response.body).to eq('') end end @@ -100,7 +100,7 @@ describe Projects::DeploymentsController do get :metrics, params: deployment_params(id: failed_deployment.to_param) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -129,7 +129,7 @@ describe Projects::DeploymentsController do it 'returns a empty response 204 response' do get :additional_metrics, params: deployment_params(id: deployment.to_param, format: :json) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect(response.body).to eq('') end end diff --git a/spec/controllers/projects/discussions_controller_spec.rb b/spec/controllers/projects/discussions_controller_spec.rb index d59f76c1b32..b2e4a3b7b0d 100644 --- a/spec/controllers/projects/discussions_controller_spec.rb +++ b/spec/controllers/projects/discussions_controller_spec.rb @@ -27,7 +27,7 @@ describe Projects::DiscussionsController do it 'returns 404' do get :show, params: request_params, session: { format: :json } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -39,7 +39,7 @@ describe Projects::DiscussionsController do it 'returns status 200' do get :show, params: request_params, session: { format: :json } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'returns status 404 if MR does not exists' do @@ -47,7 +47,7 @@ describe Projects::DiscussionsController do get :show, params: request_params, session: { format: :json } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -60,7 +60,7 @@ describe Projects::DiscussionsController do it 'returns status 200' do get :show, params: request_params, session: { format: :json } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -74,7 +74,7 @@ describe Projects::DiscussionsController do it "returns status 404" do post :resolve, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -91,7 +91,7 @@ describe Projects::DiscussionsController do it "returns status 404" do post :resolve, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -120,7 +120,7 @@ describe Projects::DiscussionsController do it "returns status 200" do post :resolve, params: request_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it "renders discussion with serializer" do @@ -157,7 +157,7 @@ describe Projects::DiscussionsController do it "returns status 404" do delete :unresolve, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -174,7 +174,7 @@ describe Projects::DiscussionsController do it "returns status 404" do delete :unresolve, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -188,7 +188,7 @@ describe Projects::DiscussionsController do it "returns status 200" do delete :unresolve, params: request_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end context "when vue_mr_discussions cookie is present" do diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index e7ce2cb0c2e..7f0f8e36564 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -179,7 +179,7 @@ describe Projects::EnvironmentsController do params[:id] = 12345 get :show, params: params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -197,7 +197,7 @@ describe Projects::EnvironmentsController do patch_params = environment_params.merge(environment: { external_url: 'https://git.gitlab.com' }) patch :update, params: patch_params - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -208,7 +208,7 @@ describe Projects::EnvironmentsController do patch :stop, params: environment_params(format: :json) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -221,7 +221,7 @@ describe Projects::EnvironmentsController do patch :stop, params: environment_params(format: :json) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to eq( { 'redirect_url' => project_job_url(project, action) }) @@ -235,7 +235,7 @@ describe Projects::EnvironmentsController do patch :stop, params: environment_params(format: :json) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to eq( { 'redirect_url' => project_environment_url(project, environment) }) @@ -278,7 +278,7 @@ describe Projects::EnvironmentsController do it 'responds with a status code 200' do get :terminal, params: environment_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'loads the terminals for the environment' do @@ -295,7 +295,7 @@ describe Projects::EnvironmentsController do it 'responds with a status code 404' do get :terminal, params: environment_params(id: 666) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -321,7 +321,7 @@ describe Projects::EnvironmentsController do get :terminal_websocket_authorize, params: environment_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.headers["Content-Type"]).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.body).to eq('{"workhorse":"response"}') end @@ -331,7 +331,7 @@ describe Projects::EnvironmentsController do it 'returns 404' do get :terminal_websocket_authorize, params: environment_params(id: 666) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -386,7 +386,7 @@ describe Projects::EnvironmentsController do get :metrics, params: environment_params(format: :json) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect(json_response).to eq({}) end end @@ -428,7 +428,7 @@ describe Projects::EnvironmentsController do it 'returns a metrics JSON document' do additional_metrics(window_params) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect(json_response).to eq({}) end end diff --git a/spec/controllers/projects/forks_controller_spec.rb b/spec/controllers/projects/forks_controller_spec.rb index e351fb2b1f6..e6a68459a84 100644 --- a/spec/controllers/projects/forks_controller_spec.rb +++ b/spec/controllers/projects/forks_controller_spec.rb @@ -23,7 +23,7 @@ describe Projects::ForksController do it 'returns with 404' do subject - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -167,7 +167,7 @@ describe Projects::ForksController do subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -205,7 +205,7 @@ describe Projects::ForksController do it 'responds with status 302' do subject - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_import_path(user.namespace, project)) end @@ -228,7 +228,7 @@ describe Projects::ForksController do it 'passes continue params to the redirect' do subject - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_import_path(user.namespace, project, continue: continue_params)) end end diff --git a/spec/controllers/projects/group_links_controller_spec.rb b/spec/controllers/projects/group_links_controller_spec.rb index d0cb3a74b78..c775b77ce1c 100644 --- a/spec/controllers/projects/group_links_controller_spec.rb +++ b/spec/controllers/projects/group_links_controller_spec.rb @@ -33,7 +33,7 @@ describe Projects::GroupLinksController do include_context 'link project to group' it 'responds with status 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/controllers/projects/hooks_controller_spec.rb b/spec/controllers/projects/hooks_controller_spec.rb index 137296b4f19..f50ef2d804c 100644 --- a/spec/controllers/projects/hooks_controller_spec.rb +++ b/spec/controllers/projects/hooks_controller_spec.rb @@ -42,7 +42,7 @@ describe Projects::HooksController do post :create, params: { namespace_id: project.namespace, project_id: project, hook: hook_params } - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(ProjectHook.all.size).to eq(1) expect(ProjectHook.first).to have_attributes(hook_params) end diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 945a56365c8..7cdb8989692 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -24,7 +24,7 @@ describe Projects::IssuesController do get :index, params: { namespace_id: project.namespace, project_id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -32,7 +32,7 @@ describe Projects::IssuesController do it 'renders the "index" template' do get :index, params: { namespace_id: project.namespace, project_id: project } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template(:index) end end @@ -51,14 +51,14 @@ describe Projects::IssuesController do get :index, params: { namespace_id: project.namespace, project_id: project } expect(response).to redirect_to(project_issues_path(new_project)) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end it 'redirects from an old issue correctly' do get :show, params: { namespace_id: project.namespace, project_id: project, id: issue } expect(response).to redirect_to(project_issue_path(new_project, issue)) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end @@ -78,7 +78,7 @@ describe Projects::IssuesController do it "returns index" do get :index, params: { namespace_id: project.namespace, project_id: project } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it "returns 301 if request path doesn't match project path" do @@ -92,7 +92,7 @@ describe Projects::IssuesController do project.save! get :index, params: { namespace_id: project.namespace, project_id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -118,7 +118,7 @@ describe Projects::IssuesController do get :index, params: params.merge(page: last_page + 1) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:issues).size).to eq(2) end end @@ -227,7 +227,7 @@ describe Projects::IssuesController do get :new, params: { namespace_id: project.namespace, project_id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -235,7 +235,7 @@ describe Projects::IssuesController do it 'renders the "new" template' do get :new, params: { namespace_id: project.namespace, project_id: project } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template(:new) end end @@ -330,7 +330,7 @@ describe Projects::IssuesController do [issue1, issue2, issue3].map(&:reload) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(issue1.relative_position) .to be_between(issue2.relative_position, issue3.relative_position) end @@ -340,7 +340,7 @@ describe Projects::IssuesController do it 'returns a unprocessable entity 422 response for invalid move ids' do reorder_issue(issue1, move_after_id: 99, move_before_id: 999) - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end it 'returns a not found 404 response for invalid issue id' do @@ -348,7 +348,7 @@ describe Projects::IssuesController do move_after_id: issue2.id, move_before_id: issue3.id) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'returns a unprocessable entity 422 response for issues not in group' do @@ -359,7 +359,7 @@ describe Projects::IssuesController do move_before_id: issue3.id, group_full_path: another_group.full_path) - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end end @@ -415,7 +415,7 @@ describe Projects::IssuesController do it 'updates the issue' do subject - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(issue.reload.title).to eq('New title') end @@ -443,7 +443,7 @@ describe Projects::IssuesController do it 'updates the issue' do subject - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(issue.reload.title).to eq('New title') end end @@ -458,7 +458,7 @@ describe Projects::IssuesController do it 'responds with 404' do subject - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -505,7 +505,7 @@ describe Projects::IssuesController do it 'returns 200' do go(id: issue.iid) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -749,7 +749,7 @@ describe Projects::IssuesController do it 'returns 200 status' do update_issue - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -769,7 +769,7 @@ describe Projects::IssuesController do it 'returns 200 status' do update_issue - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -785,7 +785,7 @@ describe Projects::IssuesController do end it 'returns 200 status' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'accepts an issue after recaptcha is verified' do @@ -1131,7 +1131,7 @@ describe Projects::IssuesController do it "rejects a developer to destroy an issue" do delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -1147,14 +1147,14 @@ describe Projects::IssuesController do it "deletes the issue" do delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid, destroy_confirm: true } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(controller).to set_flash[:notice].to(/The issue was successfully deleted\./) end it "deletes the issue" do delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid, destroy_confirm: true } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(controller).to set_flash[:notice].to(/The issue was successfully deleted\./) end @@ -1163,7 +1163,7 @@ describe Projects::IssuesController do delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(controller).to set_flash[:notice].to('Destroy confirmation not provided for issue') end @@ -1172,7 +1172,7 @@ describe Projects::IssuesController do delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid, format: 'json' } - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) expect(json_response).to eq({ 'errors' => 'Destroy confirmation not provided for issue' }) end @@ -1206,7 +1206,7 @@ describe Projects::IssuesController do subject end.to change { issue.award_emoji.count }.by(1) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it "removes the already awarded emoji" do @@ -1214,7 +1214,7 @@ describe Projects::IssuesController do expect { subject }.to change { AwardEmoji.count }.by(-1) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'marks Todos on the Issue as done' do @@ -1250,7 +1250,7 @@ describe Projects::IssuesController do create_merge_request - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'is not available for users who cannot create merge requests' do @@ -1258,7 +1258,7 @@ describe Projects::IssuesController do create_merge_request - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end context 'target_project_id is set' do diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index 53c40683a5b..65f57deff1b 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -1183,7 +1183,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do get_terminal_websocket(id: job.id) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.headers["Content-Type"]).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.body).to eq('{"workhorse":"response"}') end @@ -1193,7 +1193,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do it 'returns 404' do get_terminal_websocket(id: 1234) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/labels_controller_spec.rb b/spec/controllers/projects/labels_controller_spec.rb index aee017b211a..c6098f5934d 100644 --- a/spec/controllers/projects/labels_controller_spec.rb +++ b/spec/controllers/projects/labels_controller_spec.rb @@ -80,7 +80,7 @@ describe Projects::LabelsController do it 'creates labels' do post :generate, params: { namespace_id: personal_project.namespace.to_param, project_id: personal_project } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -88,7 +88,7 @@ describe Projects::LabelsController do it 'creates labels' do post :generate, params: { namespace_id: project.namespace.to_param, project_id: project } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end @@ -99,7 +99,7 @@ describe Projects::LabelsController do toggle_subscription(label) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'allows user to toggle subscription on group labels' do @@ -107,7 +107,7 @@ describe Projects::LabelsController do toggle_subscription(group_label) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end def toggle_subscription(label) @@ -123,7 +123,7 @@ describe Projects::LabelsController do it 'denies access' do post :promote, params: { namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -180,7 +180,7 @@ describe Projects::LabelsController do it 'does not redirect' do get :index, params: { namespace_id: project.namespace, project_id: project.to_param } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -231,13 +231,13 @@ describe Projects::LabelsController do it 'does not 404' do post :generate, params: { namespace_id: project.namespace, project_id: project } - expect(response).not_to have_gitlab_http_status(404) + expect(response).not_to have_gitlab_http_status(:not_found) end it 'does not redirect to the correct casing' do post :generate, params: { namespace_id: project.namespace, project_id: project } - expect(response).not_to have_gitlab_http_status(301) + expect(response).not_to have_gitlab_http_status(:moved_permanently) end end @@ -247,7 +247,7 @@ describe Projects::LabelsController do it 'returns not found' do post :generate, params: { namespace_id: project.namespace, project_id: project.to_param + 'old' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/mattermosts_controller_spec.rb b/spec/controllers/projects/mattermosts_controller_spec.rb index 64440ed585d..693176d0cfc 100644 --- a/spec/controllers/projects/mattermosts_controller_spec.rb +++ b/spec/controllers/projects/mattermosts_controller_spec.rb @@ -25,7 +25,7 @@ describe Projects::MattermostsController do project_id: project }) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index df2727d13cf..826c69ee5f0 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -113,7 +113,7 @@ describe Projects::MergeRequestsController do } expect(response).to redirect_to(project_merge_request_path(new_project, merge_request)) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end it 'redirects from an old merge request commits correctly' do @@ -125,7 +125,7 @@ describe Projects::MergeRequestsController do } expect(response).to redirect_to(commits_project_merge_request_path(new_project, merge_request)) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end @@ -229,7 +229,7 @@ describe Projects::MergeRequestsController do get_merge_requests(last_page) expect(assigns(:merge_requests).current_page).to eq(last_page) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'does not redirect to external sites when provided a host field' do @@ -306,7 +306,7 @@ describe Projects::MergeRequestsController do it 'responds with 404' do update_merge_request(title: 'New title') - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -381,7 +381,7 @@ describe Projects::MergeRequestsController do end it 'returns 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -615,7 +615,7 @@ describe Projects::MergeRequestsController do it "denies access to users unless they're admin or project owner" do delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end context "when the user is owner" do @@ -630,7 +630,7 @@ describe Projects::MergeRequestsController do it "deletes the merge request" do delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid, destroy_confirm: true } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(controller).to set_flash[:notice].to(/The merge request was successfully deleted\./) end @@ -639,7 +639,7 @@ describe Projects::MergeRequestsController do delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(controller).to set_flash[:notice].to('Destroy confirmation not provided for merge request') end @@ -648,7 +648,7 @@ describe Projects::MergeRequestsController do delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid, format: 'json' } - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) expect(json_response).to eq({ 'errors' => 'Destroy confirmation not provided for merge request' }) end @@ -842,7 +842,7 @@ describe Projects::MergeRequestsController do it 'responds with a 404' do subject - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to be_blank end end @@ -855,7 +855,7 @@ describe Projects::MergeRequestsController do it 'responds with a 404' do subject - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to be_blank end end @@ -898,7 +898,7 @@ describe Projects::MergeRequestsController do it 'returns exposed artifacts' do subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['status']).to eq('parsed') expect(json_response['data']).to eq([{ 'job_name' => 'test', @@ -951,7 +951,7 @@ describe Projects::MergeRequestsController do it 'returns no content' do subject - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect(response.body).to be_empty end end @@ -998,7 +998,7 @@ describe Projects::MergeRequestsController do it 'responds with a 404' do subject - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to be_blank end end @@ -1011,7 +1011,7 @@ describe Projects::MergeRequestsController do it 'responds with a 404' do subject - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to be_blank end end diff --git a/spec/controllers/projects/milestones_controller_spec.rb b/spec/controllers/projects/milestones_controller_spec.rb index a3f55c1eed0..3efdeda6171 100644 --- a/spec/controllers/projects/milestones_controller_spec.rb +++ b/spec/controllers/projects/milestones_controller_spec.rb @@ -30,14 +30,14 @@ describe Projects::MilestonesController do it 'shows milestone page' do view_milestone - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type).to eq 'text/html' end it 'returns milestone json' do view_milestone format: :json - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(response.content_type).to eq 'application/json' end end @@ -171,7 +171,7 @@ describe Projects::MilestonesController do it 'renders 404' do post :promote, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -190,7 +190,7 @@ describe Projects::MilestonesController do get :labels, params: { namespace_id: group.id, project_id: project.id, id: milestone.iid }, format: :json - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type).to eq 'application/json' expect(json_response['html']).not_to include(label.title) @@ -201,7 +201,7 @@ describe Projects::MilestonesController do get :labels, params: { namespace_id: group.id, project_id: project.id, id: milestone.iid }, format: :json - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type).to eq 'application/json' expect(json_response['html']).to include(label.title) @@ -240,7 +240,7 @@ describe Projects::MilestonesController do post :promote, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -263,7 +263,7 @@ describe Projects::MilestonesController do params = { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid, format: :json } get :participants, params: params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type).to eq 'application/json' expect(json_response['html']).to include(issue_assignee.name) end @@ -278,7 +278,7 @@ describe Projects::MilestonesController do params = { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid, format: :json } get :participants, params: params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type).to eq 'application/json' expect(json_response['html']).not_to include(issue_assignee.name) end diff --git a/spec/controllers/projects/mirrors_controller_spec.rb b/spec/controllers/projects/mirrors_controller_spec.rb index e14686970a1..4362febda5c 100644 --- a/spec/controllers/projects/mirrors_controller_spec.rb +++ b/spec/controllers/projects/mirrors_controller_spec.rb @@ -103,7 +103,7 @@ describe Projects::MirrorsController do it "returns an error with a 400 response for URL #{url.inspect}" do do_get(project, url) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response).to eq('message' => 'Invalid URL') end end @@ -115,7 +115,7 @@ describe Projects::MirrorsController do do_get(project) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end end @@ -125,7 +125,7 @@ describe Projects::MirrorsController do do_get(project) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response).to eq('message' => 'An error') end end @@ -139,7 +139,7 @@ describe Projects::MirrorsController do do_get(project) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to eq('known_hosts' => ssh_key, 'fingerprints' => [ssh_fp.stringify_keys], 'host_keys_changed' => true) end end diff --git a/spec/controllers/projects/notes_controller_spec.rb b/spec/controllers/projects/notes_controller_spec.rb index abc9e728cb3..7c00af7b945 100644 --- a/spec/controllers/projects/notes_controller_spec.rb +++ b/spec/controllers/projects/notes_controller_spec.rb @@ -152,7 +152,7 @@ describe Projects::NotesController do it 'renders 404' do get :index, params: params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -246,7 +246,7 @@ describe Projects::NotesController do context 'the project is publically available' do context 'for HTML' do it "returns status 302" do - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -254,7 +254,7 @@ describe Projects::NotesController do let(:extra_request_params) { { format: :json } } it "returns status 200 for json" do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -265,7 +265,7 @@ describe Projects::NotesController do let(:extra_request_params) { { format: :json } } it "returns status 422 for json" do - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end end @@ -278,7 +278,7 @@ describe Projects::NotesController do let(:extra_request_params) { extra } it "returns status 404" do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -296,7 +296,7 @@ describe Projects::NotesController do it "returns status 302 (redirect)" do create! - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -306,7 +306,7 @@ describe Projects::NotesController do it "returns status 200" do create! - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -316,7 +316,7 @@ describe Projects::NotesController do it 'returns discussion JSON when the return_discussion param is set' do create! - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to have_key 'discussion' expect(json_response.dig('discussion', 'notes', 0, 'note')).to eq(request_params[:note][:note]) end @@ -330,7 +330,7 @@ describe Projects::NotesController do it 'includes changes in commands_changes ' do create! - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['commands_changes']).to include('emoji_award', 'time_estimate', 'spend_time') expect(json_response['commands_changes']).not_to include('target_project', 'title') end @@ -349,7 +349,7 @@ describe Projects::NotesController do it 'does not include changes in commands_changes' do create! - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['commands_changes']).not_to include('target_project', 'title') end end @@ -363,7 +363,7 @@ describe Projects::NotesController do it "prevents a non-member user from creating a note on one of the project's merge requests" do create! - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end context 'when the user is a team member' do @@ -424,7 +424,7 @@ describe Projects::NotesController do it 'returns an error to the user' do create! - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -436,7 +436,7 @@ describe Projects::NotesController do it "prevents a non-member user from creating a note on one of the project's merge requests" do create! - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end context 'when the user is a team member' do @@ -467,7 +467,7 @@ describe Projects::NotesController do it "returns status 302 for html" do create! - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -531,7 +531,7 @@ describe Projects::NotesController do it 'returns a 404', :sidekiq_might_not_need_inline do create! - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -540,7 +540,7 @@ describe Projects::NotesController do it 'returns a 404', :sidekiq_might_not_need_inline do create! - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -550,7 +550,7 @@ describe Projects::NotesController do it 'is successful' do create! - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end it 'creates the note' do @@ -574,7 +574,7 @@ describe Projects::NotesController do expect { post :create, params: request_params }.to change { issue.notes.count }.by(1) .and change { locked_issue.notes.count }.by(0) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -588,7 +588,7 @@ describe Projects::NotesController do request_params[:target_id] = 9999 post :create, params: request_params.merge(format: :json) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -600,13 +600,13 @@ describe Projects::NotesController do it 'returns 302 status for html' do post :create, params: request_params - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end it 'returns 200 status for json' do post :create, params: request_params.merge(format: :json) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'creates a new note' do @@ -618,7 +618,7 @@ describe Projects::NotesController do it 'returns 404 status' do post :create, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'does not create a new note' do @@ -671,7 +671,7 @@ describe Projects::NotesController do } } expect { put :update, params: request_params }.not_to change { note.reload.note } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -695,7 +695,7 @@ describe Projects::NotesController do it "returns status 200 for html" do delete :destroy, params: request_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it "deletes the note" do @@ -712,7 +712,7 @@ describe Projects::NotesController do it "returns status 404" do delete :destroy, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -732,7 +732,7 @@ describe Projects::NotesController do subject end.to change { note.award_emoji.count }.by(1) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it "removes the already awarded emoji" do @@ -740,7 +740,7 @@ describe Projects::NotesController do expect { subject }.to change { AwardEmoji.count }.by(-1) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'marks Todos on the Noteable as done' do @@ -766,7 +766,7 @@ describe Projects::NotesController do it "returns status 404" do post :resolve, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -783,7 +783,7 @@ describe Projects::NotesController do it "returns status 404" do post :resolve, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -812,7 +812,7 @@ describe Projects::NotesController do it "returns status 200" do post :resolve, params: request_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -829,7 +829,7 @@ describe Projects::NotesController do it "returns status 404" do delete :unresolve, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -846,7 +846,7 @@ describe Projects::NotesController do it "returns status 404" do delete :unresolve, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -860,7 +860,7 @@ describe Projects::NotesController do it "returns status 200" do delete :unresolve, params: request_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/controllers/projects/pages_controller_spec.rb b/spec/controllers/projects/pages_controller_spec.rb index c07619465bf..102c0b6b048 100644 --- a/spec/controllers/projects/pages_controller_spec.rb +++ b/spec/controllers/projects/pages_controller_spec.rb @@ -23,7 +23,7 @@ describe Projects::PagesController do it 'returns 200 status' do get :show, params: request_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end context 'when the project is in a subgroup' do @@ -33,7 +33,7 @@ describe Projects::PagesController do it 'returns a 200 status code' do get :show, params: request_params - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -42,7 +42,7 @@ describe Projects::PagesController do it 'returns 302 status' do delete :destroy, params: request_params - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end context 'when user is developer' do @@ -53,7 +53,7 @@ describe Projects::PagesController do it 'returns 404 status' do delete :destroy, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -67,7 +67,7 @@ describe Projects::PagesController do it 'returns 404 status' do get :show, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -75,7 +75,7 @@ describe Projects::PagesController do it 'returns 404 status' do delete :destroy, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/pages_domains_controller_spec.rb b/spec/controllers/projects/pages_domains_controller_spec.rb index ef6a193e677..ef5e831d26c 100644 --- a/spec/controllers/projects/pages_domains_controller_spec.rb +++ b/spec/controllers/projects/pages_domains_controller_spec.rb @@ -35,7 +35,7 @@ describe Projects::PagesDomainsController do it "displays to the 'show' page" do make_request - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('show') end @@ -47,7 +47,7 @@ describe Projects::PagesDomainsController do it 'renders 404 page' do make_request - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -56,7 +56,7 @@ describe Projects::PagesDomainsController do it "displays the 'new' page" do get(:new, params: request_params) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('new') end end @@ -78,7 +78,7 @@ describe Projects::PagesDomainsController do it "displays the 'show' page" do get(:show, params: request_params.merge(id: pages_domain.domain)) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('show') end end @@ -177,7 +177,7 @@ describe Projects::PagesDomainsController do it 'returns a 404 response for an unknown domain' do post :verify, params: request_params.merge(id: 'unknown-domain') - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -250,7 +250,7 @@ describe Projects::PagesDomainsController do it 'returns 404 status' do get(:show, params: request_params.merge(id: pages_domain.domain)) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -258,7 +258,7 @@ describe Projects::PagesDomainsController do it 'returns 404 status' do get :new, params: request_params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -266,7 +266,7 @@ describe Projects::PagesDomainsController do it "returns 404 status" do post(:create, params: request_params.merge(pages_domain: pages_domain_params)) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -274,7 +274,7 @@ describe Projects::PagesDomainsController do it "deletes the pages domain" do delete(:destroy, params: request_params.merge(id: pages_domain.domain)) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/pipeline_schedules_controller_spec.rb b/spec/controllers/projects/pipeline_schedules_controller_spec.rb index 60b802f1cab..72b282429e9 100644 --- a/spec/controllers/projects/pipeline_schedules_controller_spec.rb +++ b/spec/controllers/projects/pipeline_schedules_controller_spec.rb @@ -396,7 +396,7 @@ describe Projects::PipelineSchedulesController do post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -407,7 +407,7 @@ describe Projects::PipelineSchedulesController do post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id } expect(flash[:notice]).to start_with 'Successfully scheduled a pipeline to run' - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end it 'prevents users from scheduling the same pipeline repeatedly' do @@ -417,7 +417,7 @@ describe Projects::PipelineSchedulesController do expect(flash.to_a.size).to eq(2) expect(flash[:alert]).to eq _('You cannot play this scheduled pipeline at the moment. Please wait a minute.') - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -430,7 +430,7 @@ describe Projects::PipelineSchedulesController do post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: protected_schedule.id } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -460,7 +460,7 @@ describe Projects::PipelineSchedulesController do delete :destroy, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id } end.to change { project.pipeline_schedules.count }.by(-1) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index 4cc5b3cba7c..74d7e056737 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -703,7 +703,7 @@ describe Projects::PipelinesController do it 'shows latest pipeline for the default project branch' do get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: nil } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:pipeline)).to have_attributes(id: pipeline_master.id) end end @@ -716,7 +716,7 @@ describe Projects::PipelinesController do 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 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:pipeline)).to have_attributes(id: pipeline_secondary.id) end @@ -728,7 +728,7 @@ describe Projects::PipelinesController do it 'shows the provided ref with the last sha/pipeline combo' do get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: branch_secondary.name } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:pipeline)).to have_attributes(id: pipeline_secondary.id) end end @@ -737,7 +737,7 @@ describe Projects::PipelinesController do it 'renders a 404 if no pipeline is found for the ref' do get :show, params: { namespace_id: project.namespace, project_id: project, ref: 'no-branch' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -754,7 +754,7 @@ describe Projects::PipelinesController do it 'deletes pipeline and redirects' do delete_pipeline - expect(response).to have_gitlab_http_status(303) + expect(response).to have_gitlab_http_status(:see_other) expect(Ci::Build.exists?(build.id)).to be_falsy expect(Ci::Pipeline.exists?(pipeline.id)).to be_falsy @@ -766,7 +766,7 @@ describe Projects::PipelinesController do it 'fails to delete pipeline' do delete_pipeline - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -775,7 +775,7 @@ describe Projects::PipelinesController do it 'fails to delete pipeline' do delete_pipeline - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end diff --git a/spec/controllers/projects/pipelines_settings_controller_spec.rb b/spec/controllers/projects/pipelines_settings_controller_spec.rb index 16a43f62bd5..789b2104d3c 100644 --- a/spec/controllers/projects/pipelines_settings_controller_spec.rb +++ b/spec/controllers/projects/pipelines_settings_controller_spec.rb @@ -17,7 +17,7 @@ describe Projects::PipelinesSettingsController do it 'redirects with 302 status code' do get :show, params: { namespace_id: project.namespace, project_id: project } - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end diff --git a/spec/controllers/projects/project_members_controller_spec.rb b/spec/controllers/projects/project_members_controller_spec.rb index 0df19aa6e44..09420cc8556 100644 --- a/spec/controllers/projects/project_members_controller_spec.rb +++ b/spec/controllers/projects/project_members_controller_spec.rb @@ -11,7 +11,7 @@ describe Projects::ProjectMembersController do it 'has the project_members address with a 200 status code' do get :index, params: { namespace_id: project.namespace, project_id: project } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end context 'when project belongs to group' do @@ -64,7 +64,7 @@ describe Projects::ProjectMembersController do access_level: Gitlab::Access::GUEST } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(project.users).not_to include project_user end end @@ -145,7 +145,7 @@ describe Projects::ProjectMembersController do id: 42 } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -162,7 +162,7 @@ describe Projects::ProjectMembersController do id: member } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(project.members).to include member end end @@ -211,7 +211,7 @@ describe Projects::ProjectMembersController do project_id: project } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -246,7 +246,7 @@ describe Projects::ProjectMembersController do project_id: project } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -305,7 +305,7 @@ describe Projects::ProjectMembersController do id: 42 } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -322,7 +322,7 @@ describe Projects::ProjectMembersController do id: member } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(project.members).not_to include member end end diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb index aef8ef1d487..8cb48dca095 100644 --- a/spec/controllers/projects/raw_controller_spec.rb +++ b/spec/controllers/projects/raw_controller_spec.rb @@ -23,7 +23,7 @@ describe Projects::RawController do it 'delivers ASCII file' do subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8') expect(response.header['Content-Disposition']).to eq('inline') expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true" @@ -37,7 +37,7 @@ describe Projects::RawController do it 'leaves image content disposition' do subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.header['Content-Disposition']).to eq('inline') expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true" expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:') @@ -63,7 +63,7 @@ describe Projects::RawController do .to change { Gitlab::GitalyClient.get_request_count }.by(0) expect(response.body).to eq(_('You cannot access the raw file. Please wait a minute.')) - expect(response).to have_gitlab_http_status(429) + expect(response).to have_gitlab_http_status(:too_many_requests) end it 'logs the event on auth.log' do @@ -94,7 +94,7 @@ describe Projects::RawController do request.headers['X-Gitlab-External-Storage-Token'] = token execute_raw_requests(requests: 6, project: project, file_path: file_path) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -113,7 +113,7 @@ describe Projects::RawController do execute_raw_requests(requests: 3, project: project, file_path: modified_path) expect(response.body).to eq(_('You cannot access the raw file. Please wait a minute.')) - expect(response).to have_gitlab_http_status(429) + expect(response).to have_gitlab_http_status(:too_many_requests) end end @@ -125,7 +125,7 @@ describe Projects::RawController do it 'does not prevent from accessing the raw file' do execute_raw_requests(requests: 10, project: project, file_path: file_path) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -141,14 +141,14 @@ describe Projects::RawController do execute_raw_requests(requests: 6, project: project, file_path: file_path) expect(response.body).to eq(_('You cannot access the raw file. Please wait a minute.')) - expect(response).to have_gitlab_http_status(429) + expect(response).to have_gitlab_http_status(:too_many_requests) # Accessing upcase version of readme file_path = "#{commit_sha}/README.md" execute_raw_requests(requests: 1, project: project, file_path: file_path) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -166,7 +166,7 @@ describe Projects::RawController do it 'redirects to sign in page' do execute_raw_requests(requests: 1, project: project, file_path: file_path) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response.location).to end_with('/users/sign_in') end end @@ -176,7 +176,7 @@ describe Projects::RawController do it 'calls the action normally' do execute_raw_requests(requests: 1, project: project, file_path: file_path, token: user.static_object_token) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -184,7 +184,7 @@ describe Projects::RawController do it 'redirects to sign in page' do execute_raw_requests(requests: 1, project: project, file_path: file_path, token: 'foobar') - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response.location).to end_with('/users/sign_in') end end @@ -196,7 +196,7 @@ describe Projects::RawController do request.headers['X-Gitlab-Static-Object-Token'] = user.static_object_token execute_raw_requests(requests: 1, project: project, file_path: file_path) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -205,7 +205,7 @@ describe Projects::RawController do request.headers['X-Gitlab-Static-Object-Token'] = 'foobar' execute_raw_requests(requests: 1, project: project, file_path: file_path) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response.location).to end_with('/users/sign_in') end end diff --git a/spec/controllers/projects/repositories_controller_spec.rb b/spec/controllers/projects/repositories_controller_spec.rb index 084644484c5..aeb053fe9f6 100644 --- a/spec/controllers/projects/repositories_controller_spec.rb +++ b/spec/controllers/projects/repositories_controller_spec.rb @@ -45,7 +45,7 @@ describe Projects::RepositoriesController do it 'handles legacy queries with the ref specified as ref in params' do get :archive, params: { namespace_id: project.namespace, project_id: project, ref: 'feature' }, format: 'zip' - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:ref)).to eq('feature') expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:") end @@ -53,7 +53,7 @@ describe Projects::RepositoriesController do it 'handles legacy queries with the ref specified as id in params' do get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'feature' }, format: 'zip' - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:ref)).to eq('feature') expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:") end @@ -61,7 +61,7 @@ describe Projects::RepositoriesController do it 'prioritizes the id param over the ref param when both are specified' do get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'feature', ref: 'feature_conflict' }, format: 'zip' - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:ref)).to eq('feature') expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:") end @@ -74,7 +74,7 @@ describe Projects::RepositoriesController do it "renders Not Found" do get :archive, params: { namespace_id: project.namespace, project_id: project, id: "master" }, format: "zip" - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -82,7 +82,7 @@ describe Projects::RepositoriesController do it 'sets appropriate caching headers' do get_archive - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.header['ETag']).to be_present expect(response.header['Cache-Control']).to include('max-age=60, private') end @@ -93,7 +93,7 @@ describe Projects::RepositoriesController do it 'sets appropriate caching headers' do get_archive - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.header['ETag']).to be_present expect(response.header['Cache-Control']).to include('max-age=60, public') end @@ -103,7 +103,7 @@ describe Projects::RepositoriesController do it 'max-age is set to 3600 in Cache-Control header' do get_archive('ddd0f15ae83993f5cb66a927a28673882e99100b') - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.header['Cache-Control']).to include('max-age=3600') end end @@ -116,7 +116,7 @@ describe Projects::RepositoriesController do request.headers['If-None-Match'] = response.headers['ETag'] get_archive - expect(response).to have_gitlab_http_status(304) + expect(response).to have_gitlab_http_status(:not_modified) end end @@ -137,7 +137,7 @@ describe Projects::RepositoriesController do it 'redirects to sign in page' do get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master' }, format: 'zip' - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -146,7 +146,7 @@ describe Projects::RepositoriesController do it 'calls the action normally' do get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master', token: user.static_object_token }, format: 'zip' - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -154,7 +154,7 @@ describe Projects::RepositoriesController do it 'redirects to sign in page' do get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master', token: 'foobar' }, format: 'zip' - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end @@ -165,7 +165,7 @@ describe Projects::RepositoriesController do request.headers['X-Gitlab-Static-Object-Token'] = user.static_object_token get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master' }, format: 'zip' - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -174,7 +174,7 @@ describe Projects::RepositoriesController do request.headers['X-Gitlab-Static-Object-Token'] = 'foobar' get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master' }, format: 'zip' - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end end diff --git a/spec/controllers/projects/runners_controller_spec.rb b/spec/controllers/projects/runners_controller_spec.rb index 279b4f360c5..1893180fe9b 100644 --- a/spec/controllers/projects/runners_controller_spec.rb +++ b/spec/controllers/projects/runners_controller_spec.rb @@ -30,7 +30,7 @@ describe Projects::RunnersController do runner.reload - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(runner.description).to eq(new_desc) end end @@ -39,7 +39,7 @@ describe Projects::RunnersController do it 'destroys the runner' do delete :destroy, params: params - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(Ci::Runner.find_by(id: runner.id)).to be_nil end end @@ -54,7 +54,7 @@ describe Projects::RunnersController do runner.reload - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(runner.active).to eq(true) end end @@ -69,7 +69,7 @@ describe Projects::RunnersController do runner.reload - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(runner.active).to eq(false) end end diff --git a/spec/controllers/projects/snippets_controller_spec.rb b/spec/controllers/projects/snippets_controller_spec.rb index ee145a62b57..8233c0a0adb 100644 --- a/spec/controllers/projects/snippets_controller_spec.rb +++ b/spec/controllers/projects/snippets_controller_spec.rb @@ -35,7 +35,7 @@ describe Projects::SnippetsController do get :index, params: { namespace_id: project.namespace, project_id: project } expect(assigns(:snippets)).not_to include(project_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -48,7 +48,7 @@ describe Projects::SnippetsController do get :index, params: { namespace_id: project.namespace, project_id: project } expect(assigns(:snippets)).to include(project_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -61,7 +61,7 @@ describe Projects::SnippetsController do get :index, params: { namespace_id: project.namespace, project_id: project } expect(assigns(:snippets)).to include(project_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -318,7 +318,7 @@ describe Projects::SnippetsController do it 'responds with status 404' do get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -331,7 +331,7 @@ describe Projects::SnippetsController do get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param } expect(assigns(:snippet)).to eq(project_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -344,7 +344,7 @@ describe Projects::SnippetsController do get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param } expect(assigns(:snippet)).to eq(project_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -354,7 +354,7 @@ describe Projects::SnippetsController do it 'responds with status 404' do get action, params: { namespace_id: project.namespace, project_id: project, id: 42 } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -366,7 +366,7 @@ describe Projects::SnippetsController do it 'responds with status 404' do get action, params: { namespace_id: project.namespace, project_id: project, id: 42 } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -386,7 +386,7 @@ describe Projects::SnippetsController do let(:snippet_permission) { :private } it 'responds with status 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -395,7 +395,7 @@ describe Projects::SnippetsController do it 'responds with status 200' do expect(assigns(:snippet)).to eq(project_snippet) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -407,7 +407,7 @@ describe Projects::SnippetsController do it 'responds with status 404' do expect(assigns(:snippet)).to eq(project_snippet) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -501,7 +501,7 @@ describe Projects::SnippetsController do it 'responds with status 404' do delete :destroy, params: params - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/stages_controller_spec.rb b/spec/controllers/projects/stages_controller_spec.rb index a91e3523fd7..c38e3d2544f 100644 --- a/spec/controllers/projects/stages_controller_spec.rb +++ b/spec/controllers/projects/stages_controller_spec.rb @@ -25,7 +25,7 @@ describe Projects::StagesController do it 'returns not authorized' do play_manual_stage! - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/controllers/projects/templates_controller_spec.rb b/spec/controllers/projects/templates_controller_spec.rb index 07b8a36fefc..b4b04878181 100644 --- a/spec/controllers/projects/templates_controller_spec.rb +++ b/spec/controllers/projects/templates_controller_spec.rb @@ -110,7 +110,7 @@ describe Projects::TemplatesController do it 'returns the template names' do get(:names, params: { namespace_id: project.namespace, template_type: template_type, project_id: project }, format: :json) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response.size).to eq(1) expect(json_response[0]['name']).to eq(expected_template_name) end @@ -121,7 +121,7 @@ describe Projects::TemplatesController do get(:names, params: { namespace_id: project.namespace, template_type: template_type, project_id: project }, format: :json) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/controllers/projects/todos_controller_spec.rb b/spec/controllers/projects/todos_controller_spec.rb index c12019fed5e..b7d40d2a452 100644 --- a/spec/controllers/projects/todos_controller_spec.rb +++ b/spec/controllers/projects/todos_controller_spec.rb @@ -22,7 +22,7 @@ describe Projects::TodosController do it "doesn't create todo" do expect { post_create }.not_to change { user.todos.count } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb index 5df05a06f00..96838383540 100644 --- a/spec/controllers/projects/tree_controller_spec.rb +++ b/spec/controllers/projects/tree_controller_spec.rb @@ -85,7 +85,7 @@ describe Projects::TreeController do context "valid SHA commit ID with path" do let(:id) { '6d39438/.gitignore' } - it { expect(response).to have_gitlab_http_status(302) } + it { expect(response).to have_gitlab_http_status(:found) } end end diff --git a/spec/controllers/projects/uploads_controller_spec.rb b/spec/controllers/projects/uploads_controller_spec.rb index a70669e86a6..bb5415ee62c 100644 --- a/spec/controllers/projects/uploads_controller_spec.rb +++ b/spec/controllers/projects/uploads_controller_spec.rb @@ -49,7 +49,7 @@ describe Projects::UploadsController do it "responds with status internal_server_error" do post_authorize - expect(response).to have_gitlab_http_status(500) + expect(response).to have_gitlab_http_status(:internal_server_error) expect(response.body).to eq(_('Error uploading file')) end end diff --git a/spec/controllers/projects/usage_ping_controller_spec.rb b/spec/controllers/projects/usage_ping_controller_spec.rb index a9abbff160d..284db93d7a8 100644 --- a/spec/controllers/projects/usage_ping_controller_spec.rb +++ b/spec/controllers/projects/usage_ping_controller_spec.rb @@ -24,7 +24,7 @@ describe Projects::UsagePingController do it 'returns 302' do subject - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end @@ -32,7 +32,7 @@ describe Projects::UsagePingController do it 'returns 404' do subject - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -57,7 +57,7 @@ describe Projects::UsagePingController do it 'returns 404' do subject - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/wikis_controller_spec.rb b/spec/controllers/projects/wikis_controller_spec.rb index bfa555aab4c..6dd050af277 100644 --- a/spec/controllers/projects/wikis_controller_spec.rb +++ b/spec/controllers/projects/wikis_controller_spec.rb @@ -25,7 +25,7 @@ describe Projects::WikisController do it 'redirects to #show and appends a `random_title` param' do subject - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(Rails.application.routes.recognize_path(response.redirect_url)).to include( controller: 'projects/wikis', action: 'show' @@ -70,7 +70,7 @@ describe Projects::WikisController do end it "returns status #{expected_status}" do - expect(response).to have_http_status(expected_status) + expect(response).to have_gitlab_http_status(expected_status) end end @@ -103,7 +103,7 @@ describe Projects::WikisController do subject - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:page).title).to eq(wiki_title) end @@ -113,7 +113,7 @@ describe Projects::WikisController do subject - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(flash[:notice]).to eq(_('The content of this page is not encoded in UTF-8. Edits can only be made via the Git repository.')) end end @@ -204,7 +204,7 @@ describe Projects::WikisController do it 'shows the edit page' do subject - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.body).to include(s_('Wiki|Edit Page')) end end diff --git a/spec/controllers/sent_notifications_controller_spec.rb b/spec/controllers/sent_notifications_controller_spec.rb index 4dd4f49dcf1..b4b867f5c66 100644 --- a/spec/controllers/sent_notifications_controller_spec.rb +++ b/spec/controllers/sent_notifications_controller_spec.rb @@ -30,6 +30,16 @@ describe SentNotificationsController do let(:target_project) { project } describe 'GET unsubscribe' do + shared_examples 'returns 404' do + it 'does not set the flash message' do + expect(controller).not_to set_flash[:notice] + end + + it 'returns a 404' do + expect(response).to have_gitlab_http_status(:not_found) + end + end + context 'when the user is not logged in' do context 'when the force param is passed' do before do @@ -156,6 +166,16 @@ describe SentNotificationsController do end end end + + context 'when the noteable associated to the notification has been deleted' do + before do + sent_notification.noteable.destroy! + + get(:unsubscribe, params: { id: sent_notification.reply_key }) + end + + it_behaves_like 'returns 404' + end end context 'when the user is logged in' do @@ -168,17 +188,7 @@ describe SentNotificationsController do get(:unsubscribe, params: { id: sent_notification.reply_key.reverse }) end - it 'does not unsubscribe the user' do - expect(issue.subscribed?(user, project)).to be_truthy - end - - it 'does not set the flash message' do - expect(controller).not_to set_flash[:notice] - end - - it 'returns a 404' do - expect(response).to have_gitlab_http_status(:not_found) - end + it_behaves_like 'returns 404' end context 'when the force param is passed' do @@ -254,6 +264,16 @@ describe SentNotificationsController do end end end + + context 'when the noteable associated to the notification has been deleted' do + before do + sent_notification.noteable.destroy! + + get(:unsubscribe, params: { id: sent_notification.reply_key }) + end + + it_behaves_like 'returns 404' + end end end end |