diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-29 12:08:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-29 12:08:45 +0300 |
commit | c3fe9f52152cd57f6790d30efc2d5e4b9dbf54dd (patch) | |
tree | af0e47e4d4ff68e36ed2c79c993096668ecb4966 /spec/services | |
parent | bceef0b492c1f4bc15c21c70cbe7aef34385a3da (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/releases/links/params_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/services/releases/links/params_spec.rb b/spec/services/releases/links/params_spec.rb new file mode 100644 index 00000000000..580bddf4fd9 --- /dev/null +++ b/spec/services/releases/links/params_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Releases::Links::Params, feature_category: :release_orchestration do + subject(:filter) { described_class.new(params) } + + let(:params) { { name: name, url: url, direct_asset_path: direct_asset_path, link_type: link_type, unknown: '?' } } + let(:name) { 'link' } + let(:url) { 'https://example.com' } + let(:direct_asset_path) { '/path' } + let(:link_type) { 'other' } + + describe '#allowed_params' do + subject { filter.allowed_params } + + it 'returns only allowed params' do + is_expected.to eq('name' => name, 'url' => url, 'filepath' => direct_asset_path, 'link_type' => link_type) + end + + context 'when deprecated filepath is used' do + let(:params) { super().merge(direct_asset_path: nil, filepath: 'filepath') } + + it 'uses filepath value' do + is_expected.to eq('name' => name, 'url' => url, 'filepath' => 'filepath', 'link_type' => link_type) + end + end + + context 'when both direct_asset_path and filepath are provided' do + let(:params) { super().merge(filepath: 'filepath') } + + it 'uses direct_asset_path value' do + is_expected.to eq('name' => name, 'url' => url, 'filepath' => direct_asset_path, 'link_type' => link_type) + end + end + end +end |