Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Only track changed values when persisted state is Dirty
Browse files Browse the repository at this point in the history
[#1355 state:resolved]
  • Loading branch information
dkubb committed Jul 28, 2010
1 parent 2c20393 commit 75c67e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/dm-core/resource/state/dirty.rb
Expand Up @@ -44,9 +44,9 @@ def track(subject, value)
if original_attributes[subject].eql?(value)
original_attributes.delete(subject)
end
else
elsif !value.eql?(original = get(subject))
# track the original value
original_attributes[subject] = get(subject)
original_attributes[subject] = original
end
end

Expand Down
4 changes: 3 additions & 1 deletion spec/semipublic/resource/state/dirty_spec.rb
Expand Up @@ -127,7 +127,7 @@ class ::Author
supported_by :all do
describe 'with attributes that keep the resource dirty' do
before do
@key = @model.properties[:name]
@key = @model.properties[:id]
@value = @key.get!(@resource)
end

Expand All @@ -136,6 +136,8 @@ class ::Author
it 'should return a Dirty state' do
should equal(@state)
end

its(:original_attributes) { should == { @model.properties[:name] => 'Dan Kubb' } }
end

describe 'with attributes that make the resource clean' do
Expand Down

0 comments on commit 75c67e6

Please sign in to comment.