Commit 1503495e authored by James Lopez's avatar James Lopez

Merge branch 'rc/fix_leaky_constants_3' into 'master'

Fixes for RSpec/LeakyConstantDeclaration cop

See merge request gitlab-org/gitlab!28483
parents fcffcf1b e1a8bc28
...@@ -329,13 +329,6 @@ RSpec/LeakyConstantDeclaration: ...@@ -329,13 +329,6 @@ RSpec/LeakyConstantDeclaration:
Exclude: Exclude:
- 'spec/**/*.rb' - 'spec/**/*.rb'
- 'qa/spec/**/*.rb' - 'qa/spec/**/*.rb'
- 'ee/spec/presenters/security/vulnerable_project_presenter_spec.rb'
- 'ee/spec/serializers/vulnerable_project_entity_spec.rb'
- 'ee/spec/services/clusters/applications/check_upgrade_progress_service_spec.rb'
- 'ee/spec/services/dashboard/projects/list_service_spec.rb'
- 'ee/spec/services/metrics/dashboard/clone_dashboard_service_spec.rb'
- 'ee/spec/support/shared_contexts/epic_aggregate_constants.rb'
- 'ee/spec/workers/elastic_namespace_rollout_worker_spec.rb'
RSpec/EmptyLineAfterHook: RSpec/EmptyLineAfterHook:
Enabled: false Enabled: false
......
...@@ -28,8 +28,8 @@ describe Gitlab::Graphql::Aggregations::Epics::EpicNode do ...@@ -28,8 +28,8 @@ describe Gitlab::Graphql::Aggregations::Epics::EpicNode do
end end
end end
it_behaves_like 'setting attributes based on the first record', { epic_state_id: OPENED_EPIC_STATE, parent_id: nil } it_behaves_like 'setting attributes based on the first record', { epic_state_id: Gitlab::Graphql::Aggregations::Epics::Constants::OPENED_EPIC_STATE, parent_id: nil }
it_behaves_like 'setting attributes based on the first record', { epic_state_id: CLOSED_EPIC_STATE, parent_id: 2 } it_behaves_like 'setting attributes based on the first record', { epic_state_id: Gitlab::Graphql::Aggregations::Epics::Constants::CLOSED_EPIC_STATE, parent_id: 2 }
end end
describe 'recursive totals' do describe 'recursive totals' do
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe Security::VulnerableProjectPresenter do describe Security::VulnerableProjectPresenter do
SEVERITY_LEVELS = ::Vulnerabilities::Occurrence::SEVERITY_LEVELS.keys
let(:project) { create(:project) } let(:project) { create(:project) }
before do before do
...@@ -17,7 +15,7 @@ describe Security::VulnerableProjectPresenter do ...@@ -17,7 +15,7 @@ describe Security::VulnerableProjectPresenter do
expect(subject.id).to be(project.id) expect(subject.id).to be(project.id)
end end
SEVERITY_LEVELS.each do |severity_level| ::Vulnerabilities::Occurrence::SEVERITY_LEVELS.keys.each do |severity_level|
it "exposes a vulnerability count attribute for #{severity_level} vulnerabilities" do it "exposes a vulnerability count attribute for #{severity_level} vulnerabilities" do
expect(subject.public_send("#{severity_level}_vulnerability_count")).to be(1) expect(subject.public_send("#{severity_level}_vulnerability_count")).to be(1)
end end
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe VulnerableProjectEntity do describe VulnerableProjectEntity do
SEVERITY_LEVELS = ::Vulnerabilities::Occurrence::SEVERITY_LEVELS.keys
let(:project) { create(:project) } let(:project) { create(:project) }
let(:vulnerable_project) { ::Security::VulnerableProjectPresenter.new(project) } let(:vulnerable_project) { ::Security::VulnerableProjectPresenter.new(project) }
...@@ -14,7 +12,7 @@ describe VulnerableProjectEntity do ...@@ -14,7 +12,7 @@ describe VulnerableProjectEntity do
subject { described_class.new(vulnerable_project) } subject { described_class.new(vulnerable_project) }
SEVERITY_LEVELS.each do |severity_level| ::Vulnerabilities::Occurrence::SEVERITY_LEVELS.keys.each do |severity_level|
it "exposes a vulnerability count attribute for #{severity_level} vulnerabilities" do it "exposes a vulnerability count attribute for #{severity_level} vulnerabilities" do
expect(subject.as_json["#{severity_level}_vulnerability_count".to_sym]).to be(2) expect(subject.as_json["#{severity_level}_vulnerability_count".to_sym]).to be(2)
end end
......
...@@ -3,14 +3,11 @@ ...@@ -3,14 +3,11 @@
require 'spec_helper' require 'spec_helper'
describe Dashboard::Projects::ListService do describe Dashboard::Projects::ListService do
PUBLIC = Gitlab::VisibilityLevel::PUBLIC
PRIVATE = Gitlab::VisibilityLevel::PRIVATE
let!(:license) { create(:license, plan: License::ULTIMATE_PLAN) } let!(:license) { create(:license, plan: License::ULTIMATE_PLAN) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, namespace: namespace, visibility_level: PRIVATE) } let(:project) { create(:project, namespace: namespace, visibility_level: Gitlab::VisibilityLevel::PRIVATE) }
let(:namespace) { create(:namespace, visibility_level: PRIVATE) } let(:namespace) { create(:namespace, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let(:service) { described_class.new(user, feature: :operations_dashboard) } let(:service) { described_class.new(user, feature: :operations_dashboard) }
describe '#execute' do describe '#execute' do
...@@ -131,14 +128,17 @@ describe Dashboard::Projects::ListService do ...@@ -131,14 +128,17 @@ describe Dashboard::Projects::ListService do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
where(:check_namespace_plan, :project_visibility, :namespace_visibility, :available) do where(:check_namespace_plan, :project_visibility, :namespace_visibility, :available) do
true | PUBLIC | PUBLIC | true public_visibility = Gitlab::VisibilityLevel::PUBLIC
true | PRIVATE | PUBLIC | false private_visibility = Gitlab::VisibilityLevel::PRIVATE
true | PUBLIC | PRIVATE | false
true | PRIVATE | PRIVATE | false true | public_visibility | public_visibility | true
false | PUBLIC | PUBLIC | true true | private_visibility | public_visibility | false
false | PRIVATE | PUBLIC | true true | public_visibility | private_visibility | false
false | PUBLIC | PRIVATE | true true | private_visibility | private_visibility | false
false | PRIVATE | PRIVATE | true false | public_visibility | public_visibility | true
false | private_visibility | public_visibility | true
false | public_visibility | private_visibility | true
false | private_visibility | private_visibility | true
end end
with_them do with_them do
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe Metrics::Dashboard::CloneDashboardService, :use_clean_rails_memory_store_caching do describe Metrics::Dashboard::CloneDashboardService, :use_clean_rails_memory_store_caching do
STAGES = ::Gitlab::Metrics::Dashboard::Stages
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:environment) { create(:environment, project: project) } let_it_be(:environment) { create(:environment, project: project) }
...@@ -30,9 +28,20 @@ describe Metrics::Dashboard::CloneDashboardService, :use_clean_rails_memory_stor ...@@ -30,9 +28,20 @@ describe Metrics::Dashboard::CloneDashboardService, :use_clean_rails_memory_stor
branch: branch branch: branch
} }
end end
let(:stages) { ::Gitlab::Metrics::Dashboard::Stages }
it_behaves_like 'valid dashboard cloning process', ::Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH,
[
::Gitlab::Metrics::Dashboard::Stages::CommonMetricsInserter,
::Gitlab::Metrics::Dashboard::Stages::CustomMetricsInserter,
::Gitlab::Metrics::Dashboard::Stages::Sorter
]
it_behaves_like 'valid dashboard cloning process', ::Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH, [STAGES::CommonMetricsInserter, STAGES::CustomMetricsInserter, STAGES::Sorter] it_behaves_like 'valid dashboard cloning process', ::Metrics::Dashboard::ClusterDashboardService::DASHBOARD_PATH,
it_behaves_like 'valid dashboard cloning process', ::Metrics::Dashboard::ClusterDashboardService::DASHBOARD_PATH, [STAGES::CommonMetricsInserter, STAGES::Sorter] [
::Gitlab::Metrics::Dashboard::Stages::CommonMetricsInserter,
::Gitlab::Metrics::Dashboard::Stages::Sorter
]
end end
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
shared_context 'includes EpicAggregate constants' do shared_context 'includes EpicAggregate constants' do
EPIC_TYPE = Gitlab::Graphql::Aggregations::Epics::Constants::EPIC_TYPE before do
ISSUE_TYPE = Gitlab::Graphql::Aggregations::Epics::Constants::ISSUE_TYPE stub_const('EPIC_TYPE', Gitlab::Graphql::Aggregations::Epics::Constants::EPIC_TYPE)
stub_const('ISSUE_TYPE', Gitlab::Graphql::Aggregations::Epics::Constants::ISSUE_TYPE)
OPENED_EPIC_STATE = Gitlab::Graphql::Aggregations::Epics::Constants::OPENED_EPIC_STATE stub_const('OPENED_EPIC_STATE', Gitlab::Graphql::Aggregations::Epics::Constants::OPENED_EPIC_STATE)
CLOSED_EPIC_STATE = Gitlab::Graphql::Aggregations::Epics::Constants::CLOSED_EPIC_STATE stub_const('CLOSED_EPIC_STATE', Gitlab::Graphql::Aggregations::Epics::Constants::CLOSED_EPIC_STATE)
OPENED_ISSUE_STATE = Gitlab::Graphql::Aggregations::Epics::Constants::OPENED_ISSUE_STATE stub_const('OPENED_ISSUE_STATE', Gitlab::Graphql::Aggregations::Epics::Constants::OPENED_ISSUE_STATE)
CLOSED_ISSUE_STATE = Gitlab::Graphql::Aggregations::Epics::Constants::CLOSED_ISSUE_STATE stub_const('CLOSED_ISSUE_STATE', Gitlab::Graphql::Aggregations::Epics::Constants::CLOSED_ISSUE_STATE)
WEIGHT_SUM = Gitlab::Graphql::Aggregations::Epics::Constants::WEIGHT_SUM stub_const('WEIGHT_SUM', Gitlab::Graphql::Aggregations::Epics::Constants::WEIGHT_SUM)
COUNT = Gitlab::Graphql::Aggregations::Epics::Constants::COUNT stub_const('COUNT', Gitlab::Graphql::Aggregations::Epics::Constants::COUNT)
end
end end
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
require 'spec_helper' require 'spec_helper'
describe ElasticNamespaceRolloutWorker do describe ElasticNamespaceRolloutWorker do
ROLLOUT = described_class::ROLLOUT before do
ROLLBACK = described_class::ROLLBACK stub_const('ROLLOUT', described_class::ROLLOUT)
stub_const('ROLLBACK', described_class::ROLLBACK)
end
Plan::PAID_HOSTED_PLANS.each do |plan| Plan::PAID_HOSTED_PLANS.each do |plan|
plan_factory = "#{plan}_plan" plan_factory = "#{plan}_plan"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment