mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Order serializer spec
This commit is contained in:
32
spec/serializers/order_serializer_spec.rb
Normal file
32
spec/serializers/order_serializer_spec.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
#require 'spec_helper'
|
||||
|
||||
describe Api::OrderSerializer do
|
||||
let(:serializer) { Api::OrderSerializer.new order }
|
||||
let(:order) { create(:completed_order_with_totals) }
|
||||
|
||||
|
||||
it "serializes an order" do
|
||||
expect(serializer.to_json).to match order.id.to_s
|
||||
end
|
||||
|
||||
it "converts the total to currency and amount" do
|
||||
puts order.inspect
|
||||
puts serializer.serializable_hash.inspect
|
||||
expect(serializer.serializable_hash[:total_money].keys).to include :currency_symbol
|
||||
# Not sure what currency symbol is in test env
|
||||
expect(serializer.serializable_hash[:total_money].keys).to include :amount
|
||||
expect(serializer.serializable_hash[:total_money][:amount]).to eq "0.00"
|
||||
end
|
||||
|
||||
it "converts the balance to currency and amount" do
|
||||
expect(serializer.serializable_hash[:balance_money].keys).to include :currency_symbol
|
||||
# Not sure what currency symbol is in test env
|
||||
expect(serializer.serializable_hash[:balance_money].keys).to include :amount
|
||||
expect(serializer.serializable_hash[:balance_money][:amount]).to eq "0.00"
|
||||
end
|
||||
it "convert the state attributes to readable strings" do
|
||||
expect(serializer.to_json).to match "Complete"
|
||||
expect(serializer.to_json).to match "Balance due"
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user