diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 13:49:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 13:49:51 +0000 |
commit | 71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch) | |
tree | 6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /spec/tooling/danger/config_files_spec.rb | |
parent | a7253423e3403b8c08f8a161e5937e1488f5f407 (diff) | |
download | gitlab-ce-15.9.0-rc42.tar.gz |
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'spec/tooling/danger/config_files_spec.rb')
-rw-r--r-- | spec/tooling/danger/config_files_spec.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/spec/tooling/danger/config_files_spec.rb b/spec/tooling/danger/config_files_spec.rb index 88b327df63f..65edcabb817 100644 --- a/spec/tooling/danger/config_files_spec.rb +++ b/spec/tooling/danger/config_files_spec.rb @@ -13,7 +13,6 @@ RSpec.describe Tooling::Danger::ConfigFiles do let(:fake_danger) { DangerSpecHelper.fake_danger.include(described_class) } let(:fake_project_helper) { instance_double(Tooling::Danger::ProjectHelper) } - let(:matching_line) { "+ introduced_by_url:" } subject(:config_file) { fake_danger.new(helper: fake_helper) } @@ -22,29 +21,42 @@ RSpec.describe Tooling::Danger::ConfigFiles do end describe '#add_suggestion_for_missing_introduced_by_url' do - let(:file_lines) do + let(:file_diff) do [ - "---", - "name: about_some_new_flow", - "introduced_by_url: #{url}", - "rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/355909", - "milestone: '14.10'" + "+---", + "+name: about_some_new_flow", + "+introduced_by_url: #{url}", + "+rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/355909", + "+milestone: '14.10'" ] end + let(:file_lines) do + file_diff.map { |line| line.delete_prefix('+') } + end + let(:filename) { 'config/feature_flags/new_ff.yml' } + let(:mr_url) { 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/1' } before do allow(config_file.project_helper).to receive(:file_lines).and_return(file_lines) allow(config_file.helper).to receive(:added_files).and_return([filename]) - allow(config_file.helper).to receive(:mr_web_url).and_return(url) + allow(config_file.helper).to receive(:changed_lines).with(filename).and_return(file_diff) + allow(config_file.helper).to receive(:mr_web_url).and_return(mr_url) end context 'when config file has an empty introduced_by_url line' do let(:url) { '' } it 'adds suggestions at the correct line' do - expected_format = format(described_class::SUGGEST_INTRODUCED_BY_COMMENT, url: url) + template = <<~SUGGEST_COMMENT + ```suggestion + introduced_by_url: %<mr_url>s + ``` + SUGGEST_COMMENT + + expected_format = format(template, mr_url: mr_url) + expect(config_file).to receive(:markdown).with(expected_format, file: filename, line: 3) config_file.add_suggestion_for_missing_introduced_by_url |