test/unit/gateways/braintree_test.rb in activemerchant-1.4.2 vs test/unit/gateways/braintree_test.rb in activemerchant-1.5.0
- old
+ new
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../../test_helper'
+require 'test_helper'
class BraintreeTest < Test::Unit::TestCase
def setup
@gateway = BraintreeGateway.new(
@@ -32,17 +32,27 @@
end
def test_add_address
result = {}
- @gateway.send(:add_address, result, nil, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
+ @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
assert_equal ["address1", "city", "company", "country", "phone", "state", "zip"], result.stringify_keys.keys.sort
- assert_equal 'CO', result[:state]
- assert_equal '164 Waverley Street', result[:address1]
- assert_equal 'US', result[:country]
+ assert_equal 'CO', result["state"]
+ assert_equal '164 Waverley Street', result["address1"]
+ assert_equal 'US', result["country"]
end
+ def test_add_shipping_address
+ result = {}
+
+ @gateway.send(:add_address, result, {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'},"shipping" )
+ assert_equal ["shipping_address1", "shipping_city", "shipping_company", "shipping_country", "shipping_phone", "shipping_state", "shipping_zip"], result.stringify_keys.keys.sort
+ assert_equal 'CO', result["shipping_state"]
+ assert_equal '164 Waverley Street', result["shipping_address1"]
+ assert_equal 'US', result["shipping_country"]
+
+ end
def test_supported_countries
assert_equal ['US'], BraintreeGateway.supported_countries
end
@@ -71,11 +81,11 @@
check = Check.new(:name => 'Fred Bloggs',
:routing_number => '111000025',
:account_number => '123456789012',
:account_holder_type => 'personal',
:account_type => 'checking')
- @gateway.send(:add_check, post, check)
+ @gateway.send(:add_check, post, check, {})
assert_equal %w[account_holder_type account_type checkaba checkaccount checkname payment], post.stringify_keys.keys.sort
end
def test_funding_source
assert_equal :check, @gateway.send(:determine_funding_source, Check.new)
@@ -95,17 +105,9 @@
response = @gateway.purchase(@amount, @credit_card)
assert_equal 'N', response.cvv_result['code']
end
- def test_gateway_should_be_available_as_brain_tree
- gateway = BrainTreeGateway.new(:login => 'l', :password => 'p')
- gateway.expects(:ssl_post).returns(successful_purchase_response)
- response = gateway.purchase(@amount, @credit_card)
- assert_success response
-
- end
-
private
def successful_purchase_response
'response=1&responsetext=SUCCESS&authcode=123456&transactionid=510695343&avsresponse=N&cvvresponse=N&orderid=ea1e0d50dcc8cfc6e4b55650c592097e&type=sale&response_code=100'
end