diff options
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r-- | spec/models/repository_spec.rb | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 964cc5a13ca..a6b79e55f02 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -587,15 +587,19 @@ RSpec.describe Repository do end it "is expired when the branches caches are expired" do - expect(cache).to receive(:delete).with(:merged_branch_names).at_least(:once) + expect(cache).to receive(:delete) do |*args| + expect(args).to include(:merged_branch_names) + end - repository.send(:expire_branches_cache) + repository.expire_branches_cache end it "is expired when the repository caches are expired" do - expect(cache).to receive(:delete).with(:merged_branch_names).at_least(:once) + expect(cache).to receive(:delete) do |*args| + expect(args).to include(:merged_branch_names) + end - repository.send(:expire_all_method_caches) + repository.expire_all_method_caches end end @@ -1245,6 +1249,32 @@ RSpec.describe Repository do end end + describe '#has_ambiguous_refs?' do + using RSpec::Parameterized::TableSyntax + + where(:branch_names, :tag_names, :result) do + nil | nil | false + %w() | %w() | false + %w(a b) | %w() | false + %w() | %w(c d) | false + %w(a b) | %w(c d) | false + %w(a/b) | %w(c/d) | false + %w(a b) | %w(c d a/z) | true + %w(a b c/z) | %w(c d) | true + %w(a/b/z) | %w(a/b) | false # we only consider refs ambiguous before the first slash + %w(a/b/z) | %w(a/b a) | true + end + + with_them do + it do + allow(repository).to receive(:branch_names).and_return(branch_names) + allow(repository).to receive(:tag_names).and_return(tag_names) + + expect(repository.has_ambiguous_refs?).to eq(result) + end + end + end + describe '#expand_ref' do let(:ref) { 'ref' } @@ -1926,8 +1956,9 @@ RSpec.describe Repository do :has_visible_content?, :issue_template_names, :merge_request_template_names, - :metrics_dashboard_paths, - :xcode_project? + :user_defined_metrics_dashboard_paths, + :xcode_project?, + :has_ambiguous_refs? ]) repository.after_change_head @@ -2072,7 +2103,7 @@ RSpec.describe Repository do describe '#expire_branches_cache' do it 'expires the cache' do expect(repository).to receive(:expire_method_caches) - .with(%i(branch_names merged_branch_names branch_count has_visible_content?)) + .with(%i(branch_names merged_branch_names branch_count has_visible_content? has_ambiguous_refs?)) .and_call_original repository.expire_branches_cache @@ -2082,7 +2113,7 @@ RSpec.describe Repository do describe '#expire_tags_cache' do it 'expires the cache' do expect(repository).to receive(:expire_method_caches) - .with(%i(tag_names tag_count)) + .with(%i(tag_names tag_count has_ambiguous_refs?)) .and_call_original repository.expire_tags_cache @@ -2673,6 +2704,7 @@ RSpec.describe Repository do build(:commit, author: author_c), build(:commit, author: author_c)] end + let(:order_by) { nil } let(:sort) { nil } |