Commit 61fffbe0 authored by Ryan Cobb's avatar Ryan Cobb

Dont use class_eval

parent b521c390
...@@ -192,9 +192,7 @@ describe GitlabSchema do ...@@ -192,9 +192,7 @@ describe GitlabSchema do
# We cannot use an anonymous class here as `GlobalID` expects `.name` not # We cannot use an anonymous class here as `GlobalID` expects `.name` not
# to return `nil` # to return `nil`
before do before do
stub_const('TestGlobalId', Class.new) test_global_id = Class.new do
TestGlobalId.class_eval do
include GlobalID::Identification include GlobalID::Identification
attr_accessor :id attr_accessor :id
...@@ -202,6 +200,8 @@ describe GitlabSchema do ...@@ -202,6 +200,8 @@ describe GitlabSchema do
@id = id @id = id
end end
end end
stub_const('TestGlobalId', test_global_id)
end end
it 'falls back to a regular find' do it 'falls back to a regular find' do
......
...@@ -149,19 +149,19 @@ describe VisibilityLevelHelper do ...@@ -149,19 +149,19 @@ describe VisibilityLevelHelper do
# This is a subset of all the permutations # This is a subset of all the permutations
where(:requested_level, :max_allowed, :global_default_level, :restricted_levels, :expected) do where(:requested_level, :max_allowed, :global_default_level, :restricted_levels, :expected) do
public_vis = Gitlab::VisibilityLevel::PUBLIC public_vis = Gitlab::VisibilityLevel::PUBLIC
internal = Gitlab::VisibilityLevel::INTERNAL internal_vis = Gitlab::VisibilityLevel::INTERNAL
private_vis = Gitlab::VisibilityLevel::PRIVATE private_vis = Gitlab::VisibilityLevel::PRIVATE
public_vis | public_vis | public_vis | [] | public_vis public_vis | public_vis | public_vis | [] | public_vis
public_vis | public_vis | public_vis | [public_vis] | internal public_vis | public_vis | public_vis | [public_vis] | internal_vis
internal | public_vis | public_vis | [] | internal internal_vis | public_vis | public_vis | [] | internal_vis
internal | private_vis | private_vis | [] | private_vis internal_vis | private_vis | private_vis | [] | private_vis
private_vis | public_vis | public_vis | [] | private_vis private_vis | public_vis | public_vis | [] | private_vis
public_vis | private_vis | internal | [] | private_vis public_vis | private_vis | internal_vis | [] | private_vis
public_vis | internal | public_vis | [] | internal public_vis | internal_vis | public_vis | [] | internal_vis
public_vis | private_vis | public_vis | [] | private_vis public_vis | private_vis | public_vis | [] | private_vis
public_vis | internal | internal | [] | internal public_vis | internal_vis | internal_vis | [] | internal_vis
public_vis | public_vis | internal | [] | public_vis public_vis | public_vis | internal_vis | [] | public_vis
end end
before do before do
......
...@@ -6,10 +6,7 @@ describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, schema: ...@@ -6,10 +6,7 @@ describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, schema:
before do before do
# we need to define the classes due to encryption # we need to define the classes due to encryption
stub_const('IssueTrackerData', Class.new(ApplicationRecord)) issue_tracker_data = Class.new(ApplicationRecord) do
stub_const('JiraTrackerData', Class.new(ApplicationRecord))
IssueTrackerData.class_eval do
self.table_name = 'issue_tracker_data' self.table_name = 'issue_tracker_data'
def self.encryption_options def self.encryption_options
...@@ -26,7 +23,7 @@ describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, schema: ...@@ -26,7 +23,7 @@ describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, schema:
attr_encrypted :new_issue_url, encryption_options attr_encrypted :new_issue_url, encryption_options
end end
JiraTrackerData.class_eval do jira_tracker_data = Class.new(ApplicationRecord) do
self.table_name = 'jira_tracker_data' self.table_name = 'jira_tracker_data'
def self.encryption_options def self.encryption_options
...@@ -43,6 +40,9 @@ describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, schema: ...@@ -43,6 +40,9 @@ describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, schema:
attr_encrypted :username, encryption_options attr_encrypted :username, encryption_options
attr_encrypted :password, encryption_options attr_encrypted :password, encryption_options
end end
stub_const('IssueTrackerData', issue_tracker_data)
stub_const('JiraTrackerData', jira_tracker_data)
end end
let(:url) { 'http://base-url.tracker.com' } let(:url) { 'http://base-url.tracker.com' }
......
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