Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/app/models/workarea/bulk_action/product_edit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def act_on!(product)
apply_pricing!(product)
apply_inventory!(product)

product.update_attributes!(settings)
product.update!(settings)
end
end

Expand Down Expand Up @@ -54,7 +54,7 @@ def apply_pricing!(product)
sku_pricing = pricing.dup
changes = sku_pricing.delete('prices')

sku.update_attributes!(sku_pricing)
sku.update!(sku_pricing)
sku.prices.build unless sku.prices.any?

sku.prices.each do |price|
Expand All @@ -77,7 +77,7 @@ def apply_inventory!(product)
collection = Inventory::Collection.new(product.skus)

collection.records.each do |record|
record.update_attributes!(inventory)
record.update!(inventory)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/workarea/data_file/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Export
def process!
set(started_at: Time.current)
run_callbacks(:process) { format.export! }
update_attributes!(file: tempfile.tap(&:close), completed_at: Time.current)
update!(file: tempfile.tap(&:close), completed_at: Time.current)
end

def models
Expand Down
4 changes: 2 additions & 2 deletions core/app/models/workarea/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ def update_item(id, attributes)

if existing_item.present? && existing_item.id.to_s != id.to_s
item = items.find(id)
existing_item.update_attributes(quantity: existing_item.quantity + (attributes[:quantity] || item.quantity))
existing_item.update(quantity: existing_item.quantity + (attributes[:quantity] || item.quantity))
item.delete
else
items.find(id).update_attributes(attributes)
items.find(id).update(attributes)
end
end

Expand Down
2 changes: 1 addition & 1 deletion core/app/models/workarea/pricing/discount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def <=>(other)
# Automatically deactivates a discount
#
def auto_deactivate!
update_attributes!(active: false, auto_deactivated_at: Time.current)
update!(active: false, auto_deactivated_at: Time.current)
end

# Whether this discount qualifies for this order. It does so
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/workarea/pricing/discount/code_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CodeList
#
def generate_promo_codes!
count.times { generate_code }
update_attributes!(generation_completed_at: Time.current)
update!(generation_completed_at: Time.current)
end

# Whether the list finished generating its codes
Expand Down
4 changes: 2 additions & 2 deletions core/app/models/workarea/pricing/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def all_skus
def save_order
# as_document won't contain items in the hash if there isn't any items left.
# ensure the items get cleared out when this happens
@persisted_order.update_attributes!(order.as_document.reverse_merge(items: []))
@persisted_order.update!(order.as_document.reverse_merge(items: []))
cache_key.order = @persisted_order
@persisted_order.set(pricing_cache_key: cache_key.to_s)
end
Expand All @@ -149,7 +149,7 @@ def save_shippings
s.id == tmp_shipping.id
end

matching_shipping.update_attributes!(shipping_attrs)
matching_shipping.update!(shipping_attrs)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/workarea/reports/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def name
def process!
set(started_at: Time.current)
CSV.open(temp_path, 'w') { |csv| yield(csv) }
update_attributes!(file: temp_path, completed_at: Time.current)
update!(file: temp_path, completed_at: Time.current)
end

def report
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/workarea/user/authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def status_email_recipients
end

def mark_impersonated_by!(user)
update_attributes!(
update!(
last_impersonated_by_id: user.id,
last_impersonated_at: Time.current
)
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/workarea/user/login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def unlock_login!
end

def update_login!(request)
update_attributes!(
update!(
ip_address: request.ip,
user_agent: request.user_agent
)
Expand Down
14 changes: 11 additions & 3 deletions core/app/models/workarea/user/password_reset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ def complete(new_password)
return false
end

if user.update_attributes(password: new_password)
if user.update(password: new_password)
destroy
else
user.errors.each do |attribute, error|
errors.add(attribute, error)
# Rails 7 yields ActiveModel::Error objects; older Rails yields
# [attribute, message] pairs.
user.errors.each do |error|
if error.respond_to?(:attribute) && error.respond_to?(:message)
errors.add(error.attribute, error.message)
else
attribute, message = error
errors.add(attribute, message)
end
end

false
end
end
Expand Down
2 changes: 1 addition & 1 deletion core/app/seeds/workarea/dynamic_content_seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def content_blocks_from_file(path)

def set_content(contentable, blocks)
content = Content.for(contentable)
content.update_attributes!(blocks: blocks)
content.update!(blocks: blocks)
end

def seed_images
Expand Down
2 changes: 1 addition & 1 deletion core/app/seeds/workarea/orders_seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def create_order
user = User.sample

if user.first_name.blank? || user.last_name.blank?
user.update_attributes!(
user.update!(
first_name: Faker::Name.first_name,
last_name: Faker::Name.last_name
)
Expand Down
2 changes: 1 addition & 1 deletion core/app/seeds/workarea/search_settings_seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def perform
private

def add_filters
Search::Settings.current.update_attributes!(
Search::Settings.current.update!(
terms_facets: %w(Color Size),
range_facets: {
'price' => [
Expand Down
2 changes: 1 addition & 1 deletion core/app/services/workarea/login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def perform
if current_order.started_checkout?
Checkout.new(current_order).continue_as(user)
else
current_order.update_attributes!(user_id: user.id)
current_order.update!(user_id: user.id)
end
end

Expand Down
4 changes: 2 additions & 2 deletions core/app/services/workarea/save_taxonomy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(taxon, params)
end

def perform
@taxon.update_attributes!(parent_id: @params[:parent_id])
@taxon.update!(parent_id: @params[:parent_id])
@taxon.move_to_position(@params[:position]) if @params[:position].present?

set_taxonomy_slug
Expand All @@ -26,7 +26,7 @@ def set_taxonomy_slug
Release.with_current(nil) do
Sidekiq::Callbacks.disable(RedirectNavigableSlugs) do
slug = FindTaxonomySlug.new(@taxon.navigable, @taxon).slug
@taxon.navigable.update_attributes!(slug: slug) if slug.present?
@taxon.navigable.update!(slug: slug) if slug.present?
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion core/app/workers/workarea/save_user_order_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def save_payment_details(order, user)
user.auto_save_billing_address(billing_address)

if user.public_info.blank?
user.update_attributes!(
user.update!(
first_name: billing_address[:first_name],
last_name: billing_address[:last_name]
)
Expand Down
2 changes: 1 addition & 1 deletion core/lib/workarea/tasks/migrate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def v3_5

Workarea::Scheduler.delete(release.undo_job_id)

release.update_attributes!(undo_at: nil, undo_job_id: nil)
release.update!(undo_at: nil, undo_job_id: nil)
count += 1
end

Expand Down
Loading