diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/lib/gitlab/danger | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/lib/gitlab/danger')
-rw-r--r-- | spec/lib/gitlab/danger/changelog_spec.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/danger/helper_spec.rb | 65 | ||||
-rw-r--r-- | spec/lib/gitlab/danger/teammate_spec.rb | 13 |
3 files changed, 75 insertions, 11 deletions
diff --git a/spec/lib/gitlab/danger/changelog_spec.rb b/spec/lib/gitlab/danger/changelog_spec.rb index ba23c3828de..8929374fb87 100644 --- a/spec/lib/gitlab/danger/changelog_spec.rb +++ b/spec/lib/gitlab/danger/changelog_spec.rb @@ -86,14 +86,6 @@ describe Gitlab::Danger::Changelog do end end - describe '#presented_no_changelog_labels' do - subject { changelog.presented_no_changelog_labels } - - it 'returns the labels formatted' do - is_expected.to eq('~backstage, ~ci-build, ~meta') - end - end - describe '#ee_changelog?' do subject { changelog.ee_changelog? } diff --git a/spec/lib/gitlab/danger/helper_spec.rb b/spec/lib/gitlab/danger/helper_spec.rb index d5d582d7d6c..c2c881fd589 100644 --- a/spec/lib/gitlab/danger/helper_spec.rb +++ b/spec/lib/gitlab/danger/helper_spec.rb @@ -363,4 +363,69 @@ describe Gitlab::Danger::Helper do expect(helper).to be_security_mr end end + + describe '#mr_has_label?' do + it 'returns false when `gitlab_helper` is unavailable' do + expect(helper).to receive(:gitlab_helper).and_return(nil) + + expect(helper.mr_has_labels?('telemetry')).to be_falsey + end + + context 'when mr has labels' do + before do + mr_labels = ['telemetry', 'telemetry::reviewed'] + expect(fake_gitlab).to receive(:mr_labels).and_return(mr_labels) + end + + it 'returns true with a matched label' do + expect(helper.mr_has_labels?('telemetry')).to be_truthy + end + + it 'returns false with unmatched label' do + expect(helper.mr_has_labels?('database')).to be_falsey + end + + it 'returns true with an array of labels' do + expect(helper.mr_has_labels?(['telemetry', 'telemetry::reviewed'])).to be_truthy + end + + it 'returns true with multi arguments with matched labels' do + expect(helper.mr_has_labels?('telemetry', 'telemetry::reviewed')).to be_truthy + end + + it 'returns false with multi arguments with unmatched labels' do + expect(helper.mr_has_labels?('telemetry', 'telemetry::non existing')).to be_falsey + end + end + end + + describe '#labels_list' do + let(:labels) { ['telemetry', 'telemetry::reviewed'] } + + it 'composes the labels string' do + expect(helper.labels_list(labels)).to eq('~"telemetry", ~"telemetry::reviewed"') + end + + context 'when passing a separator' do + it 'composes the labels string with the given separator' do + expect(helper.labels_list(labels, sep: ' ')).to eq('~"telemetry" ~"telemetry::reviewed"') + end + end + + it 'returns empty string for empty array' do + expect(helper.labels_list([])).to eq('') + end + end + + describe '#prepare_labels_for_mr' do + it 'composes the labels string' do + mr_labels = ['telemetry', 'telemetry::reviewed'] + + expect(helper.prepare_labels_for_mr(mr_labels)).to eq('/label ~"telemetry" ~"telemetry::reviewed"') + end + + it 'returns empty string for empty array' do + expect(helper.prepare_labels_for_mr([])).to eq('') + end + end end diff --git a/spec/lib/gitlab/danger/teammate_spec.rb b/spec/lib/gitlab/danger/teammate_spec.rb index 570f4bd27cc..ea5aecbc597 100644 --- a/spec/lib/gitlab/danger/teammate_spec.rb +++ b/spec/lib/gitlab/danger/teammate_spec.rb @@ -163,6 +163,13 @@ describe Gitlab::Danger::Teammate do { message: 'OOO: massage' } | false { message: 'love it SOOO much' } | false { emoji: 'red_circle' } | false + { emoji: 'palm_tree' } | false + { emoji: 'beach' } | false + { emoji: 'beach_umbrella' } | false + { emoji: 'beach_with_umbrella' } | false + { emoji: nil } | true + { emoji: '' } | true + { emoji: 'dancer' } | true end with_them do @@ -175,9 +182,9 @@ describe Gitlab::Danger::Teammate do end it 'returns true if request fails' do - expect(Gitlab::Danger::RequestHelper).to receive(:http_get_json) - .twice - .and_raise(Gitlab::Danger::RequestHelper::HTTPError.new) + expect(Gitlab::Danger::RequestHelper) + .to receive(:http_get_json) + .and_raise(Gitlab::Danger::RequestHelper::HTTPError.new) expect(subject.available?).to be true end |