diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-03 18:07:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-03 18:07:07 +0300 |
commit | 9a1c5456747a7b5b218b8b44e4b43396bf7fd705 (patch) | |
tree | dc5873f33437c897389e923a59365fb192d87fb8 /spec/lib/gitlab/git | |
parent | 927cfbfe63dd3dc64df9d341d7c4328a2fe3597f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/git')
-rw-r--r-- | spec/lib/gitlab/git/changes_spec.rb | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git/changes_spec.rb b/spec/lib/gitlab/git/changes_spec.rb new file mode 100644 index 00000000000..7f56d30cb48 --- /dev/null +++ b/spec/lib/gitlab/git/changes_spec.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Git::Changes do + let(:changes) { described_class.new } + + describe '#includes_branches?' do + subject { changes.includes_branches? } + + context 'has changes for branches' do + before do + changes.add_branch_change(oldrev: 'abc123', newrev: 'def456', ref: 'branch') + end + + it { is_expected.to be_truthy } + end + + context 'has no changes for branches' do + before do + changes.add_tag_change(oldrev: 'abc123', newrev: 'def456', ref: 'tag') + end + + it { is_expected.to be_falsey } + end + end + + describe '#includes_tags?' do + subject { changes.includes_tags? } + + context 'has changes for tags' do + before do + changes.add_tag_change(oldrev: 'abc123', newrev: 'def456', ref: 'tag') + end + + it { is_expected.to be_truthy } + end + + context 'has no changes for tags' do + before do + changes.add_branch_change(oldrev: 'abc123', newrev: 'def456', ref: 'branch') + end + + it { is_expected.to be_falsey } + end + end + + describe '#add_branch_change' do + let(:change) { { oldrev: 'abc123', newrev: 'def456', ref: 'branch' } } + + subject { changes.add_branch_change(change) } + + it 'adds the branch change to the collection' do + expect(subject).to include(change) + expect(subject.refs).to include(change[:ref]) + expect(subject.repository_data).to include(before: change[:oldrev], after: change[:newrev], ref: change[:ref]) + expect(subject.branch_changes).to include(change) + end + + it 'does not add the change as a tag change' do + expect(subject.tag_changes).not_to include(change) + end + end + + describe '#add_tag_change' do + let(:change) { { oldrev: 'abc123', newrev: 'def456', ref: 'tag' } } + + subject { changes.add_tag_change(change) } + + it 'adds the tag change to the collection' do + expect(subject).to include(change) + expect(subject.refs).to include(change[:ref]) + expect(subject.repository_data).to include(before: change[:oldrev], after: change[:newrev], ref: change[:ref]) + expect(subject.tag_changes).to include(change) + end + + it 'does not add the change as a branch change' do + expect(subject.branch_changes).not_to include(change) + end + end +end |