diff options
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r-- | spec/models/repository_spec.rb | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 7bad907cf90..d50c60774b4 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -66,35 +66,58 @@ RSpec.describe Repository do it { is_expected.not_to include('v1.0.0') } end - describe 'tags_sorted_by' do + describe '#tags_sorted_by' do let(:tags_to_compare) { %w[v1.0.0 v1.1.0] } - let(:feature_flag) { true } - - before do - stub_feature_flags(tags_finder_gitaly: feature_flag) - end context 'name_desc' do subject { repository.tags_sorted_by('name_desc').map(&:name) & tags_to_compare } it { is_expected.to eq(['v1.1.0', 'v1.0.0']) } - - context 'when feature flag is disabled' do - let(:feature_flag) { false } - - it { is_expected.to eq(['v1.1.0', 'v1.0.0']) } - end end context 'name_asc' do - subject { repository.tags_sorted_by('name_asc').map(&:name) & tags_to_compare } + subject { repository.tags_sorted_by('name_asc', pagination_params).map(&:name) & tags_to_compare } + + let(:pagination_params) { nil } it { is_expected.to eq(['v1.0.0', 'v1.1.0']) } - context 'when feature flag is disabled' do - let(:feature_flag) { false } + context 'with pagination' do + context 'with limit' do + let(:pagination_params) { { limit: 1 } } + + it { is_expected.to eq(['v1.0.0']) } + end + + context 'with page token and limit' do + let(:pagination_params) { { page_token: 'refs/tags/v1.0.0', limit: 1 } } + + it { is_expected.to eq(['v1.1.0']) } + end - it { is_expected.to eq(['v1.0.0', 'v1.1.0']) } + context 'with page token only' do + let(:pagination_params) { { page_token: 'refs/tags/v1.0.0' } } + + it 'raises an ArgumentError' do + expect { subject }.to raise_error(ArgumentError) + end + end + + context 'with negative limit' do + let(:pagination_params) { { limit: -1 } } + + it 'returns all tags' do + is_expected.to eq(['v1.0.0', 'v1.1.0']) + end + end + + context 'with unknown token' do + let(:pagination_params) { { page_token: 'unknown' } } + + it 'raises an ArgumentError' do + expect { subject }.to raise_error(ArgumentError) + end + end end end @@ -113,24 +136,12 @@ RSpec.describe Repository do subject { repository.tags_sorted_by('updated_desc').map(&:name) & (tags_to_compare + [latest_tag]) } it { is_expected.to eq([latest_tag, 'v1.1.0', 'v1.0.0']) } - - context 'when feature flag is disabled' do - let(:feature_flag) { false } - - it { is_expected.to eq([latest_tag, 'v1.1.0', 'v1.0.0']) } - end end context 'asc' do subject { repository.tags_sorted_by('updated_asc').map(&:name) & (tags_to_compare + [latest_tag]) } it { is_expected.to eq(['v1.0.0', 'v1.1.0', latest_tag]) } - - context 'when feature flag is disabled' do - let(:feature_flag) { false } - - it { is_expected.to eq(['v1.0.0', 'v1.1.0', latest_tag]) } - end end context 'annotated tag pointing to a blob' do @@ -147,12 +158,6 @@ RSpec.describe Repository do it { is_expected.to eq(['v1.0.0', 'v1.1.0', annotated_tag_name]) } - context 'when feature flag is disabled' do - let(:feature_flag) { false } - - it { is_expected.to eq(['v1.0.0', 'v1.1.0', annotated_tag_name]) } - end - after do rugged_repo(repository).tags.delete(annotated_tag_name) end @@ -163,12 +168,6 @@ RSpec.describe Repository do subject { repository.tags_sorted_by('unknown_desc').map(&:name) & tags_to_compare } it { is_expected.to eq(['v1.0.0', 'v1.1.0']) } - - context 'when feature flag is disabled' do - let(:feature_flag) { false } - - it { is_expected.to eq(['v1.0.0', 'v1.1.0']) } - end end end |