Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/tooling/danger')
-rw-r--r--spec/tooling/danger/outdated_todo_spec.rb135
-rw-r--r--spec/tooling/danger/project_helper_spec.rb5
2 files changed, 75 insertions, 65 deletions
diff --git a/spec/tooling/danger/outdated_todo_spec.rb b/spec/tooling/danger/outdated_todo_spec.rb
index 3a3909c69ac..3079c26bafc 100644
--- a/spec/tooling/danger/outdated_todo_spec.rb
+++ b/spec/tooling/danger/outdated_todo_spec.rb
@@ -15,69 +15,78 @@ RSpec.describe Tooling::Danger::OutdatedTodo, feature_category: :tooling do
]
end
- subject(:plugin) { described_class.new(filenames, context: fake_danger, todos: todos) }
-
- context 'when the filenames are mentioned in single todo' do
- let(:filenames) { ['app/controllers/acme_challenges_controller.rb'] }
-
- it 'warns about mentions' do
- expect(fake_danger)
- .to receive(:warn)
- .with <<~MESSAGE
- `app/controllers/acme_challenges_controller.rb` was removed but is mentioned in:
- - `spec/fixtures/tooling/danger/rubocop_todo/cop1.yml:5`
- MESSAGE
-
- plugin.check
- end
- end
-
- context 'when the filenames are mentioned in multiple todos' do
- let(:filenames) do
- [
- 'app/controllers/application_controller.rb',
- 'app/controllers/acme_challenges_controller.rb'
- ]
- end
-
- it 'warns about mentions' do
- expect(fake_danger)
- .to receive(:warn)
- .with(<<~FIRSTMESSAGE)
- `app/controllers/application_controller.rb` was removed but is mentioned in:
- - `spec/fixtures/tooling/danger/rubocop_todo/cop1.yml:4`
- - `spec/fixtures/tooling/danger/rubocop_todo/cop2.yml:4`
- FIRSTMESSAGE
-
- expect(fake_danger)
- .to receive(:warn)
- .with(<<~SECONDMESSAGE)
- `app/controllers/acme_challenges_controller.rb` was removed but is mentioned in:
- - `spec/fixtures/tooling/danger/rubocop_todo/cop1.yml:5`
- SECONDMESSAGE
-
- plugin.check
- end
- end
-
- context 'when the filenames are not mentioned in todos' do
- let(:filenames) { ['any/inexisting/file.rb'] }
-
- it 'does not warn' do
- expect(fake_danger).not_to receive(:warn)
-
- plugin.check
- end
- end
-
- context 'when there is no todos' do
- let(:filenames) { ['app/controllers/acme_challenges_controller.rb'] }
- let(:todos) { [] }
-
- it 'does not warn' do
- expect(fake_danger).not_to receive(:warn)
-
- plugin.check
+ subject(:plugin) { described_class.new(filenames, context: fake_danger, todos: todos, allow_fail: allow_fail) }
+
+ [true, false].each do |allow_failure|
+ context "with allow_fail set to #{allow_failure}" do
+ let(:allow_fail) { allow_failure }
+ let(:expected_method) do
+ allow_failure ? :fail : :warn
+ end
+
+ context 'when the filenames are mentioned in single todo' do
+ let(:filenames) { ['app/controllers/acme_challenges_controller.rb'] }
+
+ it 'warns about mentions' do
+ expect(fake_danger)
+ .to receive(expected_method)
+ .with <<~MESSAGE
+ `app/controllers/acme_challenges_controller.rb` was removed but is mentioned in:
+ - `spec/fixtures/tooling/danger/rubocop_todo/cop1.yml:5`
+ MESSAGE
+
+ plugin.check
+ end
+ end
+
+ context 'when the filenames are mentioned in multiple todos' do
+ let(:filenames) do
+ [
+ 'app/controllers/application_controller.rb',
+ 'app/controllers/acme_challenges_controller.rb'
+ ]
+ end
+
+ it 'warns about mentions' do
+ expect(fake_danger)
+ .to receive(expected_method)
+ .with(<<~FIRSTMESSAGE)
+ `app/controllers/application_controller.rb` was removed but is mentioned in:
+ - `spec/fixtures/tooling/danger/rubocop_todo/cop1.yml:4`
+ - `spec/fixtures/tooling/danger/rubocop_todo/cop2.yml:4`
+ FIRSTMESSAGE
+
+ expect(fake_danger)
+ .to receive(expected_method)
+ .with(<<~SECONDMESSAGE)
+ `app/controllers/acme_challenges_controller.rb` was removed but is mentioned in:
+ - `spec/fixtures/tooling/danger/rubocop_todo/cop1.yml:5`
+ SECONDMESSAGE
+
+ plugin.check
+ end
+ end
+
+ context 'when the filenames are not mentioned in todos' do
+ let(:filenames) { ['any/inexisting/file.rb'] }
+
+ it 'does not warn' do
+ expect(fake_danger).not_to receive(expected_method)
+
+ plugin.check
+ end
+ end
+
+ context 'when there is no todos' do
+ let(:filenames) { ['app/controllers/acme_challenges_controller.rb'] }
+ let(:todos) { [] }
+
+ it 'does not warn' do
+ expect(fake_danger).not_to receive(expected_method)
+
+ plugin.check
+ end
+ end
end
end
end
diff --git a/spec/tooling/danger/project_helper_spec.rb b/spec/tooling/danger/project_helper_spec.rb
index 2da90ddbd67..a41aba17f56 100644
--- a/spec/tooling/danger/project_helper_spec.rb
+++ b/spec/tooling/danger/project_helper_spec.rb
@@ -8,7 +8,7 @@ require 'gitlab/dangerfiles/spec_helper'
require_relative '../../../danger/plugins/project_helper'
-RSpec.describe Tooling::Danger::ProjectHelper do
+RSpec.describe Tooling::Danger::ProjectHelper, feature_category: :tooling do
include StubENV
include_context "with dangerfile"
@@ -130,6 +130,7 @@ RSpec.describe Tooling::Danger::ProjectHelper do
'lib/gitlab/background_migration.rb' | [:database, :backend]
'lib/gitlab/background_migration/foo' | [:database, :backend]
'ee/lib/gitlab/background_migration/foo' | [:database, :backend]
+ 'ee/lib/ee/gitlab/background_migration/foo' | [:database, :backend]
'lib/gitlab/database.rb' | [:database, :backend]
'lib/gitlab/database/foo' | [:database, :backend]
'ee/lib/gitlab/database/foo' | [:database, :backend]
@@ -238,7 +239,7 @@ RSpec.describe Tooling::Danger::ProjectHelper do
it { is_expected.to eq(expected_categories) }
end
- context 'having specific changes' do
+ context 'when having specific changes' do
where(:expected_categories, :patch, :changed_files) do
[:analytics_instrumentation] | '+data-track-action' | ['components/welcome.vue']
[:analytics_instrumentation] | '+ data: { track_label:' | ['admin/groups/_form.html.haml']