Sha256: e49b27116c24822d6b87f1c934fe746ae15a4e9ac77dc1e0bc149a2bc849da16

Contents?: true

Size: 1.14 KB

Versions: 15

Compression:

Stored size: 1.14 KB

Contents

require 'test_helper'

class BagTest < ActiveSupport::TestCase

  def setup
    @order = Order.new
  end

  test "has a bag" do
    assert @order.respond_to?(:bag)
  end

  test "has setters and getters" do
    assert @order.respond_to?(:field)
    assert @order.respond_to?(:flag)
    assert @order.respond_to?(:at)

    assert @order.respond_to?('field=')
    assert @order.respond_to?('flag=')
    assert @order.respond_to?('flag?')
    assert @order.respond_to?('at=')
  end

  test "string access to field" do
    value = 'abc'
    @order.field = value
    assert_equal value, @order.field
    assert_not_equal 'def', @order.field
  end

  test "date access to at" do
    value = DateTime.now
    @order.at = value
    assert_equal value, @order.at
    assert_not_equal 'def', @order.at
  end

  test "bag is hidden" do
    value = 'abc'
    @order.field = value
    @order.bag = 'bad thing'
    assert_equal value, @order.field
  end

  test "merge for :at :date" do
    model = :order
    params = {model => {'at(1i)' => '1', 'at(2i)' => '2','at(3i)' => '3'}}
    res = Order.merge({}, params)
    assert_equal Date.new(1, 2, 3), res[model][:at]
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
act_with_bag-1.0.4 test/bag_test.rb
act_with_bag-1.0.3 test/bag_test.rb
act_with_bag-1.0.2 test/bag_test.rb
act_with_bag-1.0.0 test/bag_test.rb
act_with_bag-0.5.7 test/bag_test.rb
act_with_bag-0.5.6 test/bag_test.rb
act_with_bag-0.4.9.1 test/bag_test.rb
act_with_bag-0.5.5 test/bag_test.rb
act_with_bag-0.5.3 test/bag_test.rb
act_with_bag-0.5.2 test/bag_test.rb
act_with_bag-0.5.1 test/bag_test.rb
act_with_bag-0.4.9 test/bag_test.rb
act_with_bag-0.4.7 test/bag_test.rb
act_with_bag-0.4.4 test/bag_test.rb
act_with_bag-0.4.2 test/bag_test.rb