delete_paranoid 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,11 +24,11 @@ module DeleteParanoid
24
24
  with_transaction_returning_status do
25
25
  _run_destroy_callbacks do
26
26
  update_attributes(:deleted_at => Time.now.utc)
27
+ @destroyed = true
27
28
  end
28
29
  end
29
30
  end
30
-
31
- @destroyed = true
31
+
32
32
  freeze
33
33
  end
34
34
  end
@@ -1,3 +1,3 @@
1
1
  module DeleteParanoid
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
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-03-30 00:00:00 -05:00
18
+ date: 2011-04-01 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency