Sha256: 5574d8599c022aaa90945763358698f784d40f8fafa90740c346bc36e1221b26

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/helper')

class TestWepayRailsCheckoutMethods < ActiveSupport::TestCase
    include WepayRails::Helpers::ControllerHelpers

  def setup
    create_wepay_config_file(false, true)
    initialize_wepay_config
    @checkout_params = {
      :amount => 100,
      :short_description => "This is a checkout test!",
      :account_id => "12345"
    }
  end

  def teardown
    delete_wepay_config_file
  end

  test "should create a new WePay checkout object" do
	security_token = Digest::SHA2.hexdigest("1#{Time.now.to_i}")
	stub_request(:post, "https://stage.wepayapi.com/v2/checkout/create").
		with(:body => "callback_uri=http%3A%2F%2Fwww.example.com%2Fwepay%2Fipn%3Fsecurity_token%3D#{security_token}&redirect_uri=http%3A%2F%2Fwww.example.com%2Fwepay%2Fcheckout%3Fsecurity_token%3D#{security_token}&fee_payer=Payee&type=GOODS&charge_tax=0&app_fee=0&auto_capture=1&require_shipping=0&shipping_fee=0&account_id=12345&amount=100&short_description=This%20is%20a%20checkout%20test!",
	       :headers => wepay_gateway.wepay_auth_header).
	  to_return(:status => 200, :body => sample_checkout_response, :headers => {})

    @response = wepay_gateway.perform_checkout(@checkout_params)
    assert_equal "6789", @response[:checkout_id]
    assert_equal "http://stage.wepay.com/api/checkout/6789", @response[:checkout_uri]
    assert_not_nil @response[:security_token]
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wepay-rails-2.6.0 test/test_wepay_rails_checkout_methods.rb
wepay-rails-2.5.2 test/test_wepay_rails_checkout_methods.rb
wepay-rails-2.5.1 test/test_wepay_rails_checkout_methods.rb