Sha256: f9534907669d899fa9e04778484dda96b58f6ddc93f4f869f293cf596352e2c7

Contents?: true

Size: 1.18 KB

Versions: 32

Compression:

Stored size: 1.18 KB

Contents

require 'test_helper'

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

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

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

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

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

32 entries across 32 versions & 1 rubygems

Version Path
active_utils-3.4.1 test/unit/post_data_test.rb
active_utils-3.4.0 test/unit/post_data_test.rb
active_utils-3.3.19 test/unit/post_data_test.rb
active_utils-3.3.18 test/unit/post_data_test.rb
active_utils-3.3.17 test/unit/post_data_test.rb
active_utils-3.3.16 test/unit/post_data_test.rb
active_utils-3.3.15 test/unit/post_data_test.rb
active_utils-3.3.14 test/unit/post_data_test.rb
active_utils-3.3.13 test/unit/post_data_test.rb
active_utils-3.3.12 test/unit/post_data_test.rb
active_utils-3.3.11 test/unit/post_data_test.rb
active_utils-3.3.10 test/unit/post_data_test.rb
active_utils-3.3.9 test/unit/post_data_test.rb
active_utils-3.3.8 test/unit/post_data_test.rb
active_utils-3.3.7 test/unit/post_data_test.rb
active_utils-3.3.6 test/unit/post_data_test.rb
active_utils-3.3.5 test/unit/post_data_test.rb
active_utils-3.3.4 test/unit/post_data_test.rb
active_utils-3.3.3 test/unit/post_data_test.rb
active_utils-3.3.2 test/unit/post_data_test.rb