Commit 88e0da4f authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'rc/fix_leaky_constants_2' into 'master'

Fixes for RSpec/LeakyConstantDeclaration

See merge request gitlab-org/gitlab!27956
parents 5524a083 68c6fea8
......@@ -328,13 +328,6 @@ RSpec/LeakyConstantDeclaration:
Exclude:
- 'spec/**/*.rb'
- 'qa/spec/**/*.rb'
- 'ee/spec/lib/gitlab/geo/log_cursor/logger_spec.rb'
- 'ee/spec/lib/gitlab/geo/log_helpers_spec.rb'
- 'ee/spec/lib/gitlab/geo/replicator_spec.rb'
- 'ee/spec/mailers/emails/service_desk_spec.rb'
- 'ee/spec/migrations/remove_creations_in_gitlab_subscription_histories_spec.rb'
- 'ee/spec/migrations/set_resolved_state_on_vulnerabilities_spec.rb'
- 'ee/spec/models/repository_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'
......
......@@ -3,13 +3,12 @@
require 'spec_helper'
describe Gitlab::Geo::LogCursor::Logger, :geo do
class LoggerSpec; end
subject(:logger) { described_class.new(LoggerSpec) }
let(:data) { { pid: 111, class: 'LoggerSpec', host: 'localhost', message: 'Test' } }
before do
stub_const('LoggerSpec', Class.new)
stub_const("#{described_class.name}::PID", 111)
end
......
......@@ -3,13 +3,17 @@
require 'spec_helper'
describe Gitlab::Geo::LogHelpers do
class FakeLogHelpersConsumer
before do
stub_const('FakeLogHelpersConsumer', Class.new)
FakeLogHelpersConsumer.class_eval do
include Gitlab::Geo::LogHelpers
def execute
log_error('Test message')
end
end
end
def stub_sidekiq_job_context(context)
original_value = Thread.current[:sidekiq_context]
......
......@@ -4,7 +4,10 @@ require 'spec_helper'
describe Gitlab::Geo::Replicator do
context 'with defined events' do
class DummyReplicator < Gitlab::Geo::Replicator
before do
stub_const('DummyReplicator', Class.new(Gitlab::Geo::Replicator))
DummyReplicator.class_eval do
event :test
event :another_test
......@@ -14,6 +17,7 @@ describe Gitlab::Geo::Replicator do
true
end
end
end
context 'event DSL' do
subject { DummyReplicator }
......@@ -36,7 +40,10 @@ describe Gitlab::Geo::Replicator do
end
context 'model DSL' do
class DummyModel
before do
stub_const('DummyModel', Class.new)
DummyModel.class_eval do
include ActiveModel::Model
def self.after_create_commit(*args)
......@@ -46,6 +53,7 @@ describe Gitlab::Geo::Replicator do
with_replicator DummyReplicator
end
end
subject { DummyModel.new }
......
......@@ -15,7 +15,10 @@ describe Emails::ServiceDesk do
let_it_be(:issue) { create(:issue, project: project) }
let(:template) { double(content: template_content) }
class ServiceEmailClass < ApplicationMailer
before do
stub_const('ServiceEmailClass', Class.new(ApplicationMailer))
ServiceEmailClass.class_eval do
include GitlabRoutingHelper
include EmailsHelper
include Emails::ServiceDesk
......@@ -49,6 +52,7 @@ describe Emails::ServiceDesk do
end
alias_method :mail_answer_thread, :mail_new_thread
end
end
shared_examples 'handle template content' do |template_key|
before do
......
......@@ -4,9 +4,11 @@ require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200113151354_remove_creations_in_gitlab_subscription_histories.rb')
describe RemoveCreationsInGitlabSubscriptionHistories do
GITLAB_SUBSCRIPTION_CREATED = 0
GITLAB_SUBSCRIPTION_UPDATED = 1
GITLAB_SUBSCRIPTION_DESTROYED = 2
before do
stub_const('GITLAB_SUBSCRIPTION_CREATED', 0)
stub_const('GITLAB_SUBSCRIPTION_UPDATED', 1)
stub_const('GITLAB_SUBSCRIPTION_DESTROYED', 2)
end
let(:gitlab_subscriptions) { table(:gitlab_subscriptions) }
let(:gitlab_subscription_histories) { table(:gitlab_subscription_histories) }
......
......@@ -4,8 +4,6 @@ require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20191114173624_set_resolved_state_on_vulnerabilities.rb')
describe SetResolvedStateOnVulnerabilities do
PACK_FORMAT = 'H*'
let(:confidence_levels) do
{ undefined: 0, ignore: 1, unknown: 2, experimental: 3, low: 4, medium: 5, high: 6, confirmed: 7 }
end
......@@ -47,6 +45,8 @@ describe SetResolvedStateOnVulnerabilities do
end
before do
stub_const('PACK_FORMAT', 'H*')
author = users.create!(id: 1, email: 'author@example.com', projects_limit: 10)
closer = users.create!(id: closer_id, email: 'closer@example.com', projects_limit: 10)
namespace = namespaces.create!(id: 1, name: 'namespace_1', path: 'namespace_1', owner_id: author.id)
......
......@@ -7,7 +7,9 @@ describe Repository do
include ::EE::GeoHelpers
include GitHelpers
TestBlob = Struct.new(:path)
before do
stub_const('TestBlob', Struct.new(:path))
end
let_it_be(:primary_node) { create(:geo_node, :primary) }
let_it_be(:secondary_node) { create(:geo_node) }
......
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