Temporarily reverting these changes for a quick release
This commit is contained in:
Matt-Yorkley
2019-09-05 13:21:47 +01:00
parent 07d4528276
commit fc9f61ecf8
7 changed files with 7 additions and 67 deletions

View File

@@ -1,14 +1,7 @@
module Spree
Price.class_eval do
acts_as_paranoid without_default_scope: true
after_save :refresh_products_cache
# Allow prices to access associated soft-deleted variants.
def variant
Spree::Variant.unscoped { super }
end
private
def check_price

View File

@@ -91,11 +91,6 @@ Spree::Variant.class_eval do
can_supply?(quantity)
end
# Allow variant to access associated soft-deleted prices.
def default_price
Spree::Price.unscoped { super }
end
def price_with_fees(distributor, order_cycle)
price + fees_for(distributor, order_cycle)
end

View File

@@ -1,6 +0,0 @@
class AddDeletedAtToSpreePrices < ActiveRecord::Migration
def change
add_column :spree_prices, :deleted_at, :datetime
add_index :spree_prices, :deleted_at
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20190830134723) do
ActiveRecord::Schema.define(:version => 20190701002454) do
create_table "adjustment_metadata", :force => true do |t|
t.integer "adjustment_id"
@@ -649,10 +649,9 @@ ActiveRecord::Schema.define(:version => 20190830134723) do
add_index "spree_preferences", ["key"], :name => "index_spree_preferences_on_key", :unique => true
create_table "spree_prices", :force => true do |t|
t.integer "variant_id", :null => false
t.decimal "amount", :precision => 8, :scale => 2
t.string "currency"
t.datetime "deleted_at"
t.integer "variant_id", :null => false
t.decimal "amount", :precision => 8, :scale => 2
t.string "currency"
end
add_index "spree_prices", ["variant_id"], :name => "index_spree_prices_on_variant_id"

View File

@@ -28,17 +28,6 @@ feature "full-page cart", js: true do
end
end
describe "when a product is soft-deleted" do
it "shows the cart without errors" do
add_product_to_cart order, product_with_tax, quantity: 1
add_product_to_cart order, product_with_fee, quantity: 2
product_with_fee.destroy
visit main_app.cart_path
expect(page).to have_selector '.cart-item-price'
end
end
describe "percentage fees" do
let(:percentage_fee) { create(:enterprise_fee, calculator: Calculator::FlatPercentPerItem.new(preferred_flat_percent: 20)) }

View File

@@ -2,10 +2,10 @@ require 'spec_helper'
module Spree
describe Price do
let(:variant) { create(:variant) }
let(:price) { variant.default_price }
describe "callbacks" do
let(:variant) { create(:variant) }
let(:price) { variant.default_price }
it "refreshes the products cache on change" do
expect(OpenFoodNetwork::ProductsCache).to receive(:variant_changed).with(variant)
price.amount = 123
@@ -21,15 +21,5 @@ module Spree
expect(OpenFoodNetwork::ProductsCache).to receive(:variant_changed).never
end
end
context "when variant is soft-deleted" do
before do
variant.destroy
end
it "can access the variant" do
expect(price.variant).to eq variant
end
end
end
end

View File

@@ -128,26 +128,6 @@ describe VariantOverride do
end
end
describe "delegated price" do
let!(:variant_with_price) { create(:variant, price: 123.45) }
let(:price_object) { variant_with_price.default_price }
context "when variant is soft-deleted" do
before do
variant_with_price.destroy
end
it "soft-deletes the price" do
expect(price_object.deleted_at).to_not be_nil
end
it "can access the soft-deleted price" do
expect(variant_with_price.default_price).to eq price_object
expect(variant_with_price.price).to eq 123.45
end
end
end
describe "with price" do
let(:variant_override) { create(:variant_override, variant: variant, hub: hub, price: 12.34) }