diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/lib/gitlab/danger/merge_request_linter_spec.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/lib/gitlab/danger/merge_request_linter_spec.rb')
-rw-r--r-- | spec/lib/gitlab/danger/merge_request_linter_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/lib/gitlab/danger/merge_request_linter_spec.rb b/spec/lib/gitlab/danger/merge_request_linter_spec.rb new file mode 100644 index 00000000000..29facc9fdd6 --- /dev/null +++ b/spec/lib/gitlab/danger/merge_request_linter_spec.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' +require 'rspec-parameterized' +require_relative 'danger_spec_helper' + +require 'gitlab/danger/merge_request_linter' + +RSpec.describe Gitlab::Danger::MergeRequestLinter do + using RSpec::Parameterized::TableSyntax + + let(:mr_class) do + Struct.new(:message, :sha, :diff_parent) + end + + let(:mr_title) { 'A B ' + 'C' } + let(:merge_request) { mr_class.new(mr_title, anything, anything) } + + describe '#lint_subject' do + subject(:mr_linter) { described_class.new(merge_request) } + + shared_examples 'a valid mr title' do + it 'does not have any problem' do + mr_linter.lint + + expect(mr_linter.problems).to be_empty + end + end + + context 'when subject valid' do + it_behaves_like 'a valid mr title' + end + + context 'when it is too long' do + let(:mr_title) { 'A B ' + 'C' * described_class::MAX_LINE_LENGTH } + + it 'adds a problem' do + expect(mr_linter).to receive(:add_problem).with(:subject_too_long, described_class.subject_description) + + mr_linter.lint + end + end + + describe 'using magic mr run options' do + where(run_option: described_class.mr_run_options_regex.split('|') + + described_class.mr_run_options_regex.split('|').map! { |x| "[#{x}]" }) + + with_them do + let(:mr_title) { run_option + ' A B ' + 'C' * (described_class::MAX_LINE_LENGTH - 5) } + + it_behaves_like 'a valid mr title' + end + end + end +end |