diff options
Diffstat (limited to 'spec/lib/gitlab/danger/helper_spec.rb')
-rw-r--r-- | spec/lib/gitlab/danger/helper_spec.rb | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/spec/lib/gitlab/danger/helper_spec.rb b/spec/lib/gitlab/danger/helper_spec.rb index e5018e46634..c7d55c396ef 100644 --- a/spec/lib/gitlab/danger/helper_spec.rb +++ b/spec/lib/gitlab/danger/helper_spec.rb @@ -76,6 +76,30 @@ RSpec.describe Gitlab::Danger::Helper do end end + describe '#changed_lines' do + subject { helper.changed_lines('changed_file.rb') } + + before do + allow(fake_git).to receive(:diff_for_file).with('changed_file.rb').and_return(diff) + end + + context 'when file has diff' do + let(:diff) { double(:diff, patch: "+ # New change here\n+ # New change there") } + + it 'returns file changes' do + is_expected.to eq(['+ # New change here', '+ # New change there']) + end + end + + context 'when file has no diff (renamed without changes)' do + let(:diff) { nil } + + it 'returns a blank array' do + is_expected.to eq([]) + end + end + end + describe "changed_files" do it 'returns list of changed files matching given regex' do expect(helper).to receive(:all_changed_files).and_return(%w[migration.rb usage_data.rb]) @@ -371,22 +395,6 @@ RSpec.describe Gitlab::Danger::Helper do end end - describe '#missing_database_labels' do - subject { helper.missing_database_labels(current_mr_labels) } - - context 'when current merge request has ~database::review pending' do - let(:current_mr_labels) { ['database::review pending', 'feature'] } - - it { is_expected.to match_array(['database']) } - end - - context 'when current merge request does not have ~database::review pending' do - let(:current_mr_labels) { ['feature'] } - - it { is_expected.to match_array(['database', 'database::review pending']) } - end - end - describe '#sanitize_mr_title' do where(:mr_title, :expected_mr_title) do 'My MR title' | 'My MR title' |