fixed credit when no payment_profiles_supported

This commit is contained in:
Bounmy Stephane 2012-06-01 00:36:42 +02:00
parent b11a9dd9f2
commit e11a8e4d5f
2 changed files with 30 additions and 2 deletions

View File

@ -26,11 +26,12 @@ class Spree::BillingIntegration::PaypalExpressBase < Spree::BillingIntegration
end
end
def credit(amount, account, response_code, gateway_options)
def credit(*args)
amount = args.shift
response_code = args.first.is_a?(String) ? args.first : args[1]
provider.credit(amount, response_code, :currency => preferred_currency)
end
def find_authorization(payment)
logs = payment.log_entries.all(:order => 'created_at DESC')
logs.each do |log|

View File

@ -105,4 +105,31 @@ describe Spree::BillingIntegration::PaypalExpressBase do
end
end
describe "#credit" do
before { payment.stub :response_code => '123' }
context "when payment_profiles_supported = true" do
before { gateway.stub :payment_profiles_supported? => true }
it "should receive correct params" do
provider.should_receive(:credit).with(1000, '123', :currency => 'EUR').and_return(success_response)
payment.credit!(10.0)
payment.response_code.should == '123'
end
end
context "when payment_profiles_supported = false" do
before do
payment.stub :response_code => '123'
gateway.stub :payment_profiles_supported? => false
end
it "should receive correct params" do
provider.should_receive(:credit).with(amount_in_cents, '123', :currency => 'EUR').and_return(success_response)
payment.credit!(10.0)
payment.response_code.should == '123'
end
end
end
end