debian-mirror-gitlab/spec/requests/api/graphql/packages/composer_spec.rb

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

38 lines
1.2 KiB
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'package details' do
include GraphqlHelpers
2021-09-04 01:27:46 +05:30
include_context 'package details setup'
2021-06-08 01:23:25 +05:30
2022-10-11 01:57:18 +05:30
let_it_be(:package) { create(:composer_package, :last_downloaded_at, project: project) }
2021-06-08 01:23:25 +05:30
let_it_be(:composer_json) { { name: 'name', type: 'type', license: 'license', version: 1 } }
let_it_be(:composer_metadatum) do
# we are forced to manually create the metadatum, without using the factory to force the sha to be a string
# and avoid an error where gitaly can't find the repository
2021-09-04 01:27:46 +05:30
create(:composer_metadatum, package: package, target_sha: 'foo_sha', composer_json: composer_json)
2021-06-08 01:23:25 +05:30
end
let(:metadata) { query_graphql_fragment('ComposerMetadata') }
let(:package_files_response) { graphql_data_at(:package, :package_files, :nodes) }
subject { post_graphql(query, current_user: user) }
before do
subject
end
2021-09-04 01:27:46 +05:30
it_behaves_like 'a package detail'
2021-06-08 01:23:25 +05:30
2021-09-04 01:27:46 +05:30
it 'has the correct metadata' do
expect(metadata_response).to include(
'targetSha' => 'foo_sha',
'composerJson' => composer_json.transform_keys(&:to_s).transform_values(&:to_s)
)
end
2021-06-08 01:23:25 +05:30
2021-09-04 01:27:46 +05:30
it 'does not have files' do
expect(package_files_response).to be_empty
2021-06-08 01:23:25 +05:30
end
end