Commit 746ac855 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'sh-redact-links-remove-circular-dependency-ce' into 'master'

Remove circular dependency on Redactable in migration

See merge request gitlab-org/gitlab-ce!22951
parents 7dbe47f9 6a91b289
# frozen_string_literal: true # frozen_string_literal: true
# rubocop:disable Style/Documentation # rubocop:disable Style/Documentation
require_relative 'redact_links/redactable'
module Gitlab module Gitlab
module BackgroundMigration module BackgroundMigration
class RedactLinks 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 class Note < ActiveRecord::Base
include EachBatch include EachBatch
include Redactable include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
self.table_name = 'notes' self.table_name = 'notes'
self.inheritance_column = :_type_disabled self.inheritance_column = :_type_disabled
...@@ -27,7 +16,7 @@ module Gitlab ...@@ -27,7 +16,7 @@ module Gitlab
class Issue < ActiveRecord::Base class Issue < ActiveRecord::Base
include EachBatch include EachBatch
include Redactable include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
self.table_name = 'issues' self.table_name = 'issues'
self.inheritance_column = :_type_disabled self.inheritance_column = :_type_disabled
...@@ -35,7 +24,7 @@ module Gitlab ...@@ -35,7 +24,7 @@ module Gitlab
class MergeRequest < ActiveRecord::Base class MergeRequest < ActiveRecord::Base
include EachBatch include EachBatch
include Redactable include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
self.table_name = 'merge_requests' self.table_name = 'merge_requests'
self.inheritance_column = :_type_disabled self.inheritance_column = :_type_disabled
...@@ -43,7 +32,7 @@ module Gitlab ...@@ -43,7 +32,7 @@ module Gitlab
class Snippet < ActiveRecord::Base class Snippet < ActiveRecord::Base
include EachBatch include EachBatch
include Redactable include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
self.table_name = 'snippets' self.table_name = 'snippets'
self.inheritance_column = :_type_disabled self.inheritance_column = :_type_disabled
......
# 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
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