diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-11-09 21:56:59 +0000 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-11-09 21:56:59 +0000 |
commit | 746ac855f96bcee76cfd53550428831522f4054b (patch) | |
tree | 92ee439934ad0542c1d336018b157b3be28d0ed9 | |
parent | 7dbe47f98a2b6d18ae1fd5444708f8192f4a6772 (diff) | |
parent | 6a91b28932cd2dba735a57c06e4bea7334f89a69 (diff) | |
download | gitlab-ce-746ac855f96bcee76cfd53550428831522f4054b.tar.gz |
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
-rw-r--r-- | lib/gitlab/background_migration/redact_links.rb | 23 | ||||
-rw-r--r-- | lib/gitlab/background_migration/redact_links/redactable.rb | 21 |
2 files changed, 27 insertions, 17 deletions
diff --git a/lib/gitlab/background_migration/redact_links.rb b/lib/gitlab/background_migration/redact_links.rb index f5d3bcdd517..92256e59a6c 100644 --- a/lib/gitlab/background_migration/redact_links.rb +++ b/lib/gitlab/background_migration/redact_links.rb @@ -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 diff --git a/lib/gitlab/background_migration/redact_links/redactable.rb b/lib/gitlab/background_migration/redact_links/redactable.rb new file mode 100644 index 00000000000..baab34221f1 --- /dev/null +++ b/lib/gitlab/background_migration/redact_links/redactable.rb @@ -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 |