Skip to content

Commit

Permalink
unfreeze props when destroy transaction rolls back
Browse files Browse the repository at this point in the history
  • Loading branch information
subvertallchris committed Jan 9, 2015
1 parent 703bf6e commit 45c87b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/neo4j/shared/callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def destroy #:nodoc:
run_callbacks(:destroy) { super }
rescue
@_deleted = false
@attributes = @attributes.dup
tx.mark_failed
raise
ensure
Expand Down
6 changes: 4 additions & 2 deletions spec/e2e/active_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,16 @@ class Company
end

it 'rolls back node destroy' do
c = Company.create
c = Company.create(name: 'Foo')
expect(c).to be_persisted
expect { c.destroy }.not_to raise_error
expect(c).not_to be_persisted
Company.after_destroy { fail }
c = Company.create
c = Company.create(name: 'Foo')
expect { c.destroy }.to raise_error
expect(c).to be_persisted
expect(c).not_to be_frozen
expect(c).not_to be_changed
end
end
end
Expand Down

0 comments on commit 45c87b3

Please sign in to comment.