mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
34 lines
1.3 KiB
Ruby
34 lines
1.3 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Api::EnterpriseSerializer do
|
|
let(:serializer) { Api::EnterpriseSerializer.new enterprise, data: data }
|
|
let(:enterprise) { create(:distributor_enterprise) }
|
|
let(:taxon) { create(:taxon) }
|
|
let(:data) { OpenStruct.new(earliest_closing_times: {},
|
|
active_distributors: [],
|
|
all_distributed_taxons: {enterprise.id => [123]},
|
|
current_distributed_taxons: {enterprise.id => [123]},
|
|
supplied_taxons: {enterprise.id => [456]},
|
|
shipping_method_services: {},
|
|
relatives: {enterprise.id => {producers: [123], distributors: [456]}})
|
|
}
|
|
|
|
it "serializes an enterprise" do
|
|
serializer.to_json.should match enterprise.name
|
|
end
|
|
|
|
it "serializes taxons as ids only" do
|
|
serializer.serializable_hash[:taxons].should == [{id: 123}]
|
|
serializer.serializable_hash[:supplied_taxons].should == [{id: 456}]
|
|
end
|
|
|
|
it "serializes producers and hubs as ids only" do
|
|
serializer.serializable_hash[:producers].should == [{id: 123}]
|
|
serializer.serializable_hash[:hubs].should == [{id: 456}]
|
|
end
|
|
|
|
it "serializes icons" do
|
|
serializer.to_json.should match "map_005-hub.svg"
|
|
end
|
|
end
|