diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/integrations/enable_ssl_verification.rb | 21 | ||||
-rw-r--r-- | app/models/integration.rb | 8 | ||||
-rw-r--r-- | app/models/integrations/base_chat_notification.rb | 6 | ||||
-rw-r--r-- | app/models/integrations/pipelines_email.rb | 4 | ||||
-rw-r--r-- | app/models/snippet.rb | 8 |
5 files changed, 22 insertions, 25 deletions
diff --git a/app/models/concerns/integrations/enable_ssl_verification.rb b/app/models/concerns/integrations/enable_ssl_verification.rb index 9735a9bf5f6..cb20955488a 100644 --- a/app/models/concerns/integrations/enable_ssl_verification.rb +++ b/app/models/concerns/integrations/enable_ssl_verification.rb @@ -5,7 +5,11 @@ module Integrations extend ActiveSupport::Concern prepended do - boolean_accessor :enable_ssl_verification + field :enable_ssl_verification, + type: :checkbox, + title: -> { s_('Integrations|SSL verification') }, + checkbox_label: -> { s_('Integrations|Enable SSL verification') }, + help: -> { s_('Integrations|Clear if using a self-signed certificate.') } end def initialize_properties @@ -17,18 +21,11 @@ module Integrations def fields super.tap do |fields| url_index = fields.index { |field| field[:name].ends_with?('_url') } - insert_index = url_index ? url_index + 1 : -1 + insert_index = url_index || -1 - fields.insert(insert_index, - Field.new( - name: 'enable_ssl_verification', - integration_class: self, - type: :checkbox, - title: s_('Integrations|SSL verification'), - checkbox_label: s_('Integrations|Enable SSL verification'), - help: s_('Integrations|Clear if using a self-signed certificate.') - ) - ) + enable_ssl_verification_index = fields.index { |field| field[:name] == 'enable_ssl_verification' } + + fields.insert(insert_index, fields.delete_at(enable_ssl_verification_index)) end end end diff --git a/app/models/integration.rb b/app/models/integration.rb index 33955b088f1..b4408301c6d 100644 --- a/app/models/integration.rb +++ b/app/models/integration.rb @@ -219,13 +219,6 @@ class Integration < ApplicationRecord # Also keep track of updated properties in a similar way as ActiveModel::Dirty def self.boolean_accessor(*args) args.each do |arg| - # TODO: Allow legacy usage of `.boolean_accessor`, once all integrations - # are converted to the field DSL we can remove this and only call - # `.boolean_accessor` through `.field`. - # - # See https://gitlab.com/groups/gitlab-org/-/epics/7652 - prop_accessor(arg) unless method_defined?(arg) - class_eval <<~RUBY, __FILE__, __LINE__ + 1 # Make the original getter available as a private method. alias_method :#{arg}_before_type_cast, :#{arg} @@ -242,6 +235,7 @@ class Integration < ApplicationRecord RUBY end end + private_class_method :boolean_accessor def self.to_param raise NotImplementedError diff --git a/app/models/integrations/base_chat_notification.rb b/app/models/integrations/base_chat_notification.rb index e6936318f42..d4bf6353b45 100644 --- a/app/models/integrations/base_chat_notification.rb +++ b/app/models/integrations/base_chat_notification.rb @@ -34,8 +34,6 @@ module Integrations prop_accessor(*SUPPORTED_EVENTS.map { |event| EVENT_CHANNEL[event] }) prop_accessor(*GROUP_ONLY_SUPPORTED_EVENTS.map { |event| EVENT_CHANNEL[event] }) - boolean_accessor :notify_only_default_branch - validates :webhook, presence: true, public_url: true, @@ -50,7 +48,7 @@ module Integrations self.notify_only_broken_pipelines = true if self.respond_to?(:notify_only_broken_pipelines) self.branches_to_be_notified = "default" self.labels_to_be_notified_behavior = MATCH_ANY_LABEL - elsif !self.notify_only_default_branch.nil? + elsif !properties['notify_only_default_branch'].nil? # In older versions, there was only a boolean property named # `notify_only_default_branch`. Now we have a string property named # `branches_to_be_notified`. Instead of doing a background migration, we @@ -58,7 +56,7 @@ module Integrations # users haven't specified one already. When users edit the integration and # select a value for this new property, it will override everything. - self.branches_to_be_notified ||= notify_only_default_branch? ? "default" : "all" + self.branches_to_be_notified ||= properties['notify_only_default_branch'] ? "default" : "all" end end diff --git a/app/models/integrations/pipelines_email.rb b/app/models/integrations/pipelines_email.rb index fa22bd1a73c..01efbc3e4a4 100644 --- a/app/models/integrations/pipelines_email.rb +++ b/app/models/integrations/pipelines_email.rb @@ -37,8 +37,8 @@ module Integrations # `notify_only_default_branch`. Now we have a string property named # `branches_to_be_notified`. Instead of doing a background migration, we # opted to set a value for the new property based on the old one, if - # users hasn't specified one already. When users edit the service and - # selects a value for this new property, it will override everything. + # users haven't specified one already. When users edit the integration and + # select a value for this new property, it will override everything. self.branches_to_be_notified ||= notify_only_default_branch? ? "default" : "all" end diff --git a/app/models/snippet.rb b/app/models/snippet.rb index d4f8c1b3b0b..78b0c0849e3 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -79,6 +79,10 @@ class Snippet < ApplicationRecord scope :with_statistics, -> { joins(:statistics) } scope :inc_projects_namespace_route, -> { includes(project: [:route, :namespace]) } + scope :without_created_by_banned_user, -> do + where_not_exists(Users::BannedUser.where('snippets.author_id = banned_users.user_id')) + end + attr_mentionable :description participant :author @@ -365,6 +369,10 @@ class Snippet < ApplicationRecord def multiple_files? list_files.size > 1 end + + def hidden_due_to_author_ban? + Feature.enabled?(:hide_snippets_of_banned_users) && author.banned? + end end Snippet.prepend_mod_with('Snippet') |