test/virtualbox/abstract_model/attributable_test.rb in virtualbox-0.8.6 vs test/virtualbox/abstract_model/attributable_test.rb in virtualbox-0.9.0

- old
+ new

@@ -192,9 +192,31 @@ assert @model.loaded_attribute?(:foo) assert !@model.loaded_attribute?(:bar) end end + context "resetting attributes" do + class ResetAttributeModel < AttributeModel + attribute :normal + attribute :lazy, :lazy => true + end + + setup do + @model = ResetAttributeModel.new + @model.populate_attributes({ + :normal => "normal", + :lazy => "lazy" + }) + end + + should "only reset the lazy attributes" do + assert @model.loaded_attribute?(:lazy) + @model.reset_attributes + assert !@model.loaded_attribute?(:lazy) + assert_equal "normal", @model.normal + end + end + context "reading and writing attributes" do class VersionedAttributeModel < AttributeModel attribute :ver, :version => "3.1" end