Sha256: 4d62769cffa723ee0aea30dfc9a4ef071c1358fdb565b0ce599bfc74f6af592d

Contents?: true

Size: 1.85 KB

Versions: 31

Compression:

Stored size: 1.85 KB

Contents

require 'test_helper'

class ChronopayHelperTest < Test::Unit::TestCase
  include ActiveMerchant::Billing::Integrations
  
  def setup
    @helper = Chronopay::Helper.new('order-500','003176-0001-0001', :amount => 500, :currency => 'CAD')
  end
 
  def test_basic_helper_fields
    assert_field 'cs1', 'order-500'
    assert_field 'product_id', '003176-0001-0001'
    assert_field 'product_price', '500'
    assert_field 'product_price_currency', 'CAD'
  end
  
  def test_customer_fields
    @helper.customer :first_name => 'Cody', :last_name => 'Fauser'
    assert_field 'f_name', 'Cody'
    assert_field 's_name', 'Fauser'
  end

  def test_address_mapping
    @helper.billing_address :country => 'CAN',
                            :address1 => '1 My Street',
                            :city => 'Ottawa',
                            :state => 'On',
                            :zip => '90210'
   
    assert_field 'country', 'CAN'
    assert_field 'street', '1 My Street'
    assert_field 'state', 'On'
    assert_field 'zip', '90210'
  end

  def test_country_code_mapping
    @helper.billing_address :country => 'CA'
    assert_field 'country', 'CAN'
  end

  def test_province_code_mapping_non_us
    @helper.billing_address :country => 'DE', :state => 'Berlin'
    assert_field 'country', 'DEU'
    assert_field 'state', 'XX'
  end

  def test_state_code_mapping_us
    @helper.billing_address :country => 'US', :state => 'CA'
    assert_field 'country', 'USA'
    assert_field 'state', 'CA'
  end

  def test_unknown_mapping
    assert_nothing_raised do
      @helper.company_address :address => '500 Dwemthy Fox Road'
    end
  end
  
  def test_setting_invalid_address_field
    fields = @helper.fields.dup
    @helper.billing_address :street => 'My Street'
    
    # Will still set the state code to 'XX'
    fields['state'] = 'XX'
    assert_equal fields, @helper.fields
  end
end

Version data entries

31 entries across 31 versions & 10 rubygems

Version Path
johnideal-activemerchant-1.4.10 test/unit/integrations/helpers/chronopay_helper_test.rb
johnideal-activemerchant-1.4.11 test/unit/integrations/helpers/chronopay_helper_test.rb
johnideal-activemerchant-1.4.4 test/unit/integrations/helpers/chronopay_helper_test.rb
johnideal-activemerchant-1.4.5 test/unit/integrations/helpers/chronopay_helper_test.rb
johnideal-activemerchant-1.4.6 test/unit/integrations/helpers/chronopay_helper_test.rb
johnideal-activemerchant-1.4.7 test/unit/integrations/helpers/chronopay_helper_test.rb
johnideal-activemerchant-1.4.8 test/unit/integrations/helpers/chronopay_helper_test.rb
mattbauer-activemerchant-1.4.2 test/unit/integrations/helpers/chronopay_helper_test.rb
tomriley-active_merchant-1.4.2.3 test/unit/integrations/helpers/chronopay_helper_test.rb
tomriley-active_merchant-1.4.2.4 test/unit/integrations/helpers/chronopay_helper_test.rb
tomriley-active_merchant-1.4.2.5 test/unit/integrations/helpers/chronopay_helper_test.rb
tomriley-active_merchant-1.4.2.6 test/unit/integrations/helpers/chronopay_helper_test.rb
tomriley-active_merchant-1.4.2.7 test/unit/integrations/helpers/chronopay_helper_test.rb
tomriley-active_merchant-1.4.2.8 test/unit/integrations/helpers/chronopay_helper_test.rb
tomriley-tomriley-active_merchant-1.4.2.4 test/unit/integrations/helpers/chronopay_helper_test.rb
goldstar-activemerchant-1.4.2.7 test/unit/integrations/helpers/chronopay_helper_test.rb
goldstar-activemerchant-1.4.2.6 test/unit/integrations/helpers/chronopay_helper_test.rb
tomriley-active_merchant-1.4.2.11 test/unit/integrations/helpers/chronopay_helper_test.rb
tomriley-active_merchant-1.4.2.10 test/unit/integrations/helpers/chronopay_helper_test.rb
ghazel-activemerchant-1.4.2 test/unit/integrations/helpers/chronopay_helper_test.rb