test/test_document.rb in couchpillow-0.4.7 vs test/test_document.rb in couchpillow-0.4.8

- old
+ new

@@ -240,9 +240,57 @@ d = klass.get('123') assert_equal nil, d end + def test_get_multiple_ids + klass = Class.new(Document) do + type 'test' + attribute(:foo) + end + + k = klass.new + k.foo = 100 + k.save! + + k2 = klass.new + k2.foo = 200 + k2.save! + + d = klass.get(k.id, k2.id) + assert_equal 2, d.size + assert_equal 100, d[0].foo + assert_equal 200, d[1].foo + end + + + def test_get_multiple_ids_different_types_and_nils + klassA = Class.new(Document) do + type 'klassA' + attribute(:foo) + end + + klassB = Class.new(Document) do + type 'klassB' + attribute(:bar) + end + + ka = klassA.new + ka.foo = 100 + ka.save! + + kb = klassB.new + kb.bar = 200 + kb.save! + + # kb is klassB, so it should be nil + d = klassA.get(kb.id, ka.id) + assert_equal 2, d.size + assert_nil d[0] + assert_equal 100, d[1].foo + end + + def test_key_with_false_values klass = Class.new(Document) do attribute(:key) end d = klass.new({ :key => false }, "1")