From f756749e02f05a7080e90c78e3fc7076b8ecc069 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 3 Feb 2016 12:28:26 +1100 Subject: [PATCH] Fix specs --- app/models/enterprise_fee.rb | 4 ++-- app/models/spree/variant_decorator.rb | 2 +- spec/jobs/refresh_products_cache_job_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/enterprise_fee.rb b/app/models/enterprise_fee.rb index e2831a4178..0f4b3f8bc6 100644 --- a/app/models/enterprise_fee.rb +++ b/app/models/enterprise_fee.rb @@ -71,8 +71,8 @@ class EnterpriseFee < ActiveRecord::Base # Remove this association here instead of using dependent: :destroy because # dependent-destroy acts before this around_filter is called, so ProductsCache # has no way of knowing where this fee was used. - order_cycles.clear - exchange_fees.destroy_all + order_cycles(:reload).clear + exchange_fees(:reload).destroy_all # Destroy the enterprise fee yield diff --git a/app/models/spree/variant_decorator.rb b/app/models/spree/variant_decorator.rb index 143508185a..b62b2440b2 100644 --- a/app/models/spree/variant_decorator.rb +++ b/app/models/spree/variant_decorator.rb @@ -100,7 +100,7 @@ Spree::Variant.class_eval do # Remove this association here instead of using dependent: :destroy because # dependent-destroy acts before this around_filter is called, so ProductsCache # has no way of knowing which exchanges the variant was a member of. - exchange_variants.destroy_all + exchange_variants(:reload).destroy_all # Destroy the variant yield diff --git a/spec/jobs/refresh_products_cache_job_spec.rb b/spec/jobs/refresh_products_cache_job_spec.rb index 2197ba38c9..d20efe5fad 100644 --- a/spec/jobs/refresh_products_cache_job_spec.rb +++ b/spec/jobs/refresh_products_cache_job_spec.rb @@ -6,11 +6,11 @@ describe RefreshProductsCacheJob do let(:order_cycle) { create(:simple_order_cycle) } it "renders products and writes them to cache" do - OpenFoodNetwork::ProductsRenderer.any_instance.stub(:products_json) { 'products' } + RefreshProductsCacheJob.any_instance.stub(:products_json) { 'products' } run_job RefreshProductsCacheJob.new distributor.id, order_cycle.id - expect(Rails.cache.read("products-json-123-456")).to eq 'products' + expect(Rails.cache.read("products-json-#{distributor.id}-#{order_cycle.id}")).to eq 'products' end describe "fetching products JSON" do