Skip to content

Commit

Permalink
Worldpay gateway: Fix test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Soleone committed Jul 11, 2012
1 parent d3ee794 commit 16487ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/active_merchant/billing/gateways/worldpay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def refund(money, authorization, options = {})
end
end

def test?
@options[:test] || super
end

private

def inquire(authorization, options={})
Expand Down
18 changes: 18 additions & 0 deletions test/unit/gateways/worldpay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,24 @@ def test_auth
end.respond_with(successful_authorize_response)
end

def test_request_respects_test_mode_on_gateway_instance
ActiveMerchant::Billing::Base.mode = :production

@gateway = WorldpayGateway.new(
:login => 'testlogin',
:password => 'testpassword',
:test => true
)

response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
assert_equal WorldpayGateway::TEST_URL, endpoint
end.respond_with(successful_authorize_response, successful_capture_response)

ActiveMerchant::Billing::Base.mode = :test
end

def assert_tag_with_attributes(tag, attributes, string)
assert(m = %r(<#{tag}([^>]+)/>).match(string))
attributes.each do |attribute, value|
Expand Down

0 comments on commit 16487ba

Please sign in to comment.