summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-06 18:08:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-06 18:08:54 +0000
commit0d6fa033121a9bef708b8f2de186c4034c61d4a3 (patch)
tree851d65a09efbffa114c9a273e590d55cfb1436ab /spec
parent0eb3d2f799ce4f4de87fb9fc6fd98e592323bc89 (diff)
downloadgitlab-ce-0d6fa033121a9bef708b8f2de186c4034c61d4a3.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/admin/applications_controller_spec.rb2
-rw-r--r--spec/controllers/admin/clusters/applications_controller_spec.rb16
-rw-r--r--spec/controllers/admin/clusters_controller_spec.rb4
-rw-r--r--spec/controllers/admin/gitaly_servers_controller_spec.rb2
-rw-r--r--spec/controllers/admin/hooks_controller_spec.rb2
-rw-r--r--spec/controllers/admin/impersonations_controller_spec.rb6
-rw-r--r--spec/controllers/admin/projects_controller_spec.rb4
-rw-r--r--spec/controllers/admin/requests_profiles_controller_spec.rb4
-rw-r--r--spec/controllers/admin/runners_controller_spec.rb18
-rw-r--r--spec/controllers/admin/services_controller_spec.rb6
-rw-r--r--spec/controllers/admin/sessions_controller_spec.rb2
-rw-r--r--spec/controllers/admin/spam_logs_controller_spec.rb8
-rw-r--r--spec/controllers/admin/users_controller_spec.rb6
-rw-r--r--spec/controllers/boards/issues_controller_spec.rb36
-rw-r--r--spec/controllers/boards/lists_controller_spec.rb40
-rw-r--r--spec/controllers/concerns/controller_with_cross_project_access_check_spec.rb18
-rw-r--r--spec/controllers/concerns/enforces_admin_authentication_spec.rb8
-rw-r--r--spec/controllers/concerns/project_unauthorized_spec.rb6
-rw-r--r--spec/controllers/concerns/routable_actions_spec.rb14
-rw-r--r--spec/controllers/concerns/static_object_external_storage_spec.rb6
-rw-r--r--spec/controllers/dashboard/groups_controller_spec.rb4
-rw-r--r--spec/controllers/dashboard/milestones_controller_spec.rb6
-rw-r--r--spec/controllers/dashboard/projects_controller_spec.rb2
-rw-r--r--spec/controllers/dashboard/todos_controller_spec.rb14
-rw-r--r--spec/controllers/google_api/authorizations_controller_spec.rb2
-rw-r--r--spec/controllers/import/bitbucket_controller_spec.rb6
-rw-r--r--spec/controllers/import/bitbucket_server_controller_spec.rb18
-rw-r--r--spec/controllers/import/github_controller_spec.rb4
-rw-r--r--spec/controllers/import/gitlab_controller_spec.rb6
-rw-r--r--spec/controllers/import/gitlab_projects_controller_spec.rb6
-rw-r--r--spec/controllers/import/phabricator_controller_spec.rb6
-rw-r--r--spec/controllers/oauth/applications_controller_spec.rb8
-rw-r--r--spec/controllers/oauth/authorizations_controller_spec.rb8
-rw-r--r--spec/controllers/profiles/accounts_controller_spec.rb6
-rw-r--r--spec/controllers/snippets/notes_controller_spec.rb30
-rw-r--r--spec/controllers/user_callouts_controller_spec.rb4
-rw-r--r--spec/factories/prometheus_alert.rb17
-rw-r--r--spec/features/issues/user_creates_branch_and_merge_request_spec.rb2
-rw-r--r--spec/features/merge_request/user_posts_diff_notes_spec.rb2
-rw-r--r--spec/features/merge_request/user_resolves_conflicts_spec.rb4
-rw-r--r--spec/features/projects/graph_spec.rb2
-rw-r--r--spec/fixtures/lib/gitlab/import_export/complex/project.json4
-rw-r--r--spec/fixtures/lib/gitlab/import_export/group_exports/complex/group.json4
-rw-r--r--spec/graphql/types/permission_types/project_spec.rb3
-rw-r--r--spec/helpers/markup_helper_spec.rb2
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb99
-rw-r--r--spec/lib/gitlab/import_export/group_tree_restorer_spec.rb8
-rw-r--r--spec/lib/gitlab/import_export/project_tree_restorer_spec.rb4
-rw-r--r--spec/lib/gitlab/runtime_spec.rb128
-rw-r--r--spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb16
-rw-r--r--spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb2
-rw-r--r--spec/migrations/schedule_update_existing_subgroup_to_match_visibility_level_of_parent_spec.rb2
-rw-r--r--spec/models/ci/bridge_spec.rb231
-rw-r--r--spec/models/prometheus_alert_spec.rb103
-rw-r--r--spec/models/push_event_spec.rb4
-rw-r--r--spec/models/user_callout_spec.rb33
-rw-r--r--spec/models/user_spec.rb34
-rw-r--r--spec/support/controllers/project_import_rate_limiter_shared_examples.rb2
-rw-r--r--spec/support/helpers/api_helpers.rb2
-rw-r--r--spec/support/helpers/rack_attack_spec_helpers.rb2
-rw-r--r--spec/tasks/gitlab/seed/group_seed_rake_spec.rb2
61 files changed, 676 insertions, 374 deletions
diff --git a/spec/controllers/admin/applications_controller_spec.rb b/spec/controllers/admin/applications_controller_spec.rb
index 63b28b2d993..163a2033b58 100644
--- a/spec/controllers/admin/applications_controller_spec.rb
+++ b/spec/controllers/admin/applications_controller_spec.rb
@@ -16,7 +16,7 @@ describe Admin::ApplicationsController do
it 'renders the application form' do
get :index
- expect(response).to have_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
diff --git a/spec/controllers/admin/clusters/applications_controller_spec.rb b/spec/controllers/admin/clusters/applications_controller_spec.rb
index 9d6edcd80c0..44693505c4f 100644
--- a/spec/controllers/admin/clusters/applications_controller_spec.rb
+++ b/spec/controllers/admin/clusters/applications_controller_spec.rb
@@ -36,7 +36,7 @@ describe Admin::Clusters::ApplicationsController do
expect(ClusterInstallAppWorker).to receive(:perform_async).with(application, anything).once
expect { subject }.to change { current_application.count }
- expect(response).to have_http_status(:no_content)
+ expect(response).to have_gitlab_http_status(:no_content)
expect(cluster.application_helm).to be_scheduled
end
@@ -47,7 +47,7 @@ describe Admin::Clusters::ApplicationsController do
it 'return 404' do
expect { subject }.not_to change { current_application.count }
- expect(response).to have_http_status(:not_found)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -55,7 +55,7 @@ describe Admin::Clusters::ApplicationsController do
let(:application) { 'unkwnown-app' }
it 'return 404' do
- is_expected.to have_http_status(:not_found)
+ is_expected.to have_gitlab_http_status(:not_found)
end
end
@@ -65,7 +65,7 @@ describe Admin::Clusters::ApplicationsController do
end
it 'returns 400' do
- is_expected.to have_http_status(:bad_request)
+ is_expected.to have_gitlab_http_status(:bad_request)
end
end
end
@@ -99,7 +99,7 @@ describe Admin::Clusters::ApplicationsController do
it "schedules an application update" do
expect(ClusterPatchAppWorker).to receive(:perform_async).with(application.name, anything).once
- is_expected.to have_http_status(:no_content)
+ is_expected.to have_gitlab_http_status(:no_content)
expect(cluster.application_cert_manager).to be_scheduled
end
@@ -110,13 +110,13 @@ describe Admin::Clusters::ApplicationsController do
cluster.destroy!
end
- it { is_expected.to have_http_status(:not_found) }
+ it { is_expected.to have_gitlab_http_status(:not_found) }
end
context 'when application is unknown' do
let(:application_name) { 'unkwnown-app' }
- it { is_expected.to have_http_status(:not_found) }
+ it { is_expected.to have_gitlab_http_status(:not_found) }
end
context 'when application is already scheduled' do
@@ -124,7 +124,7 @@ describe Admin::Clusters::ApplicationsController do
application.make_scheduled!
end
- it { is_expected.to have_http_status(:bad_request) }
+ it { is_expected.to have_gitlab_http_status(:bad_request) }
end
end
diff --git a/spec/controllers/admin/clusters_controller_spec.rb b/spec/controllers/admin/clusters_controller_spec.rb
index f27519496df..1f5c33d8022 100644
--- a/spec/controllers/admin/clusters_controller_spec.rb
+++ b/spec/controllers/admin/clusters_controller_spec.rb
@@ -567,7 +567,7 @@ describe Admin::ClustersController do
put_update(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
@@ -587,7 +587,7 @@ describe Admin::ClustersController do
it 'rejects changes' do
put_update(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/admin/gitaly_servers_controller_spec.rb b/spec/controllers/admin/gitaly_servers_controller_spec.rb
index c75418a9ad4..db94ea06f59 100644
--- a/spec/controllers/admin/gitaly_servers_controller_spec.rb
+++ b/spec/controllers/admin/gitaly_servers_controller_spec.rb
@@ -11,7 +11,7 @@ describe Admin::GitalyServersController do
it 'shows the gitaly servers page' do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
diff --git a/spec/controllers/admin/hooks_controller_spec.rb b/spec/controllers/admin/hooks_controller_spec.rb
index 3c3a16ef9d5..9973ef93cd9 100644
--- a/spec/controllers/admin/hooks_controller_spec.rb
+++ b/spec/controllers/admin/hooks_controller_spec.rb
@@ -24,7 +24,7 @@ describe Admin::HooksController do
post :create, params: { hook: hook_params }
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(SystemHook.all.size).to eq(1)
expect(SystemHook.first).to have_attributes(hook_params)
end
diff --git a/spec/controllers/admin/impersonations_controller_spec.rb b/spec/controllers/admin/impersonations_controller_spec.rb
index b44797b23e5..fa3923bca8c 100644
--- a/spec/controllers/admin/impersonations_controller_spec.rb
+++ b/spec/controllers/admin/impersonations_controller_spec.rb
@@ -24,7 +24,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it "doesn't sign us in" do
@@ -48,7 +48,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it "doesn't sign us in as the impersonator" do
@@ -67,7 +67,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it "doesn't sign us in as the impersonator" do
diff --git a/spec/controllers/admin/projects_controller_spec.rb b/spec/controllers/admin/projects_controller_spec.rb
index 6b996798b74..2d783dab621 100644
--- a/spec/controllers/admin/projects_controller_spec.rb
+++ b/spec/controllers/admin/projects_controller_spec.rb
@@ -29,7 +29,7 @@ describe Admin::ProjectsController do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.body).not_to match(pending_delete_project.name)
expect(response.body).to match(project.name)
end
@@ -61,7 +61,7 @@ describe Admin::ProjectsController do
it 'renders show page' do
get :show, params: { namespace_id: project.namespace.path, id: project.path }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to match(project.name)
end
end
diff --git a/spec/controllers/admin/requests_profiles_controller_spec.rb b/spec/controllers/admin/requests_profiles_controller_spec.rb
index 853767199bc..13123c8e486 100644
--- a/spec/controllers/admin/requests_profiles_controller_spec.rb
+++ b/spec/controllers/admin/requests_profiles_controller_spec.rb
@@ -36,7 +36,7 @@ describe Admin::RequestsProfilesController do
it 'renders the data' do
subject
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to eq(sample_data)
end
end
@@ -54,7 +54,7 @@ describe Admin::RequestsProfilesController do
it 'renders the data' do
subject
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to eq(sample_data)
end
end
diff --git a/spec/controllers/admin/runners_controller_spec.rb b/spec/controllers/admin/runners_controller_spec.rb
index a1d346d088d..7582006df36 100644
--- a/spec/controllers/admin/runners_controller_spec.rb
+++ b/spec/controllers/admin/runners_controller_spec.rb
@@ -15,7 +15,7 @@ describe Admin::RunnersController do
it 'lists all runners' do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'avoids N+1 queries', :request_store do
@@ -29,7 +29,7 @@ describe Admin::RunnersController do
# We also need to add 1 because it takes 2 queries to preload tags
expect { get :index }.not_to exceed_query_limit(control_count + 6)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to have_content('tag1')
expect(response.body).to have_content('tag2')
end
@@ -49,13 +49,13 @@ describe Admin::RunnersController do
it 'shows a particular runner' do
get :show, params: { id: runner.id }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'shows 404 for unknown runner' do
get :show, params: { id: 0 }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'avoids N+1 queries', :request_store do
@@ -70,7 +70,7 @@ describe Admin::RunnersController do
# needs_new_sso_session permission
expect { get :show, params: { id: runner.id } }.not_to exceed_query_limit(control_count + 1)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -84,7 +84,7 @@ describe Admin::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
@@ -93,7 +93,7 @@ describe Admin::RunnersController do
it 'destroys the runner' do
delete :destroy, params: { id: runner.id }
- 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
@@ -108,7 +108,7 @@ describe Admin::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
@@ -123,7 +123,7 @@ describe Admin::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/admin/services_controller_spec.rb b/spec/controllers/admin/services_controller_spec.rb
index 1c518dab11e..44233776865 100644
--- a/spec/controllers/admin/services_controller_spec.rb
+++ b/spec/controllers/admin/services_controller_spec.rb
@@ -22,7 +22,7 @@ describe Admin::ServicesController do
it 'successfully displays the template' do
get :edit, params: { id: service.id }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
@@ -48,7 +48,7 @@ describe Admin::ServicesController do
put :update, params: { id: service.id, service: { active: true } }
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
it 'does not call the propagation worker when service is not active' do
@@ -56,7 +56,7 @@ describe Admin::ServicesController do
put :update, params: { id: service.id, service: { properties: {} } }
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
end
end
diff --git a/spec/controllers/admin/sessions_controller_spec.rb b/spec/controllers/admin/sessions_controller_spec.rb
index be996aee1d2..4bab6b51102 100644
--- a/spec/controllers/admin/sessions_controller_spec.rb
+++ b/spec/controllers/admin/sessions_controller_spec.rb
@@ -124,7 +124,7 @@ describe Admin::SessionsController, :do_not_mock_admin_mode do
it 'shows error page' do
post :destroy
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(controller.current_user_mode.admin_mode?).to be(false)
end
end
diff --git a/spec/controllers/admin/spam_logs_controller_spec.rb b/spec/controllers/admin/spam_logs_controller_spec.rb
index 15fb57d5add..6716bb8b399 100644
--- a/spec/controllers/admin/spam_logs_controller_spec.rb
+++ b/spec/controllers/admin/spam_logs_controller_spec.rb
@@ -16,7 +16,7 @@ describe Admin::SpamLogsController do
it 'lists all spam logs' do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -24,14 +24,14 @@ describe Admin::SpamLogsController do
it 'removes only the spam log when removing log' do
expect { delete :destroy, params: { id: first_spam.id } }.to change { SpamLog.count }.by(-1)
expect(User.find(user.id)).to be_truthy
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'removes user and his spam logs when removing the user', :sidekiq_might_not_need_inline do
delete :destroy, params: { id: first_spam.id, remove_user: true }
expect(flash[:notice]).to eq "User #{user.username} was successfully removed."
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(SpamLog.count).to eq(0)
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
@@ -46,7 +46,7 @@ describe Admin::SpamLogsController do
it 'submits the log as ham' do
post :mark_as_ham, params: { id: first_spam.id }
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(SpamLog.find(first_spam.id).submitted_as_ham).to be_truthy
end
end
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb
index ebdfbe14dec..2661f8c1519 100644
--- a/spec/controllers/admin/users_controller_spec.rb
+++ b/spec/controllers/admin/users_controller_spec.rb
@@ -47,7 +47,7 @@ describe Admin::UsersController do
it 'deletes user and ghosts their contributions' do
delete :destroy, params: { id: user.username }, format: :json
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(User.exists?(user.id)).to be_falsy
expect(issue.reload.author).to be_ghost
end
@@ -55,7 +55,7 @@ describe Admin::UsersController do
it 'deletes the user and their contributions when hard delete is specified' do
delete :destroy, params: { id: user.username, hard_delete: true }, format: :json
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(User.exists?(user.id)).to be_falsy
expect(Issue.exists?(issue.id)).to be_falsy
end
@@ -399,7 +399,7 @@ describe Admin::UsersController do
it "shows error page" do
post :impersonate, params: { id: user.username }
- 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/boards/issues_controller_spec.rb b/spec/controllers/boards/issues_controller_spec.rb
index d54f7ad33cf..605fff60c31 100644
--- a/spec/controllers/boards/issues_controller_spec.rb
+++ b/spec/controllers/boards/issues_controller_spec.rb
@@ -28,7 +28,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
list_issues user: user, board: 999, list: list2
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -106,7 +106,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
list_issues user: user, board: board, list: 999
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
@@ -132,7 +132,7 @@ describe Boards::IssuesController do
it 'returns a forbidden 403 response' do
list_issues user: unauth_user, board: board, list: list2
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -148,7 +148,7 @@ describe Boards::IssuesController do
list_issues(user: user, board: group_board)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it 'is successful for project boards' do
@@ -156,7 +156,7 @@ describe Boards::IssuesController do
list_issues(user: user, board: project_board)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -215,7 +215,7 @@ describe Boards::IssuesController do
expect(response).to have_gitlab_http_status(expected_status)
list_issues user: requesting_user, board: board, list: list2
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('entities/issue_boards')
@@ -391,7 +391,7 @@ describe Boards::IssuesController do
it 'returns a successful 200 response' do
create_issue user: user, board: board, list: list1, title: 'New issue'
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'returns the created issue' do
@@ -406,7 +406,7 @@ describe Boards::IssuesController do
it 'returns an unprocessable entity 422 response' do
create_issue user: user, board: board, list: list1, title: nil
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
@@ -416,7 +416,7 @@ describe Boards::IssuesController do
create_issue user: user, board: board, list: list, title: 'New issue'
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -424,7 +424,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
create_issue user: user, board: 999, list: list1, title: 'New issue'
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -432,7 +432,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
create_issue user: user, board: board, list: 999, title: 'New issue'
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
@@ -443,7 +443,7 @@ describe Boards::IssuesController do
open_list = board.lists.create(list_type: :backlog)
create_issue user: guest, board: board, list: open_list, title: 'New issue'
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -451,7 +451,7 @@ describe Boards::IssuesController do
it 'returns a forbidden 403 response' do
create_issue user: guest, board: board, list: list1, title: 'New issue'
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
@@ -475,7 +475,7 @@ describe Boards::IssuesController do
it 'returns a successful 200 response' do
move user: user, board: board, issue: issue, from_list_id: list1.id, to_list_id: list2.id
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'moves issue to the desired list' do
@@ -489,19 +489,19 @@ describe Boards::IssuesController do
it 'returns a unprocessable entity 422 response for invalid lists' do
move user: user, board: board, issue: issue, from_list_id: nil, to_list_id: nil
- 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 board id' do
move user: user, board: 999, issue: issue, from_list_id: list1.id, to_list_id: list2.id
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns a not found 404 response for invalid issue id' do
move user: user, board: board, issue: double(id: 999), from_list_id: list1.id, to_list_id: list2.id
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -515,7 +515,7 @@ describe Boards::IssuesController do
it 'returns a forbidden 403 response' do
move user: guest, board: board, issue: issue, from_list_id: list1.id, to_list_id: list2.id
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
diff --git a/spec/controllers/boards/lists_controller_spec.rb b/spec/controllers/boards/lists_controller_spec.rb
index bc46d02556b..3886388bcf4 100644
--- a/spec/controllers/boards/lists_controller_spec.rb
+++ b/spec/controllers/boards/lists_controller_spec.rb
@@ -21,7 +21,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
read_board_list user: user, board: board
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'application/json'
end
@@ -50,7 +50,7 @@ describe Boards::ListsController do
it 'returns a forbidden 403 response' do
read_board_list user: unauth_user, board: board
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -73,7 +73,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
create_board_list user: user, board: board, label_id: label.id
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'returns the created list' do
@@ -88,7 +88,7 @@ describe Boards::ListsController do
it 'returns a not found 404 response' do
create_board_list user: user, board: board, label_id: nil
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -98,7 +98,7 @@ describe Boards::ListsController do
create_board_list user: user, board: board, label_id: label.id
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
@@ -109,7 +109,7 @@ describe Boards::ListsController do
create_board_list user: guest, board: board, label_id: label.id
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -134,7 +134,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
move user: user, board: board, list: planning, position: 1
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'moves the list to the desired position' do
@@ -148,7 +148,7 @@ describe Boards::ListsController do
it 'returns an unprocessable entity 422 response' do
move user: user, board: board, list: planning, position: 6
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
@@ -156,7 +156,7 @@ describe Boards::ListsController do
it 'returns a not found 404 response' do
move user: user, board: board, list: 999, position: 1
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -164,7 +164,7 @@ describe Boards::ListsController do
it 'returns a 422 unprocessable entity response' do
move user: guest, board: board, list: planning, position: 6
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
@@ -173,14 +173,14 @@ describe Boards::ListsController do
save_setting user: user, board: board, list: planning, setting: { collapsed: true }
expect(planning.preferences_for(user).collapsed).to eq(true)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'saves not collapsed preference for user' do
save_setting user: user, board: board, list: planning, setting: { collapsed: false }
expect(planning.preferences_for(user).collapsed).to eq(false)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -191,14 +191,14 @@ describe Boards::ListsController do
save_setting user: user, board: board, list: closed, setting: { collapsed: true }
expect(closed.preferences_for(user).collapsed).to eq(true)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'saves not collapsed preference for user' do
save_setting user: user, board: board, list: closed, setting: { collapsed: false }
expect(closed.preferences_for(user).collapsed).to eq(false)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -236,7 +236,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
remove_board_list user: user, board: board, list: planning
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'removes list from board' do
@@ -248,7 +248,7 @@ describe Boards::ListsController do
it 'returns a not found 404 response' do
remove_board_list user: user, board: board, list: 999
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -256,7 +256,7 @@ describe Boards::ListsController do
it 'returns a forbidden 403 response' do
remove_board_list user: guest, board: board, list: planning
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -278,7 +278,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
generate_default_lists user: user, board: board
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'returns the defaults lists' do
@@ -294,7 +294,7 @@ describe Boards::ListsController do
generate_default_lists user: user, board: board
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
@@ -302,7 +302,7 @@ describe Boards::ListsController do
it 'returns a forbidden 403 response' do
generate_default_lists user: guest, board: board
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
diff --git a/spec/controllers/concerns/controller_with_cross_project_access_check_spec.rb b/spec/controllers/concerns/controller_with_cross_project_access_check_spec.rb
index e47f1650b1f..85989ea3e92 100644
--- a/spec/controllers/concerns/controller_with_cross_project_access_check_spec.rb
+++ b/spec/controllers/concerns/controller_with_cross_project_access_check_spec.rb
@@ -51,7 +51,7 @@ describe ControllerWithCrossProjectAccessCheck do
get :index
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to match(/#{message}/)
end
@@ -60,7 +60,7 @@ describe ControllerWithCrossProjectAccessCheck do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'is skipped when the `unless` condition returns true' do
@@ -68,13 +68,13 @@ describe ControllerWithCrossProjectAccessCheck do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'correctly renders an action that does not require cross project access' do
get :show, params: { id: 'nothing' }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -113,7 +113,7 @@ describe ControllerWithCrossProjectAccessCheck do
it 'renders a success when the check is skipped' do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'is executed when the `if` condition returns false' do
@@ -121,7 +121,7 @@ describe ControllerWithCrossProjectAccessCheck do
get :index
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it 'is executed when the `unless` condition returns true' do
@@ -129,19 +129,19 @@ describe ControllerWithCrossProjectAccessCheck do
get :index
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it 'does not skip the check on an action that is not skipped' do
get :show, params: { id: 'hello' }
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it 'does not skip the check on an action that was not defined to skip' do
get :edit, params: { id: 'hello' }
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
diff --git a/spec/controllers/concerns/enforces_admin_authentication_spec.rb b/spec/controllers/concerns/enforces_admin_authentication_spec.rb
index 019a21e8cf0..a8494543558 100644
--- a/spec/controllers/concerns/enforces_admin_authentication_spec.rb
+++ b/spec/controllers/concerns/enforces_admin_authentication_spec.rb
@@ -39,7 +39,7 @@ describe EnforcesAdminAuthentication, :do_not_mock_admin_mode do
it 'renders ok' do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
@@ -48,7 +48,7 @@ describe EnforcesAdminAuthentication, :do_not_mock_admin_mode do
it 'renders a 404' do
get :index
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'does not set admin mode' do
@@ -75,7 +75,7 @@ describe EnforcesAdminAuthentication, :do_not_mock_admin_mode do
let(:user) { create(:admin) }
it 'allows direct access to page' do
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'does not set admin mode' do
@@ -85,7 +85,7 @@ describe EnforcesAdminAuthentication, :do_not_mock_admin_mode do
context 'as a user' do
it 'renders a 404' do
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'does not set admin mode' do
diff --git a/spec/controllers/concerns/project_unauthorized_spec.rb b/spec/controllers/concerns/project_unauthorized_spec.rb
index 5834b1ef37f..9b40660811e 100644
--- a/spec/controllers/concerns/project_unauthorized_spec.rb
+++ b/spec/controllers/concerns/project_unauthorized_spec.rb
@@ -30,7 +30,7 @@ describe ProjectUnauthorized do
get :show, params: { namespace_id: project.namespace.to_param, id: project.to_param }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'renders a 403 when the service denies access to the project' do
@@ -38,7 +38,7 @@ describe ProjectUnauthorized do
get :show, params: { namespace_id: project.namespace.to_param, id: project.to_param }
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to match("External authorization denied access to this project")
end
@@ -47,7 +47,7 @@ describe ProjectUnauthorized do
get :show, params: { namespace_id: other_project.namespace.to_param, id: other_project.to_param }
- 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/concerns/routable_actions_spec.rb b/spec/controllers/concerns/routable_actions_spec.rb
index a11f4d2a154..80c67022219 100644
--- a/spec/controllers/concerns/routable_actions_spec.rb
+++ b/spec/controllers/concerns/routable_actions_spec.rb
@@ -47,14 +47,14 @@ describe RoutableActions do
it 'allows access' do
get_routable(routable)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
it 'prevents access when not authorized' do
get_routable(routable)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -75,14 +75,14 @@ describe RoutableActions do
it 'allows access' do
get_routable(routable)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
it 'prevents access when not authorized' do
get_routable(routable)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -92,7 +92,7 @@ describe RoutableActions do
it 'allows access when authorized' do
get_routable(routable)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'prevents access when unauthorized' do
@@ -100,7 +100,7 @@ describe RoutableActions do
get_routable(user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
@@ -111,7 +111,7 @@ describe RoutableActions do
get_routable(routable)
- 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/concerns/static_object_external_storage_spec.rb b/spec/controllers/concerns/static_object_external_storage_spec.rb
index ddd1a95427e..d3ece587ef7 100644
--- a/spec/controllers/concerns/static_object_external_storage_spec.rb
+++ b/spec/controllers/concerns/static_object_external_storage_spec.rb
@@ -27,7 +27,7 @@ describe StaticObjectExternalStorage do
do_request
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -75,7 +75,7 @@ describe StaticObjectExternalStorage do
request.headers['X-Gitlab-External-Storage-Token'] = 'letmein'
do_request
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -84,7 +84,7 @@ describe StaticObjectExternalStorage do
request.headers['X-Gitlab-External-Storage-Token'] = 'donotletmein'
do_request
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
diff --git a/spec/controllers/dashboard/groups_controller_spec.rb b/spec/controllers/dashboard/groups_controller_spec.rb
index 20a0951423b..b615bcc1e6b 100644
--- a/spec/controllers/dashboard/groups_controller_spec.rb
+++ b/spec/controllers/dashboard/groups_controller_spec.rb
@@ -40,7 +40,7 @@ describe Dashboard::GroupsController do
it 'renders only groups the user is a member of when searching hierarchy correctly' do
get :index, params: { filter: 'chef' }, format: :json
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
all_groups = [top_level_result, top_level_a, sub_level_result_a]
expect(assigns(:groups)).to contain_exactly(*all_groups)
end
@@ -51,7 +51,7 @@ describe Dashboard::GroupsController do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
diff --git a/spec/controllers/dashboard/milestones_controller_spec.rb b/spec/controllers/dashboard/milestones_controller_spec.rb
index 67939aa4e6a..f4b04ad6dee 100644
--- a/spec/controllers/dashboard/milestones_controller_spec.rb
+++ b/spec/controllers/dashboard/milestones_controller_spec.rb
@@ -40,7 +40,7 @@ describe Dashboard::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)
end
end
@@ -55,7 +55,7 @@ describe Dashboard::MilestonesController do
it 'returns group and project milestones to which the user belongs' do
get :index, format: :json
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(2)
expect(json_response.map { |i| i["name"] }).to match_array([group_milestone.name, project_milestone.name])
expect(json_response.map { |i| i["group_name"] }.compact).to match_array(group.name)
@@ -64,7 +64,7 @@ describe Dashboard::MilestonesController do
it 'returns closed group and project milestones to which the user belongs' do
get :index, params: { state: 'closed' }, format: :json
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(2)
expect(json_response.map { |i| i["name"] }).to match_array([closed_group_milestone.name, closed_project_milestone.name])
expect(json_response.map { |i| i["group_name"] }.compact).to match_array(group.name)
diff --git a/spec/controllers/dashboard/projects_controller_spec.rb b/spec/controllers/dashboard/projects_controller_spec.rb
index 8b95c9f2496..d013093c376 100644
--- a/spec/controllers/dashboard/projects_controller_spec.rb
+++ b/spec/controllers/dashboard/projects_controller_spec.rb
@@ -23,7 +23,7 @@ describe Dashboard::ProjectsController do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
diff --git a/spec/controllers/dashboard/todos_controller_spec.rb b/spec/controllers/dashboard/todos_controller_spec.rb
index 4ce445fe41a..0823afe410d 100644
--- a/spec/controllers/dashboard/todos_controller_spec.rb
+++ b/spec/controllers/dashboard/todos_controller_spec.rb
@@ -20,19 +20,19 @@ describe Dashboard::TodosController do
get :index, params: { project_id: unauthorized_project.id }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'renders 404 when given project does not exists' do
get :index, params: { project_id: 999 }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'renders 200 when filtering for "any project" todos' do
get :index, params: { project_id: '' }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'renders 200 when user has access on given project' do
@@ -40,7 +40,7 @@ describe Dashboard::TodosController do
get :index, params: { project_id: authorized_project.id }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -78,7 +78,7 @@ describe Dashboard::TodosController do
get :index, params: { group_id: unauthorized_group.id }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -130,7 +130,7 @@ describe Dashboard::TodosController do
patch :restore, params: { id: todo.id }
expect(todo.reload).to be_pending
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ "count" => 1, "done_count" => 0 })
end
end
@@ -144,7 +144,7 @@ describe Dashboard::TodosController do
todos.each do |todo|
expect(todo.reload).to be_pending
end
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ 'count' => 2, 'done_count' => 0 })
end
end
diff --git a/spec/controllers/google_api/authorizations_controller_spec.rb b/spec/controllers/google_api/authorizations_controller_spec.rb
index 4d200140f16..58bda2bd4e8 100644
--- a/spec/controllers/google_api/authorizations_controller_spec.rb
+++ b/spec/controllers/google_api/authorizations_controller_spec.rb
@@ -23,7 +23,7 @@ describe GoogleApi::AuthorizationsController do
subject
expect(session[GoogleApi::CloudPlatform::Client.session_key_for_token]).to be_nil
- expect(response).to have_http_status(:not_found)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
diff --git a/spec/controllers/import/bitbucket_controller_spec.rb b/spec/controllers/import/bitbucket_controller_spec.rb
index 74ffcc3aeef..ab4f6d5054c 100644
--- a/spec/controllers/import/bitbucket_controller_spec.rb
+++ b/spec/controllers/import/bitbucket_controller_spec.rb
@@ -123,7 +123,7 @@ describe Import::BitbucketController do
post :create, format: :json
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'returns 422 response when the project could not be imported' do
@@ -133,7 +133,7 @@ describe Import::BitbucketController do
post :create, format: :json
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it_behaves_like 'project import rate limiter'
@@ -330,7 +330,7 @@ describe Import::BitbucketController do
post :create, params: { target_namespace: other_namespace.name }, format: :json
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
end
diff --git a/spec/controllers/import/bitbucket_server_controller_spec.rb b/spec/controllers/import/bitbucket_server_controller_spec.rb
index a84f8368198..3a347368884 100644
--- a/spec/controllers/import/bitbucket_server_controller_spec.rb
+++ b/spec/controllers/import/bitbucket_server_controller_spec.rb
@@ -48,7 +48,7 @@ describe Import::BitbucketServerController do
post :create, params: { project: project_key, repository: repo_slug }, format: :json
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
context 'with project key with tildes' do
@@ -61,20 +61,20 @@ describe Import::BitbucketServerController do
post :create, params: { project: project_key, repository: repo_slug, format: :json }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
it 'returns an error when an invalid project key is used' do
post :create, params: { project: 'some&project' }
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it 'returns an error when an invalid repository slug is used' do
post :create, params: { project: 'some-project', repository: 'try*this' }
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it 'returns an error when the project cannot be found' do
@@ -82,7 +82,7 @@ describe Import::BitbucketServerController do
post :create, params: { project: project_key, repository: repo_slug }, format: :json
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it 'returns an error when the project cannot be saved' do
@@ -92,7 +92,7 @@ describe Import::BitbucketServerController do
post :create, params: { project: project_key, repository: repo_slug }, format: :json
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it "returns an error when the server can't be contacted" do
@@ -100,7 +100,7 @@ describe Import::BitbucketServerController do
post :create, params: { project: project_key, repository: repo_slug }, format: :json
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it_behaves_like 'project import rate limiter'
@@ -118,7 +118,7 @@ describe Import::BitbucketServerController do
expect(session[:bitbucket_server_username]).to be_nil
expect(session[:bitbucket_server_personal_access_token]).to be_nil
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(status_import_bitbucket_server_path)
end
@@ -128,7 +128,7 @@ describe Import::BitbucketServerController do
expect(session[:bitbucket_server_url]).to eq(url)
expect(session[:bitbucket_server_username]).to eq(username)
expect(session[:bitbucket_server_personal_access_token]).to eq(token)
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(status_import_bitbucket_server_path)
end
end
diff --git a/spec/controllers/import/github_controller_spec.rb b/spec/controllers/import/github_controller_spec.rb
index 54fbe624cb7..40ea0bb3a44 100644
--- a/spec/controllers/import/github_controller_spec.rb
+++ b/spec/controllers/import/github_controller_spec.rb
@@ -22,7 +22,7 @@ describe Import::GithubController do
get :new
- expect(response).to have_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
it "prompts for an access token if GitHub not configured" do
@@ -31,7 +31,7 @@ describe Import::GithubController do
get :new
- expect(response).to have_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
context 'when importing a CI/CD project' do
diff --git a/spec/controllers/import/gitlab_controller_spec.rb b/spec/controllers/import/gitlab_controller_spec.rb
index 495ea62456c..96a8eb99d5c 100644
--- a/spec/controllers/import/gitlab_controller_spec.rb
+++ b/spec/controllers/import/gitlab_controller_spec.rb
@@ -86,7 +86,7 @@ describe Import::GitlabController do
post :create, format: :json
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'returns 422 response when the project could not be imported' do
@@ -96,7 +96,7 @@ describe Import::GitlabController do
post :create, format: :json
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
context "when the repository owner is the GitLab.com user" do
@@ -279,7 +279,7 @@ describe Import::GitlabController do
post :create, params: { target_namespace: other_namespace.name }, format: :json
- expect(response).to have_gitlab_http_status(422)
+ expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
diff --git a/spec/controllers/import/gitlab_projects_controller_spec.rb b/spec/controllers/import/gitlab_projects_controller_spec.rb
index 285291c53fa..a9aaefda0f6 100644
--- a/spec/controllers/import/gitlab_projects_controller_spec.rb
+++ b/spec/controllers/import/gitlab_projects_controller_spec.rb
@@ -17,14 +17,14 @@ describe Import::GitlabProjectsController do
post :create, params: { namespace_id: namespace.id, path: '/test', file: file }
expect(flash[:alert]).to start_with('Project could not be imported')
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
it 'redirects with an error when a relative path is used' do
post :create, params: { namespace_id: namespace.id, path: '../test', file: file }
expect(flash[:alert]).to start_with('Project could not be imported')
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
end
@@ -33,7 +33,7 @@ describe Import::GitlabProjectsController do
post :create, params: { namespace_id: namespace.id, path: 'test', file: file }
expect(flash[:notice]).to include('is being imported')
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
end
diff --git a/spec/controllers/import/phabricator_controller_spec.rb b/spec/controllers/import/phabricator_controller_spec.rb
index 62a719cfb5b..d29a06efbb5 100644
--- a/spec/controllers/import/phabricator_controller_spec.rb
+++ b/spec/controllers/import/phabricator_controller_spec.rb
@@ -18,7 +18,7 @@ describe Import::PhabricatorController do
stub_application_setting(import_sources: [])
end
- it { is_expected.to have_gitlab_http_status(404) }
+ it { is_expected.to have_gitlab_http_status(:not_found) }
end
context 'when the feature is disabled' do
@@ -27,7 +27,7 @@ describe Import::PhabricatorController do
stub_application_setting(import_sources: ['phabricator'])
end
- it { is_expected.to have_gitlab_http_status(404) }
+ it { is_expected.to have_gitlab_http_status(:not_found) }
end
context 'when the import is available' do
@@ -36,7 +36,7 @@ describe Import::PhabricatorController do
stub_application_setting(import_sources: ['phabricator'])
end
- it { is_expected.to have_gitlab_http_status(200) }
+ it { is_expected.to have_gitlab_http_status(:ok) }
end
end
diff --git a/spec/controllers/oauth/applications_controller_spec.rb b/spec/controllers/oauth/applications_controller_spec.rb
index 270a2fcc1d6..5f1f6af3999 100644
--- a/spec/controllers/oauth/applications_controller_spec.rb
+++ b/spec/controllers/oauth/applications_controller_spec.rb
@@ -14,7 +14,7 @@ describe Oauth::ApplicationsController do
it 'shows list of applications' do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'redirects back to profile page if OAuth applications are disabled' do
@@ -22,7 +22,7 @@ describe Oauth::ApplicationsController do
get :index
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -30,7 +30,7 @@ describe Oauth::ApplicationsController do
it 'creates an application' do
post :create, params: oauth_params
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(oauth_application_path(Doorkeeper::Application.last))
end
@@ -39,7 +39,7 @@ describe Oauth::ApplicationsController do
post :create, params: oauth_params
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(profile_path)
end
diff --git a/spec/controllers/oauth/authorizations_controller_spec.rb b/spec/controllers/oauth/authorizations_controller_spec.rb
index 41f7684051e..1b4bebd9707 100644
--- a/spec/controllers/oauth/authorizations_controller_spec.rb
+++ b/spec/controllers/oauth/authorizations_controller_spec.rb
@@ -23,7 +23,7 @@ describe Oauth::AuthorizationsController do
it 'returns 200 code and renders error view' do
get :new
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('doorkeeper/authorizations/error')
end
end
@@ -34,7 +34,7 @@ describe Oauth::AuthorizationsController do
it 'returns 200 code and renders view' do
get :new, params: params
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('doorkeeper/authorizations/new')
end
@@ -45,7 +45,7 @@ describe Oauth::AuthorizationsController do
get :new, params: params
expect(request.session['user_return_to']).to be_nil
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
context 'when there is already an access token for the application' do
@@ -62,7 +62,7 @@ describe Oauth::AuthorizationsController do
get :new, params: params
expect(request.session['user_return_to']).to be_nil
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
end
end
diff --git a/spec/controllers/profiles/accounts_controller_spec.rb b/spec/controllers/profiles/accounts_controller_spec.rb
index f481b5078f2..518ea4e5c48 100644
--- a/spec/controllers/profiles/accounts_controller_spec.rb
+++ b/spec/controllers/profiles/accounts_controller_spec.rb
@@ -13,7 +13,7 @@ describe Profiles::AccountsController do
it 'renders 404 if someone tries to unlink a non existent provider' do
delete :unlink, params: { provider: 'github' }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
[:saml, :cas3].each do |provider|
@@ -25,7 +25,7 @@ describe Profiles::AccountsController do
delete :unlink, params: { provider: provider.to_s }
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(user.reload.identities).to include(identity)
end
end
@@ -40,7 +40,7 @@ describe Profiles::AccountsController do
delete :unlink, params: { provider: provider.to_s }
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
expect(user.reload.identities).not_to include(identity)
end
end
diff --git a/spec/controllers/snippets/notes_controller_spec.rb b/spec/controllers/snippets/notes_controller_spec.rb
index fd4b95ce226..b93df3555ab 100644
--- a/spec/controllers/snippets/notes_controller_spec.rb
+++ b/spec/controllers/snippets/notes_controller_spec.rb
@@ -22,7 +22,7 @@ describe Snippets::NotesController do
end
it "returns status 200" do
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it "returns not empty array of notes" do
@@ -39,7 +39,7 @@ describe Snippets::NotesController do
it "returns status 404" do
get :index, params: { snippet_id: internal_snippet }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -51,7 +51,7 @@ describe Snippets::NotesController do
it "returns status 200" do
get :index, params: { snippet_id: internal_snippet }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
@@ -65,7 +65,7 @@ describe Snippets::NotesController do
it "returns status 404" do
get :index, params: { snippet_id: private_snippet }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -77,7 +77,7 @@ describe Snippets::NotesController do
it "returns status 404" do
get :index, params: { snippet_id: private_snippet }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -91,7 +91,7 @@ describe Snippets::NotesController do
it "returns status 200" do
get :index, params: { snippet_id: private_snippet }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it "returns 1 note" do
@@ -135,7 +135,7 @@ describe Snippets::NotesController do
it 'returns status 302' do
post :create, params: request_params
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
it 'creates the note' do
@@ -158,7 +158,7 @@ describe Snippets::NotesController do
it 'returns status 302' do
post :create, params: request_params
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
it 'creates the note' do
@@ -186,7 +186,7 @@ describe Snippets::NotesController do
it 'returns status 404' 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 the note' do
@@ -204,7 +204,7 @@ describe Snippets::NotesController do
it 'returns status 302' do
post :create, params: request_params
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
it 'creates the note on the public snippet' do
@@ -222,7 +222,7 @@ describe Snippets::NotesController do
it 'returns status 302' do
post :create, params: request_params
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
it 'creates the note' do
@@ -249,7 +249,7 @@ describe Snippets::NotesController do
it "returns status 200" 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
@@ -277,7 +277,7 @@ describe Snippets::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
it "does not update the note" do
@@ -299,7 +299,7 @@ describe Snippets::NotesController do
it "toggles the award emoji" do
expect { subject }.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 when it exists" do
@@ -307,7 +307,7 @@ describe Snippets::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
end
end
diff --git a/spec/controllers/user_callouts_controller_spec.rb b/spec/controllers/user_callouts_controller_spec.rb
index 07eaff2da09..babc93a83e5 100644
--- a/spec/controllers/user_callouts_controller_spec.rb
+++ b/spec/controllers/user_callouts_controller_spec.rb
@@ -13,7 +13,7 @@ describe UserCalloutsController do
subject { post :create, params: { feature_name: feature_name }, format: :json }
context 'with valid feature name' do
- let(:feature_name) { UserCallout.feature_names.first.first }
+ let(:feature_name) { UserCallout.feature_names.keys.first }
context 'when callout entry does not exist' do
it 'creates a callout entry with dismissed state' do
@@ -28,7 +28,7 @@ describe UserCalloutsController do
end
context 'when callout entry already exists' do
- let!(:callout) { create(:user_callout, feature_name: UserCallout.feature_names.first.first, user: user) }
+ let!(:callout) { create(:user_callout, feature_name: UserCallout.feature_names.keys.first, user: user) }
it 'returns success' do
subject
diff --git a/spec/factories/prometheus_alert.rb b/spec/factories/prometheus_alert.rb
new file mode 100644
index 00000000000..a9fede9efca
--- /dev/null
+++ b/spec/factories/prometheus_alert.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :prometheus_alert do
+ project
+ operator { :gt }
+ threshold { 1 }
+
+ environment do |alert|
+ build(:environment, project: alert.project)
+ end
+
+ prometheus_metric do |alert|
+ build(:prometheus_metric, project: alert.project)
+ end
+ end
+end
diff --git a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
index 8322a6afa04..45da4f30e4f 100644
--- a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
+++ b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
@@ -187,7 +187,7 @@ describe 'User creates branch and merge request on issue page', :js do
let(:branch_name) { "#{issue.iid}-foo" }
before do
- project.repository.create_branch(branch_name, 'master')
+ project.repository.create_branch(branch_name)
visit project_issue_path(project, issue)
end
diff --git a/spec/features/merge_request/user_posts_diff_notes_spec.rb b/spec/features/merge_request/user_posts_diff_notes_spec.rb
index a76e40da9e5..103d126891e 100644
--- a/spec/features/merge_request/user_posts_diff_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_diff_notes_spec.rb
@@ -46,7 +46,7 @@ describe 'Merge request > User posts diff notes', :js do
end
context 'with an old line on the left and a new line on the right' do
- it 'allows commenting on the left side' do
+ it 'allows commenting on the left side', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/199050' do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, '..'), 'left')
end
diff --git a/spec/features/merge_request/user_resolves_conflicts_spec.rb b/spec/features/merge_request/user_resolves_conflicts_spec.rb
index ce85e81868d..5fc65f020d3 100644
--- a/spec/features/merge_request/user_resolves_conflicts_spec.rb
+++ b/spec/features/merge_request/user_resolves_conflicts_spec.rb
@@ -169,8 +169,8 @@ describe 'Merge request > User resolves conflicts', :js do
context "with malicious branch name" do
let(:bad_branch_name) { "malicious-branch-{{toString.constructor('alert(/xss/)')()}}" }
- let(:branch) { project.repository.create_branch(bad_branch_name, 'conflict-resolvable') }
- let(:merge_request) { create_merge_request(branch.name) }
+ let!(:branch) { project.repository.create_branch(bad_branch_name, 'conflict-resolvable') }
+ let(:merge_request) { create_merge_request(bad_branch_name) }
before do
visit project_merge_request_path(project, merge_request)
diff --git a/spec/features/projects/graph_spec.rb b/spec/features/projects/graph_spec.rb
index 7b5c731c34b..562dbeb816a 100644
--- a/spec/features/projects/graph_spec.rb
+++ b/spec/features/projects/graph_spec.rb
@@ -60,7 +60,7 @@ describe 'Project Graph', :js do
let(:branch_name) { '<h1>evil</h1>' }
before do
- project.repository.create_branch(branch_name, 'master')
+ project.repository.create_branch(branch_name)
visit charts_project_graph_path(project, branch_name)
end
diff --git a/spec/fixtures/lib/gitlab/import_export/complex/project.json b/spec/fixtures/lib/gitlab/import_export/complex/project.json
index 7d784fbd54f..4d6211a1251 100644
--- a/spec/fixtures/lib/gitlab/import_export/complex/project.json
+++ b/spec/fixtures/lib/gitlab/import_export/complex/project.json
@@ -2398,7 +2398,7 @@
"requested_at": null,
"user": {
"id": 16,
- "email": "maritza_schoen@block.ca",
+ "email": "bernard_willms@gitlabexample.com",
"username": "bernard_willms"
}
},
@@ -2418,7 +2418,7 @@
"requested_at": null,
"user": {
"id": 6,
- "email": "shaina@koelpindenesik.com",
+ "email": "saul_will@gitlabexample.com",
"username": "saul_will"
}
},
diff --git a/spec/fixtures/lib/gitlab/import_export/group_exports/complex/group.json b/spec/fixtures/lib/gitlab/import_export/group_exports/complex/group.json
index edfc6333a24..6403b5fa080 100644
--- a/spec/fixtures/lib/gitlab/import_export/group_exports/complex/group.json
+++ b/spec/fixtures/lib/gitlab/import_export/group_exports/complex/group.json
@@ -348,7 +348,7 @@
"override": false,
"user": {
"id": 206,
- "email": "margaret.bergnaum@reynolds.us",
+ "email": "gwendolyn_robel@gitlabexample.com",
"username": "gwendolyn_robel"
}
},
@@ -394,7 +394,7 @@
"override": false,
"user": {
"id": 1624,
- "email": "nakesha.herzog@powlowski.com",
+ "email": "adriene.mcclure@gitlabexample.com",
"username": "adriene.mcclure"
}
},
diff --git a/spec/graphql/types/permission_types/project_spec.rb b/spec/graphql/types/permission_types/project_spec.rb
index a3a9872ee1a..56c4c2de4df 100644
--- a/spec/graphql/types/permission_types/project_spec.rb
+++ b/spec/graphql/types/permission_types/project_spec.rb
@@ -12,7 +12,8 @@ describe Types::PermissionTypes::Project do
:read_commit_status, :request_access, :create_pipeline, :create_pipeline_schedule,
:create_merge_request_from, :create_wiki, :push_code, :create_deployment, :push_to_delete_protected_branch,
:admin_wiki, :admin_project, :update_pages, :admin_remote_mirror, :create_label,
- :update_wiki, :destroy_wiki, :create_pages, :destroy_pages, :read_pages_content
+ :update_wiki, :destroy_wiki, :create_pages, :destroy_pages, :read_pages_content,
+ :read_merge_request
]
expected_permissions.each do |permission|
diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb
index 89730a67977..d7cc8afe9c5 100644
--- a/spec/helpers/markup_helper_spec.rb
+++ b/spec/helpers/markup_helper_spec.rb
@@ -403,7 +403,7 @@ describe MarkupHelper do
it 'logs the error' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(StandardError),
- project_id: project.id, file_name: 'foo.md', context: context
+ project_id: project.id, file_name: 'foo.md'
)
subject
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index 07fef203691..a9d7beb0fea 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -310,8 +310,8 @@ describe Gitlab::Git::Repository, :seed_helper do
with_them do
before do
- repository.create_branch('left-branch', 'master')
- repository.create_branch('right-branch', 'master')
+ repository.create_branch('left-branch')
+ repository.create_branch('right-branch')
left.times do
new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', 'left-branch', 'some more content for a', 'some stuff')
@@ -350,8 +350,8 @@ describe Gitlab::Git::Repository, :seed_helper do
with_them do
before do
- repository.create_branch('left-branch', 'master')
- repository.create_branch('right-branch', 'master')
+ repository.create_branch('left-branch')
+ repository.create_branch('right-branch')
left.times do
new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', 'left-branch', 'some more content for a', 'some stuff')
@@ -420,55 +420,6 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- describe "#delete_branch" do
- let(:repository) { mutable_repository }
-
- after do
- ensure_seeds
- end
-
- it "removes the branch from the repo" do
- branch_name = "to-be-deleted-soon"
-
- repository.create_branch(branch_name)
- expect(repository_rugged.branches[branch_name]).not_to be_nil
-
- repository.delete_branch(branch_name)
- expect(repository_rugged.branches[branch_name]).to be_nil
- end
-
- context "when branch does not exist" do
- it "raises a DeleteBranchError exception" do
- expect { repository.delete_branch("this-branch-does-not-exist") }.to raise_error(Gitlab::Git::Repository::DeleteBranchError)
- end
- end
- end
-
- describe "#create_branch" do
- let(:repository) { mutable_repository }
-
- after do
- ensure_seeds
- end
-
- it "creates a new branch" do
- expect(repository.create_branch('new_branch', 'master')).not_to be_nil
- end
-
- it "creates a new branch with the right name" do
- expect(repository.create_branch('another_branch', 'master').name).to eq('another_branch')
- end
-
- it "fails if we create an existing branch" do
- repository.create_branch('duplicated_branch', 'master')
- expect {repository.create_branch('duplicated_branch', 'master')}.to raise_error("Branch duplicated_branch already exists")
- end
-
- it "fails if we create a branch from a non existing ref" do
- expect {repository.create_branch('branch_based_in_wrong_ref', 'master_2_the_revenge')}.to raise_error("Invalid reference master_2_the_revenge")
- end
- end
-
describe '#delete_refs' do
let(:repository) { mutable_repository }
@@ -506,8 +457,8 @@ describe Gitlab::Git::Repository, :seed_helper do
let(:utf8_branch) { 'branch-é' }
before do
- repository.create_branch(new_branch, 'master')
- repository.create_branch(utf8_branch, 'master')
+ repository.create_branch(new_branch)
+ repository.create_branch(utf8_branch)
end
after do
@@ -609,32 +560,30 @@ describe Gitlab::Git::Repository, :seed_helper do
describe '#search_files_by_content' do
let(:repository) { mutable_repository }
let(:repository_rugged) { mutable_repository_rugged }
+ let(:ref) { 'search-files-by-content-branch' }
+ let(:content) { 'foobarbazmepmep' }
before do
- repository.create_branch('search-files-by-content-branch', 'master')
- new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', 'search-files-by-content-branch', 'committing something', 'search-files-by-content change')
- new_commit_edit_new_file_on_branch(repository_rugged, 'anotherfile', 'search-files-by-content-branch', 'committing something', 'search-files-by-content change')
+ repository.create_branch(ref)
+ new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', ref, 'committing something', content)
+ new_commit_edit_new_file_on_branch(repository_rugged, 'anotherfile', ref, 'committing something', content)
end
after do
ensure_seeds
end
- shared_examples 'search files by content' do
- it 'has 2 items' do
- expect(search_results.size).to eq(2)
- end
+ subject do
+ repository.search_files_by_content(content, ref)
+ end
- it 'has the correct matching line' do
- expect(search_results).to contain_exactly("search-files-by-content-branch:encoding/CHANGELOG\u00001\u0000search-files-by-content change\n",
- "search-files-by-content-branch:anotherfile\u00001\u0000search-files-by-content change\n")
- end
+ it 'has 2 items' do
+ expect(subject.size).to eq(2)
end
- it_should_behave_like 'search files by content' do
- let(:search_results) do
- repository.search_files_by_content('search-files-by-content', 'search-files-by-content-branch')
- end
+ it 'has the correct matching line' do
+ expect(subject).to contain_exactly("#{ref}:encoding/CHANGELOG\u00001\u0000#{content}\n",
+ "#{ref}:anotherfile\u00001\u0000#{content}\n")
end
end
@@ -1116,7 +1065,7 @@ describe Gitlab::Git::Repository, :seed_helper do
before do
create_remote_branch('joe', 'remote_branch', 'master')
- repository.create_branch('local_branch', 'master')
+ repository.create_branch('local_branch')
end
after do
@@ -1142,7 +1091,7 @@ describe Gitlab::Git::Repository, :seed_helper do
before do
create_remote_branch('joe', 'remote_branch', 'master')
- repository.create_branch('local_branch', 'master')
+ repository.create_branch('local_branch')
end
after do
@@ -1192,7 +1141,7 @@ describe Gitlab::Git::Repository, :seed_helper do
context 'when no branch names are specified' do
before do
- repository.create_branch('identical', 'master')
+ repository.create_branch('identical')
end
after do
@@ -1303,7 +1252,7 @@ describe Gitlab::Git::Repository, :seed_helper do
let(:branch_name) { "ʕ•ᴥ•ʔ" }
before do
- repository.create_branch(branch_name, "master")
+ repository.create_branch(branch_name)
end
after do
@@ -1447,7 +1396,7 @@ describe Gitlab::Git::Repository, :seed_helper do
before do
create_remote_branch('joe', 'remote_branch', 'master')
- repository.create_branch('local_branch', 'master')
+ repository.create_branch('local_branch')
end
after do
diff --git a/spec/lib/gitlab/import_export/group_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/group_tree_restorer_spec.rb
index 0c55ed715cc..0d9b07ffaf0 100644
--- a/spec/lib/gitlab/import_export/group_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/group_tree_restorer_spec.rb
@@ -10,9 +10,9 @@ describe Gitlab::ImportExport::GroupTreeRestorer do
describe 'restore group tree' do
before(:context) do
# Using an admin for import, so we can check assignment of existing members
- user = create(:admin, username: 'root')
- create(:user, username: 'adriene.mcclure')
- create(:user, username: 'gwendolyn_robel')
+ user = create(:admin, email: 'root@gitlabexample.com')
+ create(:user, email: 'adriene.mcclure@gitlabexample.com')
+ create(:user, email: 'gwendolyn_robel@gitlabexample.com')
RSpec::Mocks.with_temporary_scope do
@group = create(:group, name: 'group', path: 'group')
@@ -56,7 +56,7 @@ describe Gitlab::ImportExport::GroupTreeRestorer do
end
it 'has group members' do
- expect(@group.members.map(&:user).map(&:username)).to contain_exactly('root', 'adriene.mcclure', 'gwendolyn_robel')
+ expect(@group.members.map(&:user).map(&:email)).to contain_exactly('root@gitlabexample.com', 'adriene.mcclure@gitlabexample.com', 'gwendolyn_robel@gitlabexample.com')
end
end
end
diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
index 129f119e148..c899217d164 100644
--- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
@@ -13,8 +13,8 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
# Using an admin for import, so we can check assignment of existing members
@user = create(:admin)
@existing_members = [
- create(:user, username: 'bernard_willms'),
- create(:user, username: 'saul_will')
+ create(:user, email: 'bernard_willms@gitlabexample.com'),
+ create(:user, email: 'saul_will@gitlabexample.com')
]
RSpec::Mocks.with_temporary_scope do
diff --git a/spec/lib/gitlab/runtime_spec.rb b/spec/lib/gitlab/runtime_spec.rb
index 52976d925b9..f6e8ad8ae79 100644
--- a/spec/lib/gitlab/runtime_spec.rb
+++ b/spec/lib/gitlab/runtime_spec.rb
@@ -3,6 +3,23 @@
require 'spec_helper'
describe Gitlab::Runtime do
+ shared_examples "valid runtime" do |runtime, max_threads|
+ it "identifies itself" do
+ expect(subject.identify).to eq(runtime)
+ expect(subject.public_send("#{runtime}?")).to be(true)
+ end
+
+ it "does not identify as others" do
+ (described_class::AVAILABLE_RUNTIMES - [runtime]).each do |runtime|
+ expect(subject.public_send("#{runtime}?")).to eq(false)
+ end
+ end
+
+ it "reports its maximum concurrency" do
+ expect(subject.max_threads).to eq(max_threads)
+ end
+ end
+
before do
allow(described_class).to receive(:process_name).and_return('ruby')
stub_rails_env('production')
@@ -27,117 +44,42 @@ describe Gitlab::Runtime do
context "puma" do
let(:puma_type) { double('::Puma') }
- let(:options) do
- {
- max_threads: 2
- }
- end
before do
stub_const('::Puma', puma_type)
- allow(puma_type).to receive_message_chain(:cli_config, :options).and_return(options)
- end
-
- it "identifies itself" do
- expect(subject.identify).to eq(:puma)
- expect(subject.puma?).to be(true)
+ allow(puma_type).to receive_message_chain(:cli_config, :options).and_return(max_threads: 2)
end
- it "does not identify as others" do
- expect(subject.unicorn?).to be(false)
- expect(subject.sidekiq?).to be(false)
- expect(subject.console?).to be(false)
- expect(subject.rake?).to be(false)
- expect(subject.test_suite?).to be(false)
- end
-
- it "reports its maximum concurrency" do
- expect(subject.max_threads).to eq(2)
- end
+ it_behaves_like "valid runtime", :puma, 2
end
context "unicorn" do
- let(:unicorn_type) { Module.new }
- let(:unicorn_server_type) { Class.new }
-
before do
- stub_const('::Unicorn', unicorn_type)
- stub_const('::Unicorn::HttpServer', unicorn_server_type)
+ stub_const('::Unicorn', Module.new)
+ stub_const('::Unicorn::HttpServer', Class.new)
end
- it "identifies itself" do
- expect(subject.identify).to eq(:unicorn)
- expect(subject.unicorn?).to be(true)
- end
-
- it "does not identify as others" do
- expect(subject.puma?).to be(false)
- expect(subject.sidekiq?).to be(false)
- expect(subject.console?).to be(false)
- expect(subject.rake?).to be(false)
- expect(subject.test_suite?).to be(false)
- end
-
- it "reports its maximum concurrency" do
- expect(subject.max_threads).to eq(1)
- end
+ it_behaves_like "valid runtime", :unicorn, 1
end
context "sidekiq" do
let(:sidekiq_type) { double('::Sidekiq') }
- let(:options) do
- {
- concurrency: 2
- }
- end
before do
stub_const('::Sidekiq', sidekiq_type)
allow(sidekiq_type).to receive(:server?).and_return(true)
- allow(sidekiq_type).to receive(:options).and_return(options)
+ allow(sidekiq_type).to receive(:options).and_return(concurrency: 2)
end
- it "identifies itself" do
- expect(subject.identify).to eq(:sidekiq)
- expect(subject.sidekiq?).to be(true)
- end
-
- it "does not identify as others" do
- expect(subject.unicorn?).to be(false)
- expect(subject.puma?).to be(false)
- expect(subject.console?).to be(false)
- expect(subject.rake?).to be(false)
- expect(subject.test_suite?).to be(false)
- end
-
- it "reports its maximum concurrency" do
- expect(subject.max_threads).to eq(2)
- end
+ it_behaves_like "valid runtime", :sidekiq, 2
end
context "console" do
- let(:console_type) { double('::Rails::Console') }
-
before do
- stub_const('::Rails::Console', console_type)
- end
-
- it "identifies itself" do
- expect(subject.identify).to eq(:console)
- expect(subject.console?).to be(true)
- end
-
- it "does not identify as others" do
- expect(subject.unicorn?).to be(false)
- expect(subject.sidekiq?).to be(false)
- expect(subject.puma?).to be(false)
- expect(subject.rake?).to be(false)
- expect(subject.test_suite?).to be(false)
+ stub_const('::Rails::Console', double('::Rails::Console'))
end
- it "reports its maximum concurrency" do
- expect(subject.max_threads).to eq(1)
- end
+ it_behaves_like "valid runtime", :console, 1
end
context "test suite" do
@@ -145,20 +87,14 @@ describe Gitlab::Runtime do
stub_rails_env('test')
end
- it "identifies itself" do
- expect(subject.identify).to eq(:test_suite)
- expect(subject.test_suite?).to be(true)
- end
+ it_behaves_like "valid runtime", :test_suite, 1
+ end
- it "does not identify as others" do
- expect(subject.unicorn?).to be(false)
- expect(subject.sidekiq?).to be(false)
- expect(subject.rake?).to be(false)
- expect(subject.puma?).to be(false)
+ context "geo log cursor" do
+ before do
+ stub_const('::GeoLogCursorOptionParser', double('::GeoLogCursorOptionParser'))
end
- it "reports its maximum concurrency" do
- expect(subject.max_threads).to eq(1)
- end
+ it_behaves_like "valid runtime", :geo_log_cursor, 1
end
end
diff --git a/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb b/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb
index 0453ac87436..a84cac0623b 100644
--- a/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb
+++ b/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb
@@ -14,28 +14,28 @@ describe MigrateIssueTrackersData, :migration do
}
end
let!(:jira_service) do
- services.create(id: 10, type: 'JiraService', properties: properties, category: 'issue_tracker')
+ services.create(type: 'JiraService', properties: properties, category: 'issue_tracker')
end
let!(:jira_service_nil) do
- services.create(id: 11, type: 'JiraService', properties: nil, category: 'issue_tracker')
+ services.create(type: 'JiraService', properties: nil, category: 'issue_tracker')
end
let!(:bugzilla_service) do
- services.create(id: 12, type: 'BugzillaService', properties: properties, category: 'issue_tracker')
+ services.create(type: 'BugzillaService', properties: properties, category: 'issue_tracker')
end
let!(:youtrack_service) do
- services.create(id: 13, type: 'YoutrackService', properties: properties, category: 'issue_tracker')
+ services.create(type: 'YoutrackService', properties: properties, category: 'issue_tracker')
end
let!(:youtrack_service_empty) do
- services.create(id: 14, type: 'YoutrackService', properties: '', category: 'issue_tracker')
+ services.create(type: 'YoutrackService', properties: '', category: 'issue_tracker')
end
let!(:gitlab_service) do
- services.create(id: 15, type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker')
+ services.create(type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker')
end
let!(:gitlab_service_empty) do
- services.create(id: 16, type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker')
+ services.create(type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker')
end
let!(:other_service) do
- services.create(id: 17, type: 'OtherService', properties: properties, category: 'other_category')
+ services.create(type: 'OtherService', properties: properties, category: 'other_category')
end
before do
diff --git a/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb b/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb
index 4f947358991..b51708dd5cd 100644
--- a/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb
+++ b/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200130145430_reschedule_migrate_issue_trackers_data.rb')
-describe RescheduleMigrateIssueTrackersData, :migration, :sidekiq do
+describe RescheduleMigrateIssueTrackersData, :migration do
let(:services) { table(:services) }
let(:migration_class) { Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData }
let(:migration_name) { migration_class.to_s.demodulize }
diff --git a/spec/migrations/schedule_update_existing_subgroup_to_match_visibility_level_of_parent_spec.rb b/spec/migrations/schedule_update_existing_subgroup_to_match_visibility_level_of_parent_spec.rb
index 5ff9ff4641f..221f266cb70 100644
--- a/spec/migrations/schedule_update_existing_subgroup_to_match_visibility_level_of_parent_spec.rb
+++ b/spec/migrations/schedule_update_existing_subgroup_to_match_visibility_level_of_parent_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200110121314_schedule_update_existing_subgroup_to_match_visibility_level_of_parent.rb')
-describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent, :migration, :sidekiq do
+describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent, :migration do
include MigrationHelpers::NamespacesHelpers
let(:migration_class) { described_class::MIGRATION }
let(:migration_name) { migration_class.to_s.demodulize }
diff --git a/spec/models/ci/bridge_spec.rb b/spec/models/ci/bridge_spec.rb
index a871f9b3fe6..43c843b3420 100644
--- a/spec/models/ci/bridge_spec.rb
+++ b/spec/models/ci/bridge_spec.rb
@@ -4,14 +4,25 @@ require 'spec_helper'
describe Ci::Bridge do
set(:project) { create(:project) }
+ set(:target_project) { create(:project, name: 'project', namespace: create(:namespace, name: 'my')) }
set(:pipeline) { create(:ci_pipeline, project: project) }
let(:bridge) do
- create(:ci_bridge, pipeline: pipeline)
+ create(:ci_bridge, :variables, status: :created,
+ options: options,
+ pipeline: pipeline)
+ end
+
+ let(:options) do
+ { trigger: { project: 'my/project', branch: 'master' } }
end
it { is_expected.to include_module(Ci::PipelineDelegator) }
+ it 'has many sourced pipelines' do
+ expect(bridge).to have_many(:sourced_pipelines)
+ end
+
describe '#tags' do
it 'only has a bridge tag' do
expect(bridge.tags).to eq [:bridge]
@@ -41,4 +52,222 @@ describe Ci::Bridge do
expect(bridge.scoped_variables_hash.keys).to include(*variables)
end
end
+
+ describe '#inherit_status_from_downstream!' do
+ let(:downstream_pipeline) { build(:ci_pipeline, status: downstream_status) }
+
+ before do
+ bridge.status = 'pending'
+ create(:ci_sources_pipeline, pipeline: downstream_pipeline, source_job: bridge)
+ end
+
+ subject { bridge.inherit_status_from_downstream!(downstream_pipeline) }
+
+ context 'when status is not supported' do
+ (::Ci::Pipeline::AVAILABLE_STATUSES - ::Ci::Pipeline::COMPLETED_STATUSES).map(&:to_s).each do |status|
+ context "when status is #{status}" do
+ let(:downstream_status) { status }
+
+ it 'returns false' do
+ expect(subject).to eq(false)
+ end
+
+ it 'does not change the bridge status' do
+ expect { subject }.not_to change { bridge.status }.from('pending')
+ end
+ end
+ end
+ end
+
+ context 'when status is supported' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:downstream_status, :upstream_status) do
+ [
+ %w[success success],
+ *::Ci::Pipeline.completed_statuses.without(:success).map { |status| [status.to_s, 'failed'] }
+ ]
+ end
+
+ with_them do
+ it 'inherits the downstream status' do
+ expect { subject }.to change { bridge.status }.from('pending').to(upstream_status)
+ end
+ end
+ end
+ end
+
+ describe '#dependent?' do
+ subject { bridge.dependent? }
+
+ context 'when bridge has strategy depend' do
+ let(:options) { { trigger: { project: 'my/project', strategy: 'depend' } } }
+
+ it { is_expected.to be true }
+ end
+
+ context 'when bridge does not have strategy depend' do
+ it { is_expected.to be false }
+ end
+ end
+
+ describe '#yaml_variables' do
+ it 'returns YAML variables' do
+ expect(bridge.yaml_variables)
+ .to include(key: 'BRIDGE', value: 'cross', public: true)
+ end
+ end
+
+ describe '#downstream_variables' do
+ it 'returns variables that are going to be passed downstream' do
+ expect(bridge.downstream_variables)
+ .to include(key: 'BRIDGE', value: 'cross')
+ end
+
+ context 'when using variables interpolation' do
+ let(:yaml_variables) do
+ [
+ {
+ key: 'EXPANDED',
+ value: '$BRIDGE-bridge',
+ public: true
+ },
+ {
+ key: 'UPSTREAM_CI_PIPELINE_ID',
+ value: '$CI_PIPELINE_ID',
+ public: true
+ },
+ {
+ key: 'UPSTREAM_CI_PIPELINE_URL',
+ value: '$CI_PIPELINE_URL',
+ public: true
+ }
+ ]
+ end
+
+ before do
+ bridge.yaml_variables.concat(yaml_variables)
+ end
+
+ it 'correctly expands variables with interpolation' do
+ expanded_values = pipeline
+ .persisted_variables
+ .to_hash
+ .transform_keys { |key| "UPSTREAM_#{key}" }
+ .map { |key, value| { key: key, value: value } }
+ .push(key: 'EXPANDED', value: 'cross-bridge')
+
+ expect(bridge.downstream_variables)
+ .to match(a_collection_including(*expanded_values))
+ end
+ end
+
+ context 'when recursive interpolation has been used' do
+ before do
+ bridge.yaml_variables << { key: 'EXPANDED', value: '$EXPANDED', public: true }
+ end
+
+ it 'does not expand variable recursively' do
+ expect(bridge.downstream_variables)
+ .to include(key: 'EXPANDED', value: '$EXPANDED')
+ end
+ end
+ end
+
+ describe 'metadata support' do
+ it 'reads YAML variables from metadata' do
+ expect(bridge.yaml_variables).not_to be_empty
+ expect(bridge.metadata).to be_a Ci::BuildMetadata
+ expect(bridge.read_attribute(:yaml_variables)).to be_nil
+ expect(bridge.metadata.config_variables).to be bridge.yaml_variables
+ end
+
+ it 'reads options from metadata' do
+ expect(bridge.options).not_to be_empty
+ expect(bridge.metadata).to be_a Ci::BuildMetadata
+ expect(bridge.read_attribute(:options)).to be_nil
+ expect(bridge.metadata.config_options).to be bridge.options
+ end
+ end
+
+ describe '#triggers_child_pipeline?' do
+ subject { bridge.triggers_child_pipeline? }
+
+ context 'when bridge defines a downstream YAML' do
+ let(:options) do
+ {
+ trigger: {
+ include: 'path/to/child.yml'
+ }
+ }
+ end
+
+ it { is_expected.to be_truthy }
+ end
+
+ context 'when bridge does not define a downstream YAML' do
+ let(:options) do
+ {
+ trigger: {
+ project: project.full_path
+ }
+ }
+ end
+
+ it { is_expected.to be_falsey }
+ end
+ end
+
+ describe '#yaml_for_downstream' do
+ subject { bridge.yaml_for_downstream }
+
+ context 'when bridge defines a downstream YAML' do
+ let(:options) do
+ {
+ trigger: {
+ include: 'path/to/child.yml'
+ }
+ }
+ end
+
+ let(:yaml) do
+ <<~EOY
+ ---
+ include: path/to/child.yml
+ EOY
+ end
+
+ it { is_expected.to eq yaml }
+ end
+
+ context 'when bridge does not define a downstream YAML' do
+ let(:options) { {} }
+
+ it { is_expected.to be_nil }
+ end
+ end
+
+ describe '#target_ref' do
+ context 'when trigger is defined' do
+ it 'returns a ref name' do
+ expect(bridge.target_ref).to eq 'master'
+ end
+
+ context 'when using variable expansion' do
+ let(:options) { { trigger: { project: 'my/project', branch: '$BRIDGE-master' } } }
+
+ it 'correctly expands variables' do
+ expect(bridge.target_ref).to eq('cross-master')
+ end
+ end
+ end
+
+ context 'when trigger does not have project defined' do
+ let(:options) { nil }
+
+ it 'returns nil' do
+ expect(bridge.target_ref).to be_nil
+ end
+ end
+ end
end
diff --git a/spec/models/prometheus_alert_spec.rb b/spec/models/prometheus_alert_spec.rb
new file mode 100644
index 00000000000..cdcdb46a6c4
--- /dev/null
+++ b/spec/models/prometheus_alert_spec.rb
@@ -0,0 +1,103 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe PrometheusAlert do
+ let_it_be(:project) { build(:project) }
+ let(:metric) { build(:prometheus_metric) }
+
+ describe '.distinct_projects' do
+ let(:project1) { create(:project) }
+ let(:project2) { create(:project) }
+
+ before do
+ create(:prometheus_alert, project: project1)
+ create(:prometheus_alert, project: project1)
+ create(:prometheus_alert, project: project2)
+ end
+
+ subject { described_class.distinct_projects.count }
+
+ it 'returns a count of all distinct projects which have an alert' do
+ expect(subject).to eq(2)
+ end
+ end
+
+ describe 'operators' do
+ it 'contains the correct equality operator' do
+ expect(described_class::OPERATORS_MAP.values).to include('==')
+ expect(described_class::OPERATORS_MAP.values).not_to include('=')
+ end
+ end
+
+ describe 'associations' do
+ it { is_expected.to belong_to(:project) }
+ it { is_expected.to belong_to(:environment) }
+ end
+
+ describe 'project validations' do
+ let(:environment) { build(:environment, project: project) }
+ let(:metric) { build(:prometheus_metric, project: project) }
+
+ subject do
+ build(:prometheus_alert, prometheus_metric: metric, environment: environment, project: project)
+ end
+
+ it { is_expected.to validate_presence_of(:environment) }
+ it { is_expected.to validate_presence_of(:project) }
+ it { is_expected.to validate_presence_of(:prometheus_metric) }
+
+ context 'when environment and metric belongs same project' do
+ it { is_expected.to be_valid }
+ end
+
+ context 'when environment belongs to different project' do
+ let(:environment) { build(:environment) }
+
+ it { is_expected.not_to be_valid }
+ end
+
+ context 'when metric belongs to different project' do
+ let(:metric) { build(:prometheus_metric) }
+
+ it { is_expected.not_to be_valid }
+ end
+
+ context 'when metric is common' do
+ let(:metric) { build(:prometheus_metric, :common) }
+
+ it { is_expected.to be_valid }
+ end
+ end
+
+ describe '#full_query' do
+ before do
+ subject.operator = "gt"
+ subject.threshold = 1
+ subject.prometheus_metric = metric
+ end
+
+ it 'returns the concatenated query' do
+ expect(subject.full_query).to eq("#{metric.query} > 1.0")
+ end
+ end
+
+ describe '#to_param' do
+ before do
+ subject.operator = "gt"
+ subject.threshold = 1
+ subject.prometheus_metric = metric
+ end
+
+ it 'returns the params of the prometheus alert' do
+ expect(subject.to_param).to eq(
+ "alert" => metric.title,
+ "expr" => "#{metric.query} > 1.0",
+ "for" => "5m",
+ "labels" => {
+ "gitlab" => "hook",
+ "gitlab_alert_id" => metric.id
+ })
+ end
+ end
+end
diff --git a/spec/models/push_event_spec.rb b/spec/models/push_event_spec.rb
index 5509ed87308..8682e1c797b 100644
--- a/spec/models/push_event_spec.rb
+++ b/spec/models/push_event_spec.rb
@@ -74,7 +74,7 @@ describe PushEvent do
create(:push_event_payload, event: event4, ref: 'baz', action: :removed)
create(:push_event_payload, event: event5, ref: 'baz', ref_type: :tag)
- project.repository.create_branch('bar', 'master')
+ project.repository.create_branch('bar')
create(
:merge_request,
@@ -83,7 +83,7 @@ describe PushEvent do
source_branch: 'bar'
)
- project.repository.create_branch('qux', 'master')
+ project.repository.create_branch('qux')
create(
:merge_request,
diff --git a/spec/models/user_callout_spec.rb b/spec/models/user_callout_spec.rb
index de6534b480a..a084b1ac662 100644
--- a/spec/models/user_callout_spec.rb
+++ b/spec/models/user_callout_spec.rb
@@ -17,4 +17,37 @@ describe UserCallout do
it { is_expected.to validate_presence_of(:feature_name) }
it { is_expected.to validate_uniqueness_of(:feature_name).scoped_to(:user_id).ignoring_case_sensitivity }
end
+
+ describe 'scopes' do
+ describe '.with_feature_name' do
+ let(:second_feature_name) { described_class.feature_names.keys.second }
+ let(:last_feature_name) { described_class.feature_names.keys.last }
+
+ it 'returns callout for requested feature name only' do
+ callout1 = create(:user_callout, feature_name: second_feature_name )
+ create(:user_callout, feature_name: last_feature_name )
+
+ callouts = described_class.with_feature_name(second_feature_name)
+
+ expect(callouts).to match_array([callout1])
+ end
+ end
+
+ describe '.with_dismissed_after' do
+ let(:some_feature_name) { described_class.feature_names.keys.second }
+ let(:callout_dismissed_month_ago) { create(:user_callout, feature_name: some_feature_name, dismissed_at: 1.month.ago )}
+
+ it 'does not return callouts dismissed before specified date' do
+ callouts = described_class.with_dismissed_after(15.days.ago)
+
+ expect(callouts).to match_array([])
+ end
+
+ it 'returns callouts dismissed after specified date' do
+ callouts = described_class.with_dismissed_after(2.months.ago)
+
+ expect(callouts).to match_array([callout_dismissed_month_ago])
+ end
+ end
+ end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 855b8e3a8a7..d441f54a0fb 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -4157,6 +4157,40 @@ describe User, :do_not_mock_admin_mode do
end
end
+ describe '#dismissed_callout?' do
+ subject(:user) { create(:user) }
+
+ let(:feature_name) { UserCallout.feature_names.keys.first }
+
+ context 'when no callout dismissal record exists' do
+ it 'returns false when no ignore_dismissal_earlier_than provided' do
+ expect(user.dismissed_callout?(feature_name: feature_name)).to eq false
+ end
+
+ it 'returns false when ignore_dismissal_earlier_than provided' do
+ expect(user.dismissed_callout?(feature_name: feature_name, ignore_dismissal_earlier_than: 3.months.ago)).to eq false
+ end
+ end
+
+ context 'when dismissed callout exists' do
+ before do
+ create(:user_callout, user: user, feature_name: feature_name, dismissed_at: 4.months.ago)
+ end
+
+ it 'returns true when no ignore_dismissal_earlier_than provided' do
+ expect(user.dismissed_callout?(feature_name: feature_name)).to eq true
+ end
+
+ it 'returns true when ignore_dismissal_earlier_than is earlier than dismissed_at' do
+ expect(user.dismissed_callout?(feature_name: feature_name, ignore_dismissal_earlier_than: 6.months.ago)).to eq true
+ end
+
+ it 'returns false when ignore_dismissal_earlier_than is later than dismissed_at' do
+ expect(user.dismissed_callout?(feature_name: feature_name, ignore_dismissal_earlier_than: 3.months.ago)).to eq false
+ end
+ end
+ end
+
describe 'bots & humans' do
it 'returns corresponding users' do
human = create(:user)
diff --git a/spec/support/controllers/project_import_rate_limiter_shared_examples.rb b/spec/support/controllers/project_import_rate_limiter_shared_examples.rb
index 336f801f923..9a543dd00d4 100644
--- a/spec/support/controllers/project_import_rate_limiter_shared_examples.rb
+++ b/spec/support/controllers/project_import_rate_limiter_shared_examples.rb
@@ -16,7 +16,7 @@ shared_examples 'project import rate limiter' do
post :create, params: {}
expect(flash[:alert]).to eq('This endpoint has been requested too many times. Try again later.')
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
end
end
diff --git a/spec/support/helpers/api_helpers.rb b/spec/support/helpers/api_helpers.rb
index aff0f87b6e4..f22ef340a5f 100644
--- a/spec/support/helpers/api_helpers.rb
+++ b/spec/support/helpers/api_helpers.rb
@@ -41,7 +41,7 @@ module ApiHelpers
end
def expect_paginated_array_response(items)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.map { |item| item['id'] }).to eq(Array(items))
diff --git a/spec/support/helpers/rack_attack_spec_helpers.rb b/spec/support/helpers/rack_attack_spec_helpers.rb
index 234271ba1c0..e0cedb5a57b 100644
--- a/spec/support/helpers/rack_attack_spec_helpers.rb
+++ b/spec/support/helpers/rack_attack_spec_helpers.rb
@@ -28,6 +28,6 @@ module RackAttackSpecHelpers
def expect_rejection(&block)
yield
- expect(response).to have_http_status(429)
+ expect(response).to have_gitlab_http_status(:too_many_requests)
end
end
diff --git a/spec/tasks/gitlab/seed/group_seed_rake_spec.rb b/spec/tasks/gitlab/seed/group_seed_rake_spec.rb
index bc217281594..ecf4e9575ab 100644
--- a/spec/tasks/gitlab/seed/group_seed_rake_spec.rb
+++ b/spec/tasks/gitlab/seed/group_seed_rake_spec.rb
@@ -2,7 +2,7 @@
require 'rake_helper'
-describe 'gitlab:seed:group_seed rake task', :sidekiq do
+describe 'gitlab:seed:group_seed rake task' do
let(:username) { 'group_seed' }
let!(:user) { create(:user, username: username) }
let(:task_params) { [2, username] }