Sha256: d6811bfe2cbe4447f227c23b516b0d73d5735ebbb574bd4c5ee58090867349b6

Contents?: true

Size: 1.17 KB

Versions: 36

Compression:

Stored size: 1.17 KB

Contents

require 'test_helper'

class MyPost < PostData
  self.required_fields = [ :ccnumber, :ccexp, :firstname, :lastname, :username, :password, :order_id, :key, :time ]
end

class PostDataTest < Test::Unit::TestCase
  
  def setup
    
  end
  
  def teardown
    PostData.required_fields = []
  end
  
  def test_element_assignment
    name = 'Cody Fauser'
    post = PostData.new
    
    post[:name] = name
    assert_equal name, post[:name]
  end
  
  def test_ignore_blank_fields
    post = PostData.new
    assert_equal 0, post.keys.size
    
    post[:name] = ''
    assert_equal 0, post.keys.size
    
    post[:name] = nil
    assert_equal 0, post.keys.size
  end
  
  def test_dont_ignore_required_blank_fields
    PostData.required_fields = [ :name ]
    post = PostData.new
    
    assert_equal 0, post.keys.size
    
    post[:name] = ''
    assert_equal 1, post.keys.size
    assert_equal '', post[:name]
    
    post[:name] = nil
    assert_equal 1, post.keys.size
    assert_nil post[:name]
  end
    
  def test_subclass
    post = MyPost.new
    assert_equal [ :ccnumber, :ccexp, :firstname, :lastname, :username, :password, :order_id, :key, :time ], post.required_fields
  end
end

Version data entries

36 entries across 36 versions & 11 rubygems

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