Commit 18645920 authored by charlie ablett's avatar charlie ablett

Merge branch '221259-move-package-api-fixtures-to-core' into 'master'

Move package api fixture to core

See merge request gitlab-org/gitlab!36245
parents 071292b7 64915db3
...@@ -3,9 +3,15 @@ ...@@ -3,9 +3,15 @@
"required": ["id"], "required": ["id"],
"properties": { "properties": {
"id": { "type": "integer" }, "id": { "type": "integer" },
"merge_request": { "$ref": "../../../../../../../spec/fixtures/api/schemas/public_api/v4/merge_request_simple.json" }, "merge_request": {
"user": { "$ref": "../../../../../../../spec/fixtures/api/schemas/public_api/v4/user/basic.json" }, "$ref": "../../../../../../../spec/fixtures/api/schemas/public_api/v4/merge_request_simple.json"
"pipeline": { "$ref": "./pipeline.json" }, },
"user": {
"$ref": "../../../../../../../spec/fixtures/api/schemas/public_api/v4/user/basic.json"
},
"pipeline": {
"$ref": "../../../../../../../spec/fixtures/api/schemas/public_api/v4/pipeline.json"
},
"created_at": { "type": "date" }, "created_at": { "type": "date" },
"updated_at": { "type": "date" }, "updated_at": { "type": "date" },
"target_branch": { "type": "string" }, "target_branch": { "type": "string" },
......
...@@ -16,8 +16,8 @@ RSpec.describe ::Packages::Npm::PackagePresenter do ...@@ -16,8 +16,8 @@ RSpec.describe ::Packages::Npm::PackagePresenter do
context 'for packages without dependencies' do context 'for packages without dependencies' do
it { is_expected.to be_a(Hash) } it { is_expected.to be_a(Hash) }
it { expect(subject[package1.version]).to match_schema('public_api/v4/packages/npm_package_version', dir: 'ee') } it { expect(subject[package1.version]).to match_schema('public_api/v4/packages/npm_package_version') }
it { expect(subject[package2.version]).to match_schema('public_api/v4/packages/npm_package_version', dir: 'ee') } it { expect(subject[package2.version]).to match_schema('public_api/v4/packages/npm_package_version') }
described_class::NPM_VALID_DEPENDENCY_TYPES.each do |dependency_type| described_class::NPM_VALID_DEPENDENCY_TYPES.each do |dependency_type|
it { expect(subject.dig(package1.version, dependency_type)).to be nil } it { expect(subject.dig(package1.version, dependency_type)).to be nil }
...@@ -31,8 +31,8 @@ RSpec.describe ::Packages::Npm::PackagePresenter do ...@@ -31,8 +31,8 @@ RSpec.describe ::Packages::Npm::PackagePresenter do
end end
it { is_expected.to be_a(Hash) } it { is_expected.to be_a(Hash) }
it { expect(subject[package1.version]).to match_schema('public_api/v4/packages/npm_package_version', dir: 'ee') } it { expect(subject[package1.version]).to match_schema('public_api/v4/packages/npm_package_version') }
it { expect(subject[package2.version]).to match_schema('public_api/v4/packages/npm_package_version', dir: 'ee') } it { expect(subject[package2.version]).to match_schema('public_api/v4/packages/npm_package_version') }
described_class::NPM_VALID_DEPENDENCY_TYPES.each do |dependency_type| described_class::NPM_VALID_DEPENDENCY_TYPES.each do |dependency_type|
it { expect(subject.dig(package1.version, dependency_type.to_s)).to be_any } it { expect(subject.dig(package1.version, dependency_type.to_s)).to be_any }
end end
......
...@@ -592,12 +592,12 @@ RSpec.describe API::NpmPackages do ...@@ -592,12 +592,12 @@ RSpec.describe API::NpmPackages do
def expect_a_valid_package_response def expect_a_valid_package_response
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq('application/json') expect(response.media_type).to eq('application/json')
expect(response).to match_response_schema('public_api/v4/packages/npm_package', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/npm_package')
expect(json_response['name']).to eq(package.name) expect(json_response['name']).to eq(package.name)
expect(json_response['versions'][package.version]).to match_schema('public_api/v4/packages/npm_package_version', dir: 'ee') expect(json_response['versions'][package.version]).to match_schema('public_api/v4/packages/npm_package_version')
::Packages::Npm::PackagePresenter::NPM_VALID_DEPENDENCY_TYPES.each do |dependency_type| ::Packages::Npm::PackagePresenter::NPM_VALID_DEPENDENCY_TYPES.each do |dependency_type|
expect(json_response.dig('versions', package.version, dependency_type.to_s)).to be_any expect(json_response.dig('versions', package.version, dependency_type.to_s)).to be_any
end end
expect(json_response['dist-tags']).to match_schema('public_api/v4/packages/npm_package_tags', dir: 'ee') expect(json_response['dist-tags']).to match_schema('public_api/v4/packages/npm_package_tags')
end end
end end
...@@ -54,7 +54,7 @@ RSpec.describe API::PackageFiles do ...@@ -54,7 +54,7 @@ RSpec.describe API::PackageFiles do
get api(url, user) get api(url, user)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/packages/package_files', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/package_files')
end end
end end
......
...@@ -152,7 +152,7 @@ RSpec.describe API::ProjectPackages do ...@@ -152,7 +152,7 @@ RSpec.describe API::ProjectPackages do
subject subject
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/packages/package', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/package')
end end
it 'returns 404 when the package does not exist' do it 'returns 404 when the package does not exist' do
...@@ -194,7 +194,7 @@ RSpec.describe API::ProjectPackages do ...@@ -194,7 +194,7 @@ RSpec.describe API::ProjectPackages do
subject subject
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/packages/package', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/package')
end end
it_behaves_like 'no destroy url' it_behaves_like 'no destroy url'
...@@ -217,7 +217,7 @@ RSpec.describe API::ProjectPackages do ...@@ -217,7 +217,7 @@ RSpec.describe API::ProjectPackages do
get api(package_url, user) get api(package_url, user)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/packages/package_with_build', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/package_with_build')
end end
end end
end end
......
...@@ -13,7 +13,7 @@ RSpec.shared_examples 'Composer package index' do |user_type, status, add_member ...@@ -13,7 +13,7 @@ RSpec.shared_examples 'Composer package index' do |user_type, status, add_member
subject subject
expect(response).to have_gitlab_http_status(status) expect(response).to have_gitlab_http_status(status)
expect(response).to match_response_schema('packages/composer/index', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/composer/index')
end end
end end
end end
...@@ -24,7 +24,7 @@ RSpec.shared_examples 'Composer empty provider index' do |user_type, status, add ...@@ -24,7 +24,7 @@ RSpec.shared_examples 'Composer empty provider index' do |user_type, status, add
subject subject
expect(response).to have_gitlab_http_status(status) expect(response).to have_gitlab_http_status(status)
expect(response).to match_response_schema('packages/composer/provider', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/composer/provider')
expect(json_response['providers']).to eq({}) expect(json_response['providers']).to eq({})
end end
end end
...@@ -36,7 +36,7 @@ RSpec.shared_examples 'Composer provider index' do |user_type, status, add_membe ...@@ -36,7 +36,7 @@ RSpec.shared_examples 'Composer provider index' do |user_type, status, add_membe
subject subject
expect(response).to have_gitlab_http_status(status) expect(response).to have_gitlab_http_status(status)
expect(response).to match_response_schema('packages/composer/provider', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/composer/provider')
expect(json_response['providers']).to include(package.name) expect(json_response['providers']).to include(package.name)
end end
end end
...@@ -48,7 +48,7 @@ RSpec.shared_examples 'Composer package api request' do |user_type, status, add_ ...@@ -48,7 +48,7 @@ RSpec.shared_examples 'Composer package api request' do |user_type, status, add_
subject subject
expect(response).to have_gitlab_http_status(status) expect(response).to have_gitlab_http_status(status)
expect(response).to match_response_schema('packages/composer/package', dir: 'ee') expect(response).to match_response_schema('public_api/v4/packages/composer/package')
expect(json_response['packages']).to include(package.name) expect(json_response['packages']).to include(package.name)
expect(json_response['packages'][package.name]).to include(package.version) expect(json_response['packages'][package.name]).to include(package.version)
end end
......
...@@ -42,7 +42,7 @@ RSpec.shared_examples 'process nuget service index request' do |user_type, statu ...@@ -42,7 +42,7 @@ RSpec.shared_examples 'process nuget service index request' do |user_type, statu
subject subject
expect(response.media_type).to eq('application/json') expect(response.media_type).to eq('application/json')
expect(json_response).to match_schema('public_api/v4/packages/nuget/service_index', dir: 'ee') expect(json_response).to match_schema('public_api/v4/packages/nuget/service_index')
expect(json_response).to be_a(Hash) expect(json_response).to be_a(Hash)
end end
...@@ -59,7 +59,7 @@ RSpec.shared_examples 'returning nuget metadata json response with json schema' ...@@ -59,7 +59,7 @@ RSpec.shared_examples 'returning nuget metadata json response with json schema'
subject subject
expect(response.media_type).to eq('application/json') expect(response.media_type).to eq('application/json')
expect(json_response).to match_schema(json_schema, dir: 'ee') expect(json_response).to match_schema(json_schema)
expect(json_response).to be_a(Hash) expect(json_response).to be_a(Hash)
end end
end end
...@@ -256,7 +256,7 @@ RSpec.shared_examples 'process nuget download versions request' do |user_type, s ...@@ -256,7 +256,7 @@ RSpec.shared_examples 'process nuget download versions request' do |user_type, s
subject subject
expect(response.media_type).to eq('application/json') expect(response.media_type).to eq('application/json')
expect(json_response).to match_schema('public_api/v4/packages/nuget/download_versions', dir: 'ee') expect(json_response).to match_schema('public_api/v4/packages/nuget/download_versions')
expect(json_response).to be_a(Hash) expect(json_response).to be_a(Hash)
expect(json_response['versions']).to match_array(packages.map(&:version).sort) expect(json_response['versions']).to match_array(packages.map(&:version).sort)
end end
...@@ -332,7 +332,7 @@ RSpec.shared_examples 'process nuget search request' do |user_type, status, add_ ...@@ -332,7 +332,7 @@ RSpec.shared_examples 'process nuget search request' do |user_type, status, add_
expect(response.media_type).to eq('application/json') expect(response.media_type).to eq('application/json')
expect(json_response).to be_a(Hash) expect(json_response).to be_a(Hash)
expect(json_response).to match_schema('public_api/v4/packages/nuget/search', dir: 'ee') expect(json_response).to match_schema('public_api/v4/packages/nuget/search')
expect(json_response['totalHits']).to eq total_hits expect(json_response['totalHits']).to eq total_hits
expect(json_response['data'].map { |e| e['versions'].size }).to match_array(versions) expect(json_response['data'].map { |e| e['versions'].size }).to match_array(versions)
end end
......
...@@ -30,7 +30,7 @@ RSpec.shared_examples 'returns package tags' do |user_type| ...@@ -30,7 +30,7 @@ RSpec.shared_examples 'returns package tags' do |user_type|
it 'returns two package tags' do it 'returns two package tags' do
subject subject
expect(json_response).to match_schema('public_api/v4/packages/npm_package_tags', dir: 'ee') expect(json_response).to match_schema('public_api/v4/packages/npm_package_tags')
expect(json_response.length).to eq(3) # two tags + latest (auto added) expect(json_response.length).to eq(3) # two tags + latest (auto added)
expect(json_response[package_tag1.name]).to eq(package.version) expect(json_response[package_tag1.name]).to eq(package.version)
expect(json_response[package_tag2.name]).to eq(package.version) expect(json_response[package_tag2.name]).to eq(package.version)
......
...@@ -29,7 +29,7 @@ RSpec.shared_examples 'returns packages' do |container_type, user_type| ...@@ -29,7 +29,7 @@ RSpec.shared_examples 'returns packages' do |container_type, user_type|
it 'returns a valid response schema' do it 'returns a valid response schema' do
subject subject
expect(response).to match_response_schema(package_schema, dir: 'ee') expect(response).to match_response_schema(package_schema)
end end
it 'returns two packages' do it 'returns two packages' do
...@@ -56,7 +56,7 @@ RSpec.shared_examples 'returns packages with subgroups' do |container_type, user ...@@ -56,7 +56,7 @@ RSpec.shared_examples 'returns packages with subgroups' do |container_type, user
it 'returns a valid response schema' do it 'returns a valid response schema' do
subject subject
expect(response).to match_response_schema(package_schema, dir: 'ee') expect(response).to match_response_schema(package_schema)
end end
it 'returns three packages' do it 'returns three packages' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment