mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-28 21:07:16 +00:00
- Copied translations for payment_states, shipment_states and order_states into locale en.yml. - Enabled global Javascript function `translate` to deal with scopes like 'spree.shipment_states'. - Removed `humanize` call from order serializer and added translation scopes to accounts page. - Test OrderSerializer for untranslated attributes - Require spec helper in serializer specs
32 lines
1.2 KiB
Ruby
32 lines
1.2 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: [],
|
|
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
|