diff --git a/api/app/controllers/spree/api/base_controller.rb b/api/app/controllers/spree/api/base_controller.rb index 7303576329d..77d6df42885 100644 --- a/api/app/controllers/spree/api/base_controller.rb +++ b/api/app/controllers/spree/api/base_controller.rb @@ -133,7 +133,7 @@ def find_product(id) def product_scope if can?(:admin, Spree::Product) - scope = Spree::Product.with_deleted.accessible_by(current_ability, :read).includes(*product_includes) + scope = Spree::Product.with_discarded.accessible_by(current_ability, :read).includes(*product_includes) unless params[:show_deleted] scope = scope.not_deleted diff --git a/backend/app/controllers/spree/admin/products_controller.rb b/backend/app/controllers/spree/admin/products_controller.rb index 01a1b82c5ba..bd9b8816560 100644 --- a/backend/app/controllers/spree/admin/products_controller.rb +++ b/backend/app/controllers/spree/admin/products_controller.rb @@ -78,7 +78,7 @@ def split_params end def find_resource - Spree::Product.with_deleted.friendly.find(params[:id]) + Spree::Product.with_discarded.friendly.find(params[:id]) end def location_after_save diff --git a/backend/app/controllers/spree/admin/variants_controller.rb b/backend/app/controllers/spree/admin/variants_controller.rb index c135fc7ad18..002187290ee 100644 --- a/backend/app/controllers/spree/admin/variants_controller.rb +++ b/backend/app/controllers/spree/admin/variants_controller.rb @@ -43,7 +43,7 @@ def redirect_on_empty_option_values end def parent - @parent ||= Spree::Product.with_deleted.find_by(slug: params[:product_id]) + @parent ||= Spree::Product.with_discarded.find_by(slug: params[:product_id]) @product = @parent end end diff --git a/backend/app/views/spree/admin/products/index.html.erb b/backend/app/views/spree/admin/products/index.html.erb index 05a561e1d1b..8261d3e2c92 100644 --- a/backend/app/views/spree/admin/products/index.html.erb +++ b/backend/app/views/spree/admin/products/index.html.erb @@ -34,7 +34,7 @@
diff --git a/backend/spec/controllers/spree/admin/products_controller_spec.rb b/backend/spec/controllers/spree/admin/products_controller_spec.rb index 2592f0322f8..9122df78f3e 100644 --- a/backend/spec/controllers/spree/admin/products_controller_spec.rb +++ b/backend/spec/controllers/spree/admin/products_controller_spec.rb @@ -30,8 +30,8 @@ end end - context 'when params[:q][:with_deleted] is set to "true"' do - let(:params) { { q: { with_deleted: 'true' } } } + context 'when params[:q][:with_discarded] is set to "true"' do + let(:params) { { q: { with_discarded: 'true' } } } it 'includes soft-deleted products' do get :index, params: params diff --git a/backend/spec/features/admin/products/products_spec.rb b/backend/spec/features/admin/products/products_spec.rb index 2b11d8c8c91..d77141c5023 100644 --- a/backend/spec/features/admin/products/products_spec.rb +++ b/backend/spec/features/admin/products/products_spec.rb @@ -99,7 +99,7 @@ def build_option_type_with_values(name, values) expect(page).not_to have_content("apache baseball cap") check "Show Deleted" click_button 'Search' - expect(find('input[name="q[with_deleted]"]')).to be_checked + expect(find('input[name="q[with_discarded]"]')).to be_checked expect(page).to have_content("zomg shirt") expect(page).to have_content("apache baseball cap") uncheck "Show Deleted" diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb index 96d388b1029..7ef451d90aa 100644 --- a/core/app/models/spree/product.rb +++ b/core/app/models/spree/product.rb @@ -15,12 +15,11 @@ class Product < Spree::Base extend FriendlyId friendly_id :slug_candidates, use: :history - acts_as_paranoid - include Spree::ParanoiaDeprecations - include Discard::Model self.discard_column = :deleted_at + default_scope { kept } + after_discard do variants_including_master.discard_all self.product_option_types = [] @@ -134,7 +133,7 @@ def find_or_build_master self.whitelisted_ransackable_attributes = %w[name slug] def self.ransackable_scopes(_auth_object = nil) - %i(with_deleted with_variant_sku_cont) + %i(with_discarded with_variant_sku_cont) end # @return [Boolean] true if there are any variants diff --git a/core/app/models/spree/variant.rb b/core/app/models/spree/variant.rb index 3e19f2bf5c5..16428cb0999 100644 --- a/core/app/models/spree/variant.rb +++ b/core/app/models/spree/variant.rb @@ -35,7 +35,7 @@ class Variant < Spree::Base attr_writer :rebuild_vat_prices include Spree::DefaultPrice - belongs_to :product, -> { with_deleted }, touch: true, class_name: 'Spree::Product', inverse_of: :variants, optional: false + belongs_to :product, -> { with_discarded }, touch: true, class_name: 'Spree::Product', inverse_of: :variants, optional: false belongs_to :tax_category, class_name: 'Spree::TaxCategory', optional: true delegate :name, :description, :slug, :available_on, :shipping_category_id, diff --git a/core/spec/models/spree/product_spec.rb b/core/spec/models/spree/product_spec.rb index f4a4223fb28..2d7dd9253e1 100644 --- a/core/spec/models/spree/product_spec.rb +++ b/core/spec/models/spree/product_spec.rb @@ -417,13 +417,6 @@ class Extension < Spree::Base end end end - - context "#really_destroy!" do - it "destroy the product" do - product.really_destroy! - expect(product).not_to be_persisted - end - end end context "properties" do diff --git a/frontend/app/controllers/spree/products_controller.rb b/frontend/app/controllers/spree/products_controller.rb index cb1d00b1e7f..8487ed154a3 100644 --- a/frontend/app/controllers/spree/products_controller.rb +++ b/frontend/app/controllers/spree/products_controller.rb @@ -38,7 +38,7 @@ def accurate_title def load_product if try_spree_current_user.try(:has_spree_role?, "admin") - @products = Spree::Product.with_deleted + @products = Spree::Product.with_discarded else @products = Spree::Product.available end