From 7b2d4f10ee68732b63b609acee32e0bdd91bf5e8 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 19 Dec 2018 13:01:48 +0100 Subject: [PATCH] Cover #distributed_properties \w a controller spec This exercises the controller and the serializer ensuring the integration works allowing to confidently refactor things further. --- spec/controllers/shops_controller_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/controllers/shops_controller_spec.rb b/spec/controllers/shops_controller_spec.rb index 44f896d5f3..82ded402fd 100644 --- a/spec/controllers/shops_controller_spec.rb +++ b/spec/controllers/shops_controller_spec.rb @@ -15,4 +15,25 @@ describe ShopsController, type: :controller do get :index expect(response.body).to have_content(invisible_distributor.name) end + + it 'renders distributed properties' do + duplicate_property = create(:property, presentation: 'dairy') + producer = create(:supplier_enterprise, properties: [duplicate_property]) + property = create(:property, presentation: 'dairy') + product = create(:product, properties: [property]) + producer.supplied_products << product + + create( + :simple_order_cycle, + coordinator: distributor, + suppliers: [producer], + distributors: [distributor], + variants: [product.variants] + ) + + get :index + + expect(response.body) + .to match(/"distributed_properties":\[{"id":\d+,"name":"dairy","presentation":"dairy"}\]/) + end end