diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-30 21:07:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-30 21:07:05 +0300 |
commit | 533f020a0ba8a3cc9e81538fe91edb273b93d5b7 (patch) | |
tree | 923d85d3680cf01b6bb2e300840490c7e3cb11e5 /spec/controllers/projects | |
parent | 9376fdc13edb5fb822431df943fa088b6a273316 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers/projects')
4 files changed, 51 insertions, 5 deletions
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb index c650d145bef..16bb33e95c8 100644 --- a/spec/controllers/projects/commit_controller_spec.rb +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -483,7 +483,7 @@ RSpec.describe Projects::CommitController do end context 'when rendering a JSON format' do - it 'responds with serialized pipelines' do + it 'responds with serialized pipelines', :aggregate_failures do get_pipelines(id: commit.id, format: :json) expect(response).to be_ok @@ -491,6 +491,26 @@ RSpec.describe Projects::CommitController do expect(json_response['count']['all']).to eq 1 expect(response).to include_pagination_headers end + + context 'with pagination' do + let!(:extra_pipeline) { create(:ci_pipeline, project: project, ref: project.default_branch, sha: commit.sha, status: :running) } + + it 'paginates the result when ref is blank' do + allow(Ci::Pipeline).to receive(:default_per_page).and_return(1) + + get_pipelines(id: commit.id, format: :json) + + expect(json_response['pipelines'].count).to eq(1) + end + + it 'paginates the result when ref is present' do + allow(Ci::Pipeline).to receive(:default_per_page).and_return(1) + + get_pipelines(id: commit.id, ref: project.default_branch, format: :json) + + expect(json_response['pipelines'].count).to eq(1) + end + end end end end diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 3385505bb62..922ecb6052a 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -1016,10 +1016,13 @@ RSpec.describe Projects::IssuesController do let(:spammy_title) { 'Whatever' } let!(:spam_logs) { create_list(:spam_log, 2, user: user, title: spammy_title) } + before do + request.headers['X-GitLab-Captcha-Response'] = 'a-valid-captcha-response' + request.headers['X-GitLab-Spam-Log-Id'] = spam_logs.last.id + end + def update_verified_issue - update_issue( - issue_params: { title: spammy_title }, - additional_params: { spam_log_id: spam_logs.last.id, 'g-recaptcha-response': true }) + update_issue(issue_params: { title: spammy_title }) end it 'returns 200 status' do @@ -1036,8 +1039,9 @@ RSpec.describe Projects::IssuesController do it 'does not mark spam log as recaptcha_verified when it does not belong to current_user' do spam_log = create(:spam_log) + request.headers['X-GitLab-Spam-Log-Id'] = spam_log.id - expect { update_issue(issue_params: { spam_log_id: spam_log.id, 'g-recaptcha-response': true }) } + expect { update_issue } .not_to change { SpamLog.last.recaptcha_verified } end end diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index d4c52e1c7ca..7b5a58fe2e5 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -860,6 +860,20 @@ RSpec.describe Projects::MergeRequestsController do end end end + + context 'with pagination' do + before do + create(:ci_pipeline, project: merge_request.source_project, ref: merge_request.source_branch, sha: merge_request.diff_head_sha) + end + + it 'paginates the result' do + allow(Ci::Pipeline).to receive(:default_per_page).and_return(1) + + get :pipelines, params: { namespace_id: project.namespace.to_param, project_id: project, id: merge_request.iid }, format: :json + + expect(json_response['pipelines'].count).to eq(1) + end + end end describe 'GET context commits' do diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index c3e29f45ac9..2379ff9fd98 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -66,6 +66,14 @@ RSpec.describe Projects::PipelinesController do expect(json_response['pipelines'][0]).not_to include('coverage') end + it 'paginates the result' do + allow(Ci::Pipeline).to receive(:default_per_page).and_return(2) + + get_pipelines_index_json + + check_pipeline_response(returned: 2, all: 6) + end + context 'when performing gitaly calls', :request_store do it 'limits the Gitaly requests' do # Isolate from test preparation (Repository#exists? is also cached in RequestStore) |