Remove circular dependency on Redactable in migration

Gitlab::BackgroundMigration::RedactLinks was prepending
EE::Gitlab::BackgroundMigration::RedactLinks, while
EE::Gitlab::BackgroundMigration::RedactLinks was trying to include
Gitlab::BackgroundMigration::RedactLinks::Redactable. Ruby 2.5.3 failed
with an uninitialized constant
(https://gitlab.com/gitlab-org/gitlab-ee/-/jobs/118388511).
This commit is contained in:
Stan Hu 2018-11-09 12:57:02 -08:00
parent d5027d774b
commit 6a91b28932
2 changed files with 27 additions and 17 deletions

View File

@ -1,25 +1,14 @@
# frozen_string_literal: true
# rubocop:disable Style/Documentation
require_relative 'redact_links/redactable'
module Gitlab
module BackgroundMigration
class RedactLinks
module Redactable
extend ActiveSupport::Concern
def redact_field!(field)
self[field].gsub!(%r{/sent_notifications/\h{32}/unsubscribe}, '/sent_notifications/REDACTED/unsubscribe')
if self.changed?
self.update_columns(field => self[field],
"#{field}_html" => nil)
end
end
end
class Note < ActiveRecord::Base
include EachBatch
include Redactable
include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
self.table_name = 'notes'
self.inheritance_column = :_type_disabled
@ -27,7 +16,7 @@ module Gitlab
class Issue < ActiveRecord::Base
include EachBatch
include Redactable
include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
self.table_name = 'issues'
self.inheritance_column = :_type_disabled
@ -35,7 +24,7 @@ module Gitlab
class MergeRequest < ActiveRecord::Base
include EachBatch
include Redactable
include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
self.table_name = 'merge_requests'
self.inheritance_column = :_type_disabled
@ -43,7 +32,7 @@ module Gitlab
class Snippet < ActiveRecord::Base
include EachBatch
include Redactable
include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
self.table_name = 'snippets'
self.inheritance_column = :_type_disabled

View File

@ -0,0 +1,21 @@
# frozen_string_literal: true
# rubocop:disable Style/Documentation
module Gitlab
module BackgroundMigration
class RedactLinks
module Redactable
extend ActiveSupport::Concern
def redact_field!(field)
self[field].gsub!(%r{/sent_notifications/\h{32}/unsubscribe}, '/sent_notifications/REDACTED/unsubscribe')
if self.changed?
self.update_columns(field => self[field],
"#{field}_html" => nil)
end
end
end
end
end
end