Skip to content

Commit

Permalink
Merge pull request #119 from remear/appears-on-statement-as
Browse files Browse the repository at this point in the history
Fix appears_on_statement_as for credits
  • Loading branch information
mjallday committed Aug 5, 2013
2 parents ee2bce3 + d6ba1b6 commit 877a85d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 15 deletions.
7 changes: 4 additions & 3 deletions lib/balanced/resources/bank_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ def credit *args
options = args.last.is_a?(Hash) ? args.pop : {}
amount = args[0] || options.fetch(:amount) { nil }
description = args[1] || options.fetch(:description) { nil }

appears_on_statement_as = args[3] || options.fetch(:appears_on_statement_as) { nil }

if self.has_account?
meta = args[2] || options.fetch(:meta) { nil }
appears_on_statement_as = args[3] || options.fetch(:appears_on_statement_as) { nil }
destination_uri = args[4] || options.fetch(:destination_uri) { self.uri }
credit = self.account.credit(
:amount => amount,
Expand All @@ -75,7 +75,8 @@ def credit *args
credit = Credit.new(
:uri => self.credits_uri,
:amount => amount,
:description => description
:description => description,
:appears_on_statement_as => appears_on_statement_as
)
credit.save
end
Expand Down
65 changes: 53 additions & 12 deletions spec/balanced/resources/bank_account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,67 @@
its(:routing_number) { should eql '321174851' }
end

describe 'with an account', :vcr do
describe 'without an account', :vcr do
before do
@account = @marketplace.create_account
bank_account = @marketplace.create_bank_account(
@bank_account = @marketplace.create_bank_account(
:account_number => "1234567890111",
:bank_code => "021000021",
:name => "Timmy T. McTimmerson",
:type => "checking"
)
@account.add_bank_account(bank_account.uri)
bank_account = bank_account.reload
@credit_with_account = bank_account.credit(
:amount => 500,
:description => 'Blahblahblah'
)
end

describe 'with appears_on_statement_as', :vcr do
before do
@credit = @bank_account.credit(amount: 1000, description: "Testing", appears_on_statement_as: "Test Company")
end

subject { @credit }
its(:appears_on_statement_as) { should eql 'Test Company' }
end
end

subject { @credit_with_account }
it { should respond_to :account }
it { should be_instance_of Balanced::Credit }
describe 'with an account', :vcr do
before do
@bank_account = @marketplace.create_bank_account(
:account_number => "1234567890111",
:bank_code => "021000021",
:name => "Timmy T. McTimmerson",
:type => "checking"
)
@account = @marketplace.create_account
@account.add_bank_account(@bank_account.uri)
@bank_account.reload
end

describe 'with appears_on_statement_as', :vcr do
before do
@credit = @bank_account.credit(
:amount => 1000,
:description => "Blahblahblah",
:appears_on_statement_as => "Test Company"
)
end

subject { @credit }
it { should respond_to :account }
it { should be_instance_of Balanced::Credit }
its(:appears_on_statement_as) { should eql 'Test Company' }
end

describe 'without appears_on_statement_as', :vcr do
before do
@credit = @bank_account.credit(
:amount => 1000,
:description => "Testing",
)
end

subject { @credit }
it { should respond_to :account }
it { should be_instance_of Balanced::Credit }
its(:appears_on_statement_as) { should eql 'example.com' }
end
end
end
end
Expand Down

0 comments on commit 877a85d

Please sign in to comment.