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
|
2021-04-07 21:43:58 +00:00
|
|
|
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
|
2021-04-07 21:43:58 +00:00
|
|
|
is_expected.to match({
|
2021-04-07 21:43:58 +00:00
|
|
|
'id' => match_houid('trx'),
|
2021-02-02 21:04:53 +00:00
|
|
|
'nonprofit' => nonprofit.id,
|
|
|
|
'supporter' => supporter.id,
|
|
|
|
'object' => 'transaction',
|
2021-04-07 21:43:58 +00:00
|
|
|
'created' => Time.current.to_i,
|
2021-02-02 21:04:53 +00:00
|
|
|
'amount' => {
|
2021-02-26 20:23:29 +00:00
|
|
|
'cents' => 1000,
|
2021-02-02 21:04:53 +00:00
|
|
|
'currency' => 'usd'
|
2021-04-07 21:43:58 +00:00
|
|
|
},
|
|
|
|
'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
|