debian-mirror-gitlab/spec/support/shared_contexts/bulk_imports_requests_shared_context.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.7 KiB
Ruby
Raw Normal View History

2021-11-18 22:05:49 +05:30
# frozen_string_literal: true
RSpec.shared_context 'bulk imports requests context' do |url|
let(:page_response_headers) do
{
'Content-Type' => 'application/json',
'X-Next-Page' => 2,
'X-Page' => 1,
'X-Per-Page' => 20,
'X-Total' => 42,
'X-Total-Pages' => 2
}
end
2022-08-27 11:52:29 +05:30
let(:request_headers) { { 'Content-Type' => 'application/json' } }
2021-11-18 22:05:49 +05:30
before do
2023-03-17 16:20:25 +05:30
stub_request(:get, "#{url}/api/v4/version?private_token=demo-pat")
2021-11-18 22:05:49 +05:30
.with(headers: request_headers)
.to_return(
status: 200,
body: { version: ::BulkImport.min_gl_version_for_project_migration.to_s }.to_json,
headers: { 'Content-Type' => 'application/json' })
2022-08-27 11:52:29 +05:30
stub_request(:get, "https://gitlab.example.com/api/v4/groups?min_access_level=50&page=1&per_page=20&private_token=demo-pat&search=test&top_level_only=true")
2021-11-18 22:05:49 +05:30
.with(headers: request_headers)
.to_return(status: 200,
2022-10-11 01:57:18 +05:30
body: [{
id: 2595440,
web_url: 'https://gitlab.com/groups/test',
name: 'Test',
path: 'stub-test-group',
full_name: 'Test',
full_path: 'stub-test-group'
}].to_json,
headers: page_response_headers)
2021-11-18 22:05:49 +05:30
2022-08-27 11:52:29 +05:30
stub_request(:get, "%{url}/api/v4/groups?min_access_level=50&page=1&per_page=20&private_token=demo-pat&search=&top_level_only=true" % { url: url })
2021-11-18 22:05:49 +05:30
.to_return(
body: [{
id: 2595438,
web_url: 'https://gitlab.com/groups/auto-breakfast',
name: 'Stub',
path: 'stub-group',
full_name: 'Stub',
full_path: 'stub-group'
}].to_json,
2022-08-27 11:52:29 +05:30
headers: page_response_headers)
2021-11-18 22:05:49 +05:30
end
end