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:
Exclude:
- '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:
Enabled: false
......
......@@ -28,8 +28,8 @@ describe Gitlab::Graphql::Aggregations::Epics::EpicNode do
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: CLOSED_EPIC_STATE, parent_id: 2 }
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: Gitlab::Graphql::Aggregations::Epics::Constants::CLOSED_EPIC_STATE, parent_id: 2 }
end
describe 'recursive totals' do
......
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe Security::VulnerableProjectPresenter do
SEVERITY_LEVELS = ::Vulnerabilities::Occurrence::SEVERITY_LEVELS.keys
let(:project) { create(:project) }
before do
......@@ -17,7 +15,7 @@ describe Security::VulnerableProjectPresenter do
expect(subject.id).to be(project.id)
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
expect(subject.public_send("#{severity_level}_vulnerability_count")).to be(1)
end
......
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe VulnerableProjectEntity do
SEVERITY_LEVELS = ::Vulnerabilities::Occurrence::SEVERITY_LEVELS.keys
let(:project) { create(:project) }
let(:vulnerable_project) { ::Security::VulnerableProjectPresenter.new(project) }
......@@ -14,7 +12,7 @@ describe VulnerableProjectEntity do
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
expect(subject.as_json["#{severity_level}_vulnerability_count".to_sym]).to be(2)
end
......
......@@ -3,14 +3,11 @@
require 'spec_helper'
describe Dashboard::Projects::ListService do
PUBLIC = Gitlab::VisibilityLevel::PUBLIC
PRIVATE = Gitlab::VisibilityLevel::PRIVATE
let!(:license) { create(:license, plan: License::ULTIMATE_PLAN) }
let(:user) { create(:user) }
let(:project) { create(:project, namespace: namespace, visibility_level: PRIVATE) }
let(:namespace) { create(:namespace, visibility_level: PRIVATE) }
let(:project) { create(:project, namespace: namespace, visibility_level: Gitlab::VisibilityLevel::PRIVATE) }
let(:namespace) { create(:namespace, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let(:service) { described_class.new(user, feature: :operations_dashboard) }
describe '#execute' do
......@@ -131,14 +128,17 @@ describe Dashboard::Projects::ListService do
using RSpec::Parameterized::TableSyntax
where(:check_namespace_plan, :project_visibility, :namespace_visibility, :available) do
true | PUBLIC | PUBLIC | true
true | PRIVATE | PUBLIC | false
true | PUBLIC | PRIVATE | false
true | PRIVATE | PRIVATE | false
false | PUBLIC | PUBLIC | true
false | PRIVATE | PUBLIC | true
false | PUBLIC | PRIVATE | true
false | PRIVATE | PRIVATE | true
public_visibility = Gitlab::VisibilityLevel::PUBLIC
private_visibility = Gitlab::VisibilityLevel::PRIVATE
true | public_visibility | public_visibility | true
true | private_visibility | public_visibility | false
true | public_visibility | private_visibility | false
true | private_visibility | private_visibility | false
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
with_them do
......
......@@ -3,8 +3,6 @@
require 'spec_helper'
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(:project) { create(:project, :repository) }
let_it_be(:environment) { create(:environment, project: project) }
......@@ -30,9 +28,20 @@ describe Metrics::Dashboard::CloneDashboardService, :use_clean_rails_memory_stor
branch: branch
}
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, [STAGES::CommonMetricsInserter, STAGES::Sorter]
it_behaves_like 'valid dashboard cloning process', ::Metrics::Dashboard::ClusterDashboardService::DASHBOARD_PATH,
[
::Gitlab::Metrics::Dashboard::Stages::CommonMetricsInserter,
::Gitlab::Metrics::Dashboard::Stages::Sorter
]
end
end
end
......
# frozen_string_literal: true
shared_context 'includes EpicAggregate constants' do
EPIC_TYPE = Gitlab::Graphql::Aggregations::Epics::Constants::EPIC_TYPE
ISSUE_TYPE = Gitlab::Graphql::Aggregations::Epics::Constants::ISSUE_TYPE
before do
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
CLOSED_EPIC_STATE = Gitlab::Graphql::Aggregations::Epics::Constants::CLOSED_EPIC_STATE
OPENED_ISSUE_STATE = Gitlab::Graphql::Aggregations::Epics::Constants::OPENED_ISSUE_STATE
CLOSED_ISSUE_STATE = Gitlab::Graphql::Aggregations::Epics::Constants::CLOSED_ISSUE_STATE
stub_const('OPENED_EPIC_STATE', Gitlab::Graphql::Aggregations::Epics::Constants::OPENED_EPIC_STATE)
stub_const('CLOSED_EPIC_STATE', Gitlab::Graphql::Aggregations::Epics::Constants::CLOSED_EPIC_STATE)
stub_const('OPENED_ISSUE_STATE', Gitlab::Graphql::Aggregations::Epics::Constants::OPENED_ISSUE_STATE)
stub_const('CLOSED_ISSUE_STATE', Gitlab::Graphql::Aggregations::Epics::Constants::CLOSED_ISSUE_STATE)
WEIGHT_SUM = Gitlab::Graphql::Aggregations::Epics::Constants::WEIGHT_SUM
COUNT = Gitlab::Graphql::Aggregations::Epics::Constants::COUNT
stub_const('WEIGHT_SUM', Gitlab::Graphql::Aggregations::Epics::Constants::WEIGHT_SUM)
stub_const('COUNT', Gitlab::Graphql::Aggregations::Epics::Constants::COUNT)
end
end
......@@ -3,8 +3,10 @@
require 'spec_helper'
describe ElasticNamespaceRolloutWorker do
ROLLOUT = described_class::ROLLOUT
ROLLBACK = described_class::ROLLBACK
before do
stub_const('ROLLOUT', described_class::ROLLOUT)
stub_const('ROLLBACK', described_class::ROLLBACK)
end
Plan::PAID_HOSTED_PLANS.each do |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