diff options
Diffstat (limited to 'spec/lib/gitlab/danger/helper_spec.rb')
-rw-r--r-- | spec/lib/gitlab/danger/helper_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/lib/gitlab/danger/helper_spec.rb b/spec/lib/gitlab/danger/helper_spec.rb index f400641706d..a8f113a8cd1 100644 --- a/spec/lib/gitlab/danger/helper_spec.rb +++ b/spec/lib/gitlab/danger/helper_spec.rb @@ -33,6 +33,16 @@ RSpec.describe Gitlab::Danger::Helper do expect(helper.gitlab_helper).to eq(fake_gitlab) end end + + context 'when danger gitlab plugin is not available' do + it 'returns nil' do + invalid_danger = Class.new do + include Gitlab::Danger::Helper + end.new + + expect(invalid_danger.gitlab_helper).to be_nil + end + end end describe '#release_automation?' do @@ -591,4 +601,30 @@ RSpec.describe Gitlab::Danger::Helper do expect(helper.prepare_labels_for_mr([])).to eq('') end end + + describe '#has_ci_changes?' do + context 'when .gitlab/ci is changed' do + it 'returns true' do + expect(helper).to receive(:all_changed_files).and_return(%w[migration.rb .gitlab/ci/test.yml]) + + expect(helper.has_ci_changes?).to be_truthy + end + end + + context 'when .gitlab-ci.yml is changed' do + it 'returns true' do + expect(helper).to receive(:all_changed_files).and_return(%w[migration.rb .gitlab-ci.yml]) + + expect(helper.has_ci_changes?).to be_truthy + end + end + + context 'when neither .gitlab/ci/ or .gitlab-ci.yml is changed' do + it 'returns false' do + expect(helper).to receive(:all_changed_files).and_return(%w[migration.rb nested/.gitlab-ci.yml]) + + expect(helper.has_ci_changes?).to be_falsey + end + end + end end |