diff options
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/ci/catalog/resources/versions_finder_spec.rb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/spec/finders/ci/catalog/resources/versions_finder_spec.rb b/spec/finders/ci/catalog/resources/versions_finder_spec.rb index b541b84f198..dbde77101ee 100644 --- a/spec/finders/ci/catalog/resources/versions_finder_spec.rb +++ b/spec/finders/ci/catalog/resources/versions_finder_spec.rb @@ -5,9 +5,10 @@ require 'spec_helper' RSpec.describe Ci::Catalog::Resources::VersionsFinder, feature_category: :pipeline_composition do include_context 'when there are catalog resources with versions' + let(:name) { nil } let(:sort) { nil } let(:latest) { nil } - let(:params) { { sort: sort, latest: latest }.compact } + let(:params) { { name: name, sort: sort, latest: latest }.compact } subject(:execute) { described_class.new([resource1, resource2], current_user, params).execute } @@ -18,7 +19,7 @@ RSpec.describe Ci::Catalog::Resources::VersionsFinder, feature_category: :pipeli new_user = create(:user) expect do - described_class.new([resource1, resource2, resource3], new_user, params).execute + described_class.new([resource1, resource2], new_user, params).execute end.not_to exceed_query_limit(control_count) end @@ -37,6 +38,23 @@ RSpec.describe Ci::Catalog::Resources::VersionsFinder, feature_category: :pipeli expect(execute).to match_array([v1_0, v1_1]) end + context 'with name parameter' do + let(:name) { 'v1.0' } + + it 'returns the version that matches the name' do + expect(execute.count).to eq(1) + expect(execute.first.name).to eq('v1.0') + end + + context 'when no version matches the name' do + let(:name) { 'does_not_exist' } + + it 'returns empty response' do + is_expected.to be_empty + end + end + end + context 'with sort parameter' do it 'returns versions ordered by released_at descending by default' do expect(execute).to eq([v1_1, v1_0]) |