Sha256: a4be723c6438c326ce27455bac119d4dd910c21ce88d0dbe2291189c4dfb0492
Contents?: true
Size: 938 Bytes
Versions: 10
Compression:
Stored size: 938 Bytes
Contents
require 'test_helper' class Order < ActiveRecord::Base add_to_bag bool: :boolean end class BagBooleanTest < ActiveSupport::TestCase def setup @order = Order.new end test "uninitialized boolean should return false" do assert_equal false, @order.bool assert_equal false, @order.bag.has_key?(:bool) end test "optimized storage of boolean" do @order.bool = false assert_equal false, @order.bag.has_key?(:bool) @order.bool = 0 assert_equal false, @order.bag.has_key?(:bool) @order.bool = '0' assert_equal false, @order.bag.has_key?(:bool) end test "a true value requires storage in the bag" do @order.bool = true assert_equal true, @order.bag.has_key?(:bool) assert_equal true, @order.bool end test "reassigning a false value should drop storage in bag" do @order.bool = true @order.bool = false assert_equal false, @order.bag.has_key?(:bool) end end
Version data entries
10 entries across 10 versions & 1 rubygems