Sha256: 67f59d3cf6daba7766339689398520a0dad068fdea9466a51629ff0734ddd6c8

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

require 'test_helper'

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

class PostDataTest < Minitest::Test
  def teardown
    ActiveMerchant::PostData.required_fields = []
  end

  def test_element_assignment
    name = 'Cody Fauser'
    post = ActiveMerchant::PostData.new

    post[:name] = name
    assert_equal name, post[:name]
  end

  def test_ignore_blank_fields
    post = ActiveMerchant::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
    ActiveMerchant::PostData.required_fields = [ :name ]
    post = ActiveMerchant::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

7 entries across 7 versions & 3 rubygems

Version Path
solidus_backend-1.0.0.pre vendor/bundle/gems/active_utils-2.2.3/test/unit/post_data_test.rb
tanga_active_utils-2.2.3.1 test/unit/post_data_test.rb
tanga_active_utils-2.2.3 test/unit/post_data_test.rb
active_utils-2.2.3 test/unit/post_data_test.rb
active_utils-2.2.2 test/unit/post_data_test.rb
active_utils-2.2.1 test/unit/post_data_test.rb
active_utils-2.2.0 test/unit/post_data_test.rb