Hide wrapped exception, too

This commit is contained in:
Rohan Mitchell
2016-02-04 11:38:09 +11:00
parent ff493c21d4
commit 235c463849
2 changed files with 7 additions and 5 deletions

View File

@@ -6,6 +6,8 @@ require 'open_food_network/products_renderer'
module OpenFoodNetwork
class CachedProductsRenderer
class NoProducts < Exception; end
def initialize(distributor, order_cycle)
@distributor = distributor
@order_cycle = order_cycle
@@ -22,7 +24,7 @@ module OpenFoodNetwork
end
end
raise ProductsRenderer::NoProducts.new if products_json.nil?
raise NoProducts.new if products_json.nil?
products_json
end

View File

@@ -19,7 +19,7 @@ module OpenFoodNetwork
it "raises an exception when there are no products" do
Rails.cache.write "products-json-#{distributor.id}-#{order_cycle.id}", nil
expect { cpr.products_json }.to raise_error ProductsRenderer::NoProducts
expect { cpr.products_json }.to raise_error CachedProductsRenderer::NoProducts
end
end
@@ -52,18 +52,18 @@ module OpenFoodNetwork
before { cpr.stub(:uncached_products_json).and_raise ProductsRenderer::NoProducts }
it "raises an error" do
expect { cpr.products_json }.to raise_error ProductsRenderer::NoProducts
expect { cpr.products_json }.to raise_error CachedProductsRenderer::NoProducts
end
it "caches the products as nil" do
expect { cpr.products_json }.to raise_error ProductsRenderer::NoProducts
expect { cpr.products_json }.to raise_error CachedProductsRenderer::NoProducts
expect(cache_present).to be
expect(cached_json).to be_nil
end
it "logs a warning" do
cpr.should_receive :log_warning
expect { cpr.products_json }.to raise_error ProductsRenderer::NoProducts
expect { cpr.products_json }.to raise_error CachedProductsRenderer::NoProducts
end
end
end