Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/application_controller_spec.rb8
-rw-r--r--spec/controllers/groups_controller_spec.rb3
-rw-r--r--spec/controllers/projects/jobs_controller_spec.rb56
-rw-r--r--spec/controllers/projects/merge_requests_controller_spec.rb14
-rw-r--r--spec/controllers/projects/settings/repository_controller_spec.rb10
-rw-r--r--spec/controllers/projects_controller_spec.rb2
6 files changed, 78 insertions, 15 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index ac92b2ca657..c2bd7fd9808 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -460,6 +460,14 @@ describe ApplicationController do
expect(controller.last_payload.has_key?(:response)).to be_falsey
end
+ it 'does log correlation id' do
+ Gitlab::CorrelationId.use_id('new-id') do
+ get :index
+ end
+
+ expect(controller.last_payload).to include('correlation_id' => 'new-id')
+ end
+
context '422 errors' do
it 'logs a response with a string' do
response = spy(ActionDispatch::Response, status: 422, body: 'Hello world', content_type: 'application/json', cookies: {})
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb
index f6c85102830..4b0dc4c9b69 100644
--- a/spec/controllers/groups_controller_spec.rb
+++ b/spec/controllers/groups_controller_spec.rb
@@ -226,9 +226,10 @@ describe GroupsController do
end
context 'searching' do
- # Remove as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/52271
before do
+ # Remove in https://gitlab.com/gitlab-org/gitlab-ce/issues/54643
stub_feature_flags(use_cte_for_group_issues_search: false)
+ stub_feature_flags(use_subquery_for_group_issues_search: true)
end
it 'works with popularity sort' do
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb
index 51a7cc63cef..fca313dafb1 100644
--- a/spec/controllers/projects/jobs_controller_spec.rb
+++ b/spec/controllers/projects/jobs_controller_spec.rb
@@ -401,18 +401,56 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
context 'with variables' do
before do
create(:ci_pipeline_variable, pipeline: pipeline, key: :TRIGGER_KEY_1, value: 'TRIGGER_VALUE_1')
+ end
- get_show(id: job.id, format: :json)
+ context 'user is a maintainer' do
+ before do
+ project.add_maintainer(user)
+
+ get_show(id: job.id, format: :json)
+ end
+
+ it 'returns a job_detail' do
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(response).to match_response_schema('job/job_details')
+ end
+
+ it 'exposes trigger information and variables' do
+ expect(json_response['trigger']['short_token']).to eq 'toke'
+ expect(json_response['trigger']['variables'].length).to eq 1
+ end
+
+ it 'exposes correct variable properties' do
+ first_variable = json_response['trigger']['variables'].first
+
+ expect(first_variable['key']).to eq "TRIGGER_KEY_1"
+ expect(first_variable['value']).to eq "TRIGGER_VALUE_1"
+ expect(first_variable['public']).to eq false
+ end
end
- it 'exposes trigger information and variables' do
- expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['trigger']['short_token']).to eq 'toke'
- expect(json_response['trigger']['variables'].length).to eq 1
- expect(json_response['trigger']['variables'].first['key']).to eq "TRIGGER_KEY_1"
- expect(json_response['trigger']['variables'].first['value']).to eq "TRIGGER_VALUE_1"
- expect(json_response['trigger']['variables'].first['public']).to eq false
+ context 'user is not a mantainer' do
+ before do
+ get_show(id: job.id, format: :json)
+ end
+
+ it 'returns a job_detail' do
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(response).to match_response_schema('job/job_details')
+ end
+
+ it 'exposes trigger information and variables' do
+ expect(json_response['trigger']['short_token']).to eq 'toke'
+ expect(json_response['trigger']['variables'].length).to eq 1
+ end
+
+ it 'exposes correct variable properties' do
+ first_variable = json_response['trigger']['variables'].first
+
+ expect(first_variable['key']).to eq "TRIGGER_KEY_1"
+ expect(first_variable['value']).to be_nil
+ expect(first_variable['public']).to eq false
+ end
end
end
end
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index e62523c65c9..7f15da859e5 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -290,6 +290,20 @@ describe Projects::MergeRequestsController do
it_behaves_like 'update invalid issuable', MergeRequest
end
+
+ context 'two merge requests with the same source branch' do
+ it 'does not allow a closed merge request to be reopened if another one is open' do
+ merge_request.close!
+ create(:merge_request, source_project: merge_request.source_project, source_branch: merge_request.source_branch)
+
+ update_merge_request(state_event: 'reopen')
+
+ errors = assigns[:merge_request].errors
+
+ expect(errors[:validate_branches]).to include(/Another open merge request already exists for this source branch/)
+ expect(merge_request.reload).to be_closed
+ end
+ end
end
describe 'POST merge' do
diff --git a/spec/controllers/projects/settings/repository_controller_spec.rb b/spec/controllers/projects/settings/repository_controller_spec.rb
index 69ec971bb75..70f79a47e63 100644
--- a/spec/controllers/projects/settings/repository_controller_spec.rb
+++ b/spec/controllers/projects/settings/repository_controller_spec.rb
@@ -19,12 +19,14 @@ describe Projects::Settings::RepositoryController do
end
describe 'PUT cleanup' do
+ before do
+ allow(RepositoryCleanupWorker).to receive(:perform_async)
+ end
+
def do_put!
object_map = fixture_file_upload('spec/fixtures/bfg_object_map.txt')
- Sidekiq::Testing.fake! do
- put :cleanup, namespace_id: project.namespace, project_id: project, project: { object_map: object_map }
- end
+ put :cleanup, namespace_id: project.namespace, project_id: project, project: { object_map: object_map }
end
context 'feature enabled' do
@@ -34,7 +36,7 @@ describe Projects::Settings::RepositoryController do
do_put!
expect(response).to redirect_to project_settings_repository_path(project)
- expect(RepositoryCleanupWorker.jobs.count).to eq(1)
+ expect(RepositoryCleanupWorker).to have_received(:perform_async).once
end
end
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 7849bec4762..576191a5788 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -279,7 +279,7 @@ describe ProjectsController do
expected_query = /#{public_project.fork_network.find_forks_in(other_user.namespace).to_sql}/
expect { get(:show, namespace_id: public_project.namespace, id: public_project) }
- .not_to exceed_query_limit(1).for_query(expected_query)
+ .not_to exceed_query_limit(2).for_query(expected_query)
end
end
end