mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
Otherwise next dev might think these are attributes of the resulting JSON serialized object. They just made the refactoring a bit easier.
27 lines
878 B
Ruby
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
|