From 2bfa51cbb1a7d8e460d34e143ef075b9ac9408a0 Mon Sep 17 00:00:00 2001 From: Neal Chambers Date: Sun, 20 Aug 2023 22:15:22 +0900 Subject: [PATCH] Fix Rails/ActiveRecordOverride --- .rubocop_todo.yml | 7 ------- app/models/spree/product.rb | 11 ++++++----- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 04ee675c17..823ec3a944 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -420,13 +420,6 @@ Naming/VariableNumber: - 'spec/models/spree/tax_rate_spec.rb' - 'spec/requests/api/orders_spec.rb' -# Offense count: 1 -# Configuration parameters: Severity, Include. -# Include: app/models/**/*.rb -Rails/ActiveRecordOverride: - Exclude: - - 'app/models/spree/product.rb' - # Offense count: 47 # Configuration parameters: Include. # Include: app/models/**/*.rb diff --git a/app/models/spree/product.rb b/app/models/spree/product.rb index 7a9d843761..652e9214e1 100755 --- a/app/models/spree/product.rb +++ b/app/models/spree/product.rb @@ -29,6 +29,10 @@ module Spree acts_as_paranoid + after_create :ensure_standard_variant + around_destroy :destruction + after_save :update_units + searchable_attributes :supplier_id, :primary_taxon_id, :meta_keywords, :sku searchable_associations :supplier, :properties, :primary_taxon, :variants searchable_scopes :active, :with_properties @@ -74,9 +78,6 @@ module Spree attr_accessor :price, :display_as, :unit_value, :unit_description, :tax_category_id, :shipping_category_id - after_create :ensure_standard_variant - after_save :update_units - scope :with_properties, ->(*property_ids) { left_outer_joins(:product_properties). left_outer_joins(:supplier_properties). @@ -259,7 +260,7 @@ module Spree variants.map(&:import_date).compact.max end - def destroy + def destruction transaction do touch_distributors @@ -267,7 +268,7 @@ module Spree where('exchange_variants.variant_id IN (?)', variants.with_deleted. select(:id)).destroy_all - super + yield end end