Skip to content

Commit

Permalink
cleanup authorize.net tests
Browse files Browse the repository at this point in the history
git-svn-id: https://activemerchant.googlecode.com/svn/trunk/active_merchant@560 6513ea26-6c20-0410-8a68-89cd7235086d
  • Loading branch information
codyfauser committed Jan 18, 2008
1 parent 2e6b704 commit f410edc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG

* Fix Authorize.net test where authorize() was being called instead of purchase(). Perform some cleanup of the tests [ianlotin...@hotmail.com, cody]
* Improve Authorize.net documentation based on the DataCashGateway docs [patrick.t.joyce]
* Update EfsnetGateway to support avs and cvv data. Remove test_result_from_cc_number. [cody]
* Remove test_result_from_cc_number from DataCash. Improve unit test coverage [cody]
Expand Down
25 changes: 9 additions & 16 deletions test/unit/gateways/authorize_net_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ def setup
)

@credit_card = credit_card('4242424242424242')
@amount = 100
end

def test_successful_authorization
@gateway.expects(:ssl_post).returns(successful_authorization_response)

assert response = @gateway.authorize(100, @credit_card)
assert response = @gateway.authorize(@amount, @credit_card)
assert_instance_of Response, response
assert_success response
assert_equal '508141794', response.authorization
Expand All @@ -22,7 +23,7 @@ def test_successful_authorization
def test_successful_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)

assert response = @gateway.authorize(100, @credit_card)
assert response = @gateway.purchase(@amount, @credit_card)
assert_instance_of Response, response
assert_success response
assert_equal '508141795', response.authorization
Expand All @@ -31,20 +32,12 @@ def test_successful_purchase
def test_failed_authorization
@gateway.expects(:ssl_post).returns(failed_authorization_response)

assert response = @gateway.authorize(100, @credit_card)
assert response = @gateway.authorize(@amount, @credit_card)
assert_instance_of Response, response
assert_failure response
assert_equal '508141794', response.authorization
end

def test_purchase_exception
@gateway.expects(:ssl_post).raises(Error)

assert_raise(Error) do
assert response = @gateway.purchase(100, @credit_card, :order_id => 1)
end
end

def test_amount_style
assert_equal '10.34', @gateway.send(:amount, 1034)

Expand Down Expand Up @@ -113,15 +106,15 @@ def test_purchase_meets_minimum_requirements

def test_successful_credit
@gateway.expects(:ssl_post).returns(successful_purchase_response)
assert response = @gateway.credit(100, '123456789', :card_number => @credit_card.number)
assert response = @gateway.credit(@amount, '123456789', :card_number => @credit_card.number)
assert_success response
assert_equal 'This transaction has been approved', response.message
end

def test_failed_credit
@gateway.expects(:ssl_post).returns(failed_credit_response)

assert response = @gateway.credit(100, '123456789', :card_number => @credit_card.number)
assert response = @gateway.credit(@amount, '123456789', :card_number => @credit_card.number)
assert_failure response
assert_equal 'The referenced transaction does not meet the criteria for issuing a credit', response.message
end
Expand All @@ -143,7 +136,7 @@ def test_failure_without_response_reason_text
def test_response_under_review_by_fraud_service
@gateway.expects(:ssl_post).returns(fraud_review_response)

response = @gateway.purchase(100, @credit_card)
response = @gateway.purchase(@amount, @credit_card)
assert_failure response
assert response.fraud_review?
assert_equal "Thank you! For security reasons your order is currently being reviewed", response.message
Expand All @@ -152,14 +145,14 @@ def test_response_under_review_by_fraud_service
def test_avs_result
@gateway.expects(:ssl_post).returns(fraud_review_response)

response = @gateway.purchase(100, @credit_card)
response = @gateway.purchase(@amount, @credit_card)
assert_equal 'X', response.avs_result['code']
end

def test_cvv_result
@gateway.expects(:ssl_post).returns(fraud_review_response)

response = @gateway.purchase(100, @credit_card)
response = @gateway.purchase(@amount, @credit_card)
assert_equal 'M', response.cvv_result['code']
end

Expand Down

0 comments on commit f410edc

Please sign in to comment.