2e8821efdf
Co-authored-by: Clarissa Lima Borges <clarissa@commitchange.com>
38 lines
1.1 KiB
Ruby
38 lines
1.1 KiB
Ruby
# 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!}
|
|
it 'will create a proper builder result' do
|
|
is_expected.to match({
|
|
'id' => match_houid('trx'),
|
|
'nonprofit' => nonprofit.id,
|
|
'supporter' => supporter.id,
|
|
'object' => 'transaction',
|
|
'created' => Time.current.to_i,
|
|
'amount' => {
|
|
'cents' => 1000,
|
|
'currency' => 'usd'
|
|
},
|
|
'subtransaction' => nil,
|
|
'subtransaction_payments' => [],
|
|
'transaction_assignments' => [
|
|
{
|
|
'object' => 'donation',
|
|
'id' => match_houid('don'),
|
|
'type' => 'trx_assignment'
|
|
}
|
|
]
|
|
})
|
|
end
|
|
end
|
|
end
|