diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/controllers/import/bulk_imports_controller_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/controllers/import/bulk_imports_controller_spec.rb')
-rw-r--r-- | spec/controllers/import/bulk_imports_controller_spec.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/spec/controllers/import/bulk_imports_controller_spec.rb b/spec/controllers/import/bulk_imports_controller_spec.rb index d1c138617bb..08a54f112bb 100644 --- a/spec/controllers/import/bulk_imports_controller_spec.rb +++ b/spec/controllers/import/bulk_imports_controller_spec.rb @@ -59,7 +59,14 @@ RSpec.describe Import::BulkImportsController do parsed_response: [ { 'id' => 1, 'full_name' => 'group1', 'full_path' => 'full/path/group1', 'web_url' => 'http://demo.host/full/path/group1' }, { 'id' => 2, 'full_name' => 'group2', 'full_path' => 'full/path/group2', 'web_url' => 'http://demo.host/full/path/group1' } - ] + ], + headers: { + 'x-next-page' => '2', + 'x-page' => '1', + 'x-per-page' => '20', + 'x-total' => '37', + 'x-total-pages' => '2' + } ) end @@ -81,6 +88,17 @@ RSpec.describe Import::BulkImportsController do expect(json_response).to eq({ importable_data: client_response.parsed_response }.as_json) end + it 'forwards pagination headers' do + get :status, format: :json + + expect(response.headers['x-per-page']).to eq client_response.headers['x-per-page'] + expect(response.headers['x-page']).to eq client_response.headers['x-page'] + expect(response.headers['x-next-page']).to eq client_response.headers['x-next-page'] + expect(response.headers['x-prev-page']).to eq client_response.headers['x-prev-page'] + expect(response.headers['x-total']).to eq client_response.headers['x-total'] + expect(response.headers['x-total-pages']).to eq client_response.headers['x-total-pages'] + end + context 'when filtering' do it 'returns filtered result' do filter = 'test' @@ -167,6 +185,7 @@ RSpec.describe Import::BulkImportsController do describe 'POST create' do let(:instance_url) { "http://fake-intance" } + let(:bulk_import) { create(:bulk_import) } let(:pat) { "fake-pat" } before do @@ -183,12 +202,13 @@ RSpec.describe Import::BulkImportsController do expect_next_instance_of( BulkImportService, user, bulk_import_params, { url: instance_url, access_token: pat }) do |service| - expect(service).to receive(:execute) + allow(service).to receive(:execute).and_return(bulk_import) end post :create, params: { bulk_import: bulk_import_params } expect(response).to have_gitlab_http_status(:ok) + expect(response.body).to eq({ id: bulk_import.id }.to_json) end end end |