diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-10 18:09:02 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-10 18:09:02 +0000 |
commit | 577bb49691b11bc8ebae3a4966153ed39af60d87 (patch) | |
tree | c34970de0f1fc58463448da0f34be13a2f3f47f9 /spec/services/repositories/changelog_service_spec.rb | |
parent | 6cffe9ea21d0974ebd3c544a3b711ffcd35649e2 (diff) | |
download | gitlab-ce-577bb49691b11bc8ebae3a4966153ed39af60d87.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/repositories/changelog_service_spec.rb')
-rw-r--r-- | spec/services/repositories/changelog_service_spec.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/services/repositories/changelog_service_spec.rb b/spec/services/repositories/changelog_service_spec.rb index 1ecf45bcd16..a545b0f070a 100644 --- a/spec/services/repositories/changelog_service_spec.rb +++ b/spec/services/repositories/changelog_service_spec.rb @@ -67,6 +67,62 @@ RSpec.describe Repositories::ChangelogService do end end + describe '#start_of_commit_range' do + let(:project) { build_stubbed(:project) } + let(:user) { build_stubbed(:user) } + + context 'when the "from" argument is specified' do + it 'returns the value of the argument' do + service = described_class + .new(project, user, version: '1.0.0', from: 'foo', to: 'bar') + + expect(service.start_of_commit_range).to eq('foo') + end + end + + context 'when the "from" argument is unspecified' do + it 'returns the tag commit of the previous version' do + service = described_class + .new(project, user, version: '1.0.0', to: 'bar') + + finder_spy = instance_spy(Repositories::PreviousTagFinder) + tag = double(:tag, target_commit: double(:commit, id: '123')) + + allow(Repositories::PreviousTagFinder) + .to receive(:new) + .with(project) + .and_return(finder_spy) + + allow(finder_spy) + .to receive(:execute) + .with('1.0.0') + .and_return(tag) + + expect(service.start_of_commit_range).to eq('123') + end + + it 'raises an error when no tag is found' do + service = described_class + .new(project, user, version: '1.0.0', to: 'bar') + + finder_spy = instance_spy(Repositories::PreviousTagFinder) + + allow(Repositories::PreviousTagFinder) + .to receive(:new) + .with(project) + .and_return(finder_spy) + + allow(finder_spy) + .to receive(:execute) + .with('1.0.0') + .and_return(nil) + + expect { service.start_of_commit_range } + .to raise_error(Gitlab::Changelog::Error) + end + end + end + def create_commit(project, user, params) params = { start_branch: 'master', branch_name: 'master' }.merge(params) Files::MultiService.new(project, user, params).execute.fetch(:result) |