Sha256: 4ab323a4744d367cb01d23bf79a5f8f80f4b9e75e6f4dc49de93efb8b0ed74eb

Contents?: true

Size: 652 Bytes

Versions: 16

Compression:

Stored size: 652 Bytes

Contents

require 'test_helper'


class Order < ActiveRecord::Base
  add_to_bag :name
  add_to_bag :name2
end


class CleanTest < ActiveSupport::TestCase

  def setup
    @order = Order.new
  end

  test "assigning nil removes field from bag" do
    value = 'abc'
    assert_equal false, @order.bag.has_key?(:name)
    @order.name = value
    assert_equal true, @order.bag.has_key?(:name)
    @order.name = nil
    assert_equal false, @order.bag.has_key?(:name)
  end

  test "assigning nil to not yet initialized field" do
    assert_equal false, @order.bag.has_key?(:name2)
    @order.name2 = nil
    assert_equal false, @order.bag.has_key?(:name2)
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

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