Commit be1647f5 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Peter Leitzen

Fix leaky constant in relation factory spec

parent 84c36a86
......@@ -356,7 +356,6 @@ RSpec/LeakyConstantDeclaration:
- 'spec/lib/gitlab/database/with_lock_retries_spec.rb'
- 'spec/lib/gitlab/git/diff_collection_spec.rb'
- 'spec/lib/gitlab/import_export/import_test_coverage_spec.rb'
- 'spec/lib/gitlab/import_export/project/relation_factory_spec.rb'
- 'spec/lib/gitlab/quick_actions/dsl_spec.rb'
- 'spec/lib/marginalia_spec.rb'
- 'spec/mailers/notify_spec.rb'
......
---
title: Fix leaky constant issue in relation factory spec
merge_request: 32129
author: Rajendra Kadam
type: fixed
......@@ -18,6 +18,22 @@ describe Gitlab::ImportExport::Project::RelationFactory do
excluded_keys: excluded_keys)
end
before do
# Mocks an ActiveRecordish object with the dodgy columns
stub_const('FooModel', Class.new)
FooModel.class_eval do
include ActiveModel::Model
def initialize(params = {})
params.each { |key, value| send("#{key}=", value) }
end
def values
instance_variables.map { |ivar| instance_variable_get(ivar) }
end
end
end
context 'hook object' do
let(:relation_sym) { :hooks }
let(:id) { 999 }
......@@ -83,19 +99,6 @@ describe Gitlab::ImportExport::Project::RelationFactory do
end
end
# Mocks an ActiveRecordish object with the dodgy columns
class FooModel
include ActiveModel::Model
def initialize(params = {})
params.each { |key, value| send("#{key}=", value) }
end
def values
instance_variables.map { |ivar| instance_variable_get(ivar) }
end
end
context 'merge_request object' do
let(:relation_sym) { :merge_requests }
......@@ -208,11 +211,12 @@ describe Gitlab::ImportExport::Project::RelationFactory do
}
end
class HazardousFooModel < FooModel
before do
stub_const('HazardousFooModel', Class.new(FooModel))
HazardousFooModel.class_eval do
attr_accessor :service_id, :moved_to_id, :namespace_id, :ci_id, :random_project_id, :random_id, :milestone_id, :project_id
end
before do
allow(HazardousFooModel).to receive(:reflect_on_association).and_return(nil)
end
......@@ -246,11 +250,12 @@ describe Gitlab::ImportExport::Project::RelationFactory do
Gitlab::ImportExport::Project::RelationFactory::PROJECT_REFERENCES.map { |ref| { ref => 99 } }.inject(:merge)
end
class ProjectFooModel < FooModel
before do
stub_const('ProjectFooModel', Class.new(FooModel))
ProjectFooModel.class_eval do
attr_accessor(*Gitlab::ImportExport::Project::RelationFactory::PROJECT_REFERENCES)
end
before do
allow(ProjectFooModel).to receive(:reflect_on_association).and_return(nil)
end
......
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