Commit 7a42426d authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch '338494-rename-strip-attributes-bang' into 'master'

Rename strip_attributes method (suffix with a bang)

See merge request gitlab-org/gitlab!68193
parents d9fd807e b4a754a9
......@@ -9,7 +9,7 @@ module Ci
belongs_to :project, inverse_of: :freeze_periods
strip_attributes :freeze_start, :freeze_end
strip_attributes! :freeze_start, :freeze_end
validates :freeze_start, cron: true, presence: true
validates :freeze_end, cron: true, presence: true
......
......@@ -24,7 +24,7 @@ module Ci
validates :description, presence: true
validates :variables, nested_attributes_duplicates: true
strip_attributes :cron
strip_attributes! :cron
scope :active, -> { where(active: true) }
scope :inactive, -> { where(active: false) }
......
......@@ -152,7 +152,7 @@ module Issuable
participant :notes_with_associations
participant :assignees
strip_attributes :title
strip_attributes! :title
class << self
def labels_hash
......
......@@ -7,7 +7,7 @@
# Usage:
#
# class Milestone < ApplicationRecord
# strip_attributes :title
# strip_attributes! :title
# end
#
#
......@@ -15,7 +15,7 @@ module StripAttribute
extend ActiveSupport::Concern
class_methods do
def strip_attributes(*attrs)
def strip_attributes!(*attrs)
strip_attrs.concat(attrs)
end
......@@ -25,10 +25,10 @@ module StripAttribute
end
included do
before_validation :strip_attributes
before_validation :strip_attributes!
end
def strip_attributes
def strip_attributes!
self.class.strip_attrs.each do |attr|
self[attr].strip! if self[attr] && self[attr].respond_to?(:strip!)
end
......
......@@ -106,7 +106,7 @@ module Timebox
.where('due_date is NULL or due_date >= ?', start_date)
end
strip_attributes :title
strip_attributes! :title
alias_attribute :name, :title
end
......
......@@ -6,7 +6,7 @@ module ComplianceManagement
self.table_name = 'compliance_management_frameworks'
strip_attributes :name, :color
strip_attributes! :name, :color
belongs_to :namespace
has_many :project_settings, class_name: 'ComplianceManagement::ComplianceFramework::ProjectSettings'
......
......@@ -24,7 +24,7 @@ module EE
cache_markdown_field :title, pipeline: :single_line
cache_markdown_field :description, issuable_state_filter_enabled: true
strip_attributes :title
strip_attributes! :title
redact_field :description
......
......@@ -60,7 +60,7 @@ class GeoNode < ApplicationRecord
mode: :per_attribute_iv,
encode: true
strip_attributes :name
strip_attributes! :name
class << self
# Set in gitlab.rb as external_url
......
......@@ -16,7 +16,7 @@ module RequirementsManagement
cache_markdown_field :title, pipeline: :single_line
cache_markdown_field :description, issuable_state_filter_enabled: true
strip_attributes :title
strip_attributes! :title
belongs_to :author, inverse_of: :requirements, class_name: 'User'
belongs_to :project, inverse_of: :requirements
......
......@@ -5,12 +5,12 @@ require 'spec_helper'
RSpec.describe StripAttribute do
let(:milestone) { create(:milestone) }
describe ".strip_attributes" do
it { expect(Milestone).to respond_to(:strip_attributes) }
describe ".strip_attributes!" do
it { expect(Milestone).to respond_to(:strip_attributes!) }
it { expect(Milestone.strip_attrs).to include(:title) }
end
describe "#strip_attributes" do
describe "#strip_attributes!" do
before do
milestone.title = ' 8.3 '
milestone.valid?
......
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