diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/finders/repositories | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/finders/repositories')
-rw-r--r-- | spec/finders/repositories/commits_with_trailer_finder_spec.rb | 38 | ||||
-rw-r--r-- | spec/finders/repositories/previous_tag_finder_spec.rb | 41 |
2 files changed, 79 insertions, 0 deletions
diff --git a/spec/finders/repositories/commits_with_trailer_finder_spec.rb b/spec/finders/repositories/commits_with_trailer_finder_spec.rb new file mode 100644 index 00000000000..0c457aae340 --- /dev/null +++ b/spec/finders/repositories/commits_with_trailer_finder_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Repositories::CommitsWithTrailerFinder do + let(:project) { create(:project, :repository) } + + describe '#each_page' do + it 'only yields commits with the given trailer' do + finder = described_class.new( + project: project, + from: '570e7b2abdd848b95f2f578043fc23bd6f6fd24d', + to: 'c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd' + ) + + commits = finder.each_page('Signed-off-by').to_a.flatten + + expect(commits.length).to eq(1) + expect(commits.first.id).to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e') + expect(commits.first.trailers).to eq( + 'Signed-off-by' => 'Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>' + ) + end + + it 'supports paginating of commits' do + finder = described_class.new( + project: project, + from: 'c1acaa58bbcbc3eafe538cb8274ba387047b69f8', + to: '5937ac0a7beb003549fc5fd26fc247adbce4a52e', + per_page: 1 + ) + + commits = finder.each_page('Signed-off-by') + + expect(commits.count).to eq(4) + end + end +end diff --git a/spec/finders/repositories/previous_tag_finder_spec.rb b/spec/finders/repositories/previous_tag_finder_spec.rb new file mode 100644 index 00000000000..7cc33d11baf --- /dev/null +++ b/spec/finders/repositories/previous_tag_finder_spec.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Repositories::PreviousTagFinder do + let(:project) { build_stubbed(:project) } + let(:finder) { described_class.new(project) } + + describe '#execute' do + context 'when there is a previous tag' do + it 'returns the previous tag' do + tag1 = double(:tag1, name: 'v1.0.0') + tag2 = double(:tag2, name: 'v1.1.0') + tag3 = double(:tag3, name: 'v2.0.0') + tag4 = double(:tag4, name: '1.0.0') + + allow(project.repository) + .to receive(:tags) + .and_return([tag1, tag3, tag2, tag4]) + + expect(finder.execute('2.1.0')).to eq(tag3) + expect(finder.execute('2.0.0')).to eq(tag2) + expect(finder.execute('1.5.0')).to eq(tag2) + expect(finder.execute('1.0.1')).to eq(tag1) + end + end + + context 'when there is no previous tag' do + it 'returns nil' do + tag1 = double(:tag1, name: 'v1.0.0') + tag2 = double(:tag2, name: 'v1.1.0') + + allow(project.repository) + .to receive(:tags) + .and_return([tag1, tag2]) + + expect(finder.execute('1.0.0')).to be_nil + end + end + end +end |