diff --git a/lib/couchrest/model/persistence.rb b/lib/couchrest/model/persistence.rb index 885f726..c63b8f4 100644 --- a/lib/couchrest/model/persistence.rb +++ b/lib/couchrest/model/persistence.rb @@ -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 diff --git a/spec/couchrest/dirty_spec.rb b/spec/couchrest/dirty_spec.rb index 12c4f18..8cbd7be 100644 --- a/spec/couchrest/dirty_spec.rb +++ b/spec/couchrest/dirty_spec.rb @@ -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