Skip to content

Commit

Permalink
adds failing test for autosave
Browse files Browse the repository at this point in the history
  • Loading branch information
shaw3257 committed Jan 23, 2017
1 parent 9f1a2c9 commit 6697e39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions test/test_core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ def test_deleted?
assert ParanoidString.with_deleted.first.deleted?
end

def test_has_many_autosave
paranoid_forest = ParanoidForest.create!
paranoid_tree = paranoid_forest.paranoid_trees.create! name: 'autosave'
paranoid_tree.send(:paranoid_value=, ParanoidTree.delete_now_value)
paranoid_forest.save!
assert_not_nil paranoid_tree.paranoid_value
paranoid_tree.reload
assert_not_nil paranoid_tree.paranoid_value
end

def test_paranoid_destroy_callbacks
@paranoid_with_callback = ParanoidWithCallback.first
ParanoidWithCallback.transaction do
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class ParanoidForest < ActiveRecord::Base

scope :rainforest, lambda{ where(:rainforest => true) }

has_many :paranoid_trees, :dependent => :destroy
has_many :paranoid_trees, autosave: true, dependent: :destroy
end

class ParanoidTree < ActiveRecord::Base
Expand Down

0 comments on commit 6697e39

Please sign in to comment.