Cover #distributed_properties \w a controller spec

This exercises the controller and the serializer ensuring the
integration works allowing to confidently refactor things further.
This commit is contained in:
Pau Perez
2018-12-19 13:01:48 +01:00
parent e55fbf80fc
commit 7b2d4f10ee

View File

@@ -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