Files
openfoodnetwork/spec/serializers/api/cached_enterprise_serializer_spec.rb
Pau Perez e0f43191e2 Make helper methods private
Otherwise next dev might think these are attributes of the resulting
JSON serialized object.

They just made the refactoring a bit easier.
2018-11-28 16:21:40 +01:00

27 lines
878 B
Ruby

require 'spec_helper'
describe Api::CachedEnterpriseSerializer do
let(:cached_enterprise_serializer) { described_class.new(enterprise) }
let(:enterprise) { create(:enterprise) }
describe '#supplied_properties' do
let(:property) { create(:property, presentation: 'One') }
let(:duplicate_property) { create(:property, presentation: 'One') }
let(:different_property) { create(:property, presentation: 'Two') }
let(:enterprise) do
create(:enterprise, properties: [duplicate_property, different_property])
end
before do
product = create(:product, properties: [property])
enterprise.supplied_products << product
end
it "removes duplicate product and producer properties" do
properties = cached_enterprise_serializer.supplied_properties
expect(properties).to eq([property, different_property])
end
end
end