Commit b4a754a9 authored by Lee Tickett's avatar Lee Tickett

Rename strip_attributes method

As the method modifies an object in place it should
be suffixed with a bang

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