houdini/spec/models/transaction_spec.rb

39 lines
1.1 KiB
Ruby
Raw Normal View History

2021-02-02 21:04:53 +00:00
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
require 'rails_helper'
RSpec.describe Transaction, type: :model do
include_context :shared_donation_charge_context
describe 'to_builder' do
subject { supporter.transactions.create(
amount: 1000,
transaction_assignments: [TransactionAssignment.new(assignable:ModernDonation.new(amount: 1000))]
).to_builder.attributes!}
2021-02-02 21:04:53 +00:00
it 'will create a proper builder result' do
is_expected.to match({
'id' => match_houid('trx'),
2021-02-02 21:04:53 +00:00
'nonprofit' => nonprofit.id,
'supporter' => supporter.id,
'object' => 'transaction',
'created' => Time.current.to_i,
2021-02-02 21:04:53 +00:00
'amount' => {
'cents' => 1000,
2021-02-02 21:04:53 +00:00
'currency' => 'usd'
},
'subtransaction' => nil,
'subtransaction_payments' => [],
'transaction_assignments' => [
{
'object' => 'donation',
'id' => match_houid('don'),
'type' => 'trx_assignment'
}
]
2021-02-02 21:04:53 +00:00
})
end
end
end