Sha256: 0418bd35302aded211e4769bba7aca233457f8c0998c5c80105bdbc6db6e0fa4

Contents?: true

Size: 648 Bytes

Versions: 6

Compression:

Stored size: 648 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

6 entries across 6 versions & 1 rubygems

Version Path
act_with_bag-1.1.5 test/clean_test.rb
act_with_bag-1.1.4 test/clean_test.rb
act_with_bag-1.1.3 test/clean_test.rb
act_with_bag-1.1.2 test/clean_test.rb
act_with_bag-1.1.1 test/clean_test.rb
act_with_bag-1.1.0 test/clean_test.rb