delete_paranoid 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/delete_paranoid.rb +2 -2
- data/lib/delete_paranoid/version.rb +1 -1
- data/test/test_delete_paranoid.rb +35 -1
- metadata +4 -4
data/lib/delete_paranoid.rb
CHANGED
@@ -3,7 +3,32 @@ require File.join(File.dirname(__FILE__), 'helper')
|
|
3
3
|
class TestDeleteParanoid < Test::Unit::TestCase
|
4
4
|
class Blog < ActiveRecord::Base
|
5
5
|
acts_as_paranoid
|
6
|
+
|
7
|
+
attr_accessor :called_before_destroy, :called_after_destroy, :called_after_commit_on_destroy
|
8
|
+
|
9
|
+
before_destroy :call_me_before_destroy
|
10
|
+
after_destroy :call_me_after_destroy
|
11
|
+
|
12
|
+
after_commit :call_me_after_commit_on_destroy, :on => :destroy
|
13
|
+
|
14
|
+
def initialize(*attrs)
|
15
|
+
@called_before_destroy = @called_after_destroy = @called_after_commit_on_destroy = false
|
16
|
+
super(*attrs)
|
17
|
+
end
|
18
|
+
|
19
|
+
def call_me_before_destroy
|
20
|
+
@called_before_destroy = true
|
21
|
+
end
|
22
|
+
|
23
|
+
def call_me_after_destroy
|
24
|
+
@called_after_destroy = true
|
25
|
+
end
|
26
|
+
|
27
|
+
def call_me_after_commit_on_destroy
|
28
|
+
@called_after_commit_on_destroy = true
|
29
|
+
end
|
6
30
|
end
|
31
|
+
|
7
32
|
context 'with paranoid class' do
|
8
33
|
should 'have destroy! method' do
|
9
34
|
assert Blog.respond_to? :destroy!
|
@@ -21,9 +46,18 @@ class TestDeleteParanoid < Test::Unit::TestCase
|
|
21
46
|
assert Blog.all.include?(@blog)
|
22
47
|
end
|
23
48
|
end
|
49
|
+
should "call before_destroy callbacks" do
|
50
|
+
assert @blog.called_before_destroy
|
51
|
+
end
|
52
|
+
should "call after_destroy callbacks" do
|
53
|
+
assert @blog.called_after_destroy
|
54
|
+
end
|
55
|
+
should "call after_commit_on_destroy callbacks" do
|
56
|
+
assert @blog.called_after_commit_on_destroy
|
57
|
+
end
|
58
|
+
|
24
59
|
end
|
25
60
|
|
26
|
-
should 'fire destroy callbacks'
|
27
61
|
should 'hard delete with destroy!'
|
28
62
|
end
|
29
63
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delete_paranoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Sonnek
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-01 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|