summaryrefslogtreecommitdiff
path: root/spec/tooling/danger
diff options
context:
space:
mode:
Diffstat (limited to 'spec/tooling/danger')
-rw-r--r--spec/tooling/danger/specs_spec.rb33
-rw-r--r--spec/tooling/danger/user_types_spec.rb56
2 files changed, 22 insertions, 67 deletions
diff --git a/spec/tooling/danger/specs_spec.rb b/spec/tooling/danger/specs_spec.rb
index dcc1f592062..422923827a8 100644
--- a/spec/tooling/danger/specs_spec.rb
+++ b/spec/tooling/danger/specs_spec.rb
@@ -245,15 +245,16 @@ RSpec.describe Tooling::Danger::Specs, feature_category: :tooling do
" let_it_be(:user) { create(:user) }",
" end",
" describe 'GET \"time_summary\"' do",
- " end"
- ]
- end
-
- let(:matching_lines) do
- [
- "+ RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController, feature_category: :planning_analytics do",
- "+RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do",
- "+ RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do"
+ " end",
+ " \n",
+ "RSpec.describe Projects :aggregate_failures,",
+ " feature_category: planning_analytics do",
+ " \n",
+ "RSpec.describe Epics :aggregate_failures,",
+ " ee: true do",
+ "\n",
+ "RSpec.describe Issues :aggregate_failures,",
+ " feature_category: :team_planning do"
]
end
@@ -264,14 +265,24 @@ RSpec.describe Tooling::Danger::Specs, feature_category: :tooling do
"+ let_it_be(:user) { create(:user) }",
"- end",
"+ describe 'GET \"time_summary\"' do",
- "+ RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do"
+ "+ RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do",
+ "+RSpec.describe Projects :aggregate_failures,",
+ "+ feature_category: planning_analytics do",
+ "+RSpec.describe Epics :aggregate_failures,",
+ "+ ee: true do",
+ "+RSpec.describe Issues :aggregate_failures,"
]
end
+ before do
+ allow(specs.helper).to receive(:changed_lines).with(filename).and_return(changed_lines)
+ end
+
it 'adds suggestions at the correct lines', :aggregate_failures do
[
{ suggested_line: "RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do", number: 5 },
- { suggested_line: " RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do", number: 10 }
+ { suggested_line: " RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do", number: 10 },
+ { suggested_line: "RSpec.describe Epics :aggregate_failures,", number: 19 }
].each do |test_case|
comment = format(template, suggested_line: test_case[:suggested_line])
diff --git a/spec/tooling/danger/user_types_spec.rb b/spec/tooling/danger/user_types_spec.rb
deleted file mode 100644
index 53556601212..00000000000
--- a/spec/tooling/danger/user_types_spec.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-# frozen_string_literal: true
-
-require 'gitlab-dangerfiles'
-require 'gitlab/dangerfiles/spec_helper'
-require_relative '../../../tooling/danger/user_types'
-
-RSpec.describe Tooling::Danger::UserTypes, feature_category: :subscription_cost_management do
- include_context 'with dangerfile'
-
- let(:fake_danger) { DangerSpecHelper.fake_danger.include(described_class) }
- let(:user_types) { fake_danger.new(helper: fake_helper) }
-
- describe 'changed files' do
- subject(:bot_user_types_change_warning) { user_types.bot_user_types_change_warning }
-
- before do
- allow(fake_helper).to receive(:modified_files).and_return(modified_files)
- allow(fake_helper).to receive(:changed_lines).and_return(changed_lines)
- end
-
- context 'when has_user_type.rb file is not impacted' do
- let(:modified_files) { ['app/models/concerns/importable.rb'] }
- let(:changed_lines) { ['+ANY_CHANGES'] }
-
- it "doesn't add any warnings" do
- expect(user_types).not_to receive(:warn)
-
- bot_user_types_change_warning
- end
- end
-
- context 'when the has_user_type.rb file is impacted' do
- let(:modified_files) { ['app/models/concerns/has_user_type.rb'] }
-
- context 'with BOT_USER_TYPES changes' do
- let(:changed_lines) { ['+BOT_USER_TYPES'] }
-
- it 'adds warning' do
- expect(user_types).to receive(:warn).with(described_class::BOT_USER_TYPES_CHANGED_WARNING)
-
- bot_user_types_change_warning
- end
- end
-
- context 'without BOT_USER_TYPES changes' do
- let(:changed_lines) { ['+OTHER_CHANGES'] }
-
- it "doesn't add any warnings" do
- expect(user_types).not_to receive(:warn)
-
- bot_user_types_change_warning
- end
- end
- end
- end
-end