mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
test invoice model
This commit is contained in:
committed by
Konrad
parent
639567e903
commit
27c1fd0d30
@@ -10,6 +10,8 @@ class Invoice < ApplicationRecord
|
||||
end
|
||||
|
||||
def serialize_order
|
||||
self.data ||= Invoice::OrderSerializer.new(order).serializable_hash
|
||||
return data unless data.empty?
|
||||
|
||||
self.data = Invoice::OrderSerializer.new(order).serializable_hash
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,5 +3,19 @@
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Invoice, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
describe 'presenter' do
|
||||
it 'should return an instance of Invoice::DataPresenter' do
|
||||
invoice = create(:invoice)
|
||||
expect(invoice.presenter).to be_a(Invoice::DataPresenter)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'serialize_order' do
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
let!(:order) { create(:order, :with_line_item, :completed, distributor: distributor) }
|
||||
it 'serializes the order' do
|
||||
invoice = create(:invoice, order: order)
|
||||
expect(invoice.data).to eq(Invoice::OrderSerializer.new(order).serializable_hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user