Fixing problem with reloading models and dirty tracking

This commit is contained in:
Sam Lown 2011-06-06 01:53:36 +02:00
parent de1cab1271
commit f5be6c7679
2 changed files with 9 additions and 1 deletions

View file

@ -87,7 +87,7 @@ module CouchRest
#
# Returns self.
def reload
merge!(self.class.get(id))
prepare_all_attributes(database.get(id), :directly_set_attributes => true)
self
end

View file

@ -241,6 +241,14 @@ describe "Dirty" do
end
end
it "should report changes if an array is popped after reload" do
should_change_array do |array, obj|
obj.reload
obj.keywords.pop
end
end
it "should report no changes if an empty array is popped" do
should_not_change_array do |array, obj|
array.clear