public
Description: Rails Plugin - soft-delete your ActiveRecord records with a deleted_at timestamp. This is a much more explicit version of ActsAsParanoid
Homepage: http://6brand.com
Clone URL: git://github.com/JackDanger/permanent_records.git
updating permanent records plugin.  Seems some of the logic got switched 
in the tests.  Using better variable names to prevent this in the future.  
Not as funny, but good for business.

git-svn-id: http://svn.6brand.com/projects/plugins/permanent_records@393 
7491b73d-821b-0410-9297-ad1f6b5b4194
studioda (author)
Mon Feb 18 12:38:57 -0800 2008
commit  fb19a7c1cc6f1a38c7a6a15cf4b8ca36768a7b19
tree    4a45519f35647da22b37eaaabaf52a7fe0938dfd
parent  61068bacf4a1ab4db70cb749b3a14efe3847b0d2
...
1
2
3
4
...
51
52
53
54
 
55
56
57
...
 
1
2
3
...
50
51
52
 
53
54
55
56
0
@@ -1,4 +1,3 @@
0
-require 'active_record'
0
 module PermanentRecords
0
 
0
   def self.included(base)
0
@@ -51,7 +50,7 @@ module PermanentRecords
0
     end
0
     
0
     def revive
0
- return self if is_permanent?
0
+ return self unless is_permanent?
0
       record = self.class.find(id)
0
       record.update_attribute(:deleted_at, nil)
0
       record
...
7
8
9
10
11
12
 
 
 
13
14
15
...
19
20
21
22
 
23
24
25
26
27
 
28
29
30
31
 
32
33
34
35
 
36
37
38
39
 
40
41
42
43
 
44
45
46
47
 
48
49
50
51
 
52
53
54
55
 
56
57
58
59
 
60
61
62
63
 
64
65
66
...
7
8
9
 
 
 
10
11
12
13
14
15
...
19
20
21
 
22
23
24
25
26
 
27
28
29
30
 
31
32
33
34
 
35
36
37
38
 
39
40
41
42
 
43
44
45
46
 
47
48
49
50
 
51
52
53
54
 
55
56
57
58
 
59
60
61
62
 
63
64
65
66
0
@@ -7,9 +7,9 @@ class PermanentRecordsTest < Test::Unit::TestCase
0
   def setup
0
     super
0
     Muskrat.delete_all
0
- @wakko = Muskrat.create!(:name => 'Wakko')
0
- @yakko = Muskrat.create!(:name => 'Yakko', :deleted_at => 4.days.ago)
0
- @dot = Muskrat.create!(:name => 'Dot')
0
+ @active = Muskrat.create!(:name => 'Wakko')
0
+ @deleted = Muskrat.create!(:name => 'Yakko', :deleted_at => 4.days.ago)
0
+ @the_girl = Muskrat.create!(:name => 'Dot')
0
     Kitty.delete_all
0
     @kitty = Kitty.create!(:name => 'Meow Meow')
0
   end
0
@@ -19,48 +19,48 @@ class PermanentRecordsTest < Test::Unit::TestCase
0
   end
0
   
0
   def test_destroy_should_return_the_record
0
- muskrat = @yakko
0
+ muskrat = @deleted
0
     assert_equal muskrat, muskrat.destroy
0
   end
0
 
0
   def test_destroy_should_set_deleted_at_attribute
0
- assert @yakko.destroy.deleted_at
0
+ assert @active.destroy.deleted_at
0
   end
0
   
0
   def test_destroy_should_save_deleted_at_attribute
0
- assert Muskrat.find(@yakko.destroy.id).deleted_at
0
+ assert Muskrat.find(@active.destroy.id).deleted_at
0
   end
0
   
0
   def test_destroy_should_freeze_record
0
- assert @yakko.destroy.frozen?
0
+ assert @active.destroy.frozen?
0
   end
0
   
0
   def test_destroy_should_not_really_remove_the_record
0
- assert Muskrat.find(@yakko.destroy.id)
0
+ assert Muskrat.find(@active.destroy.id)
0
   end
0
   
0
   def test_destroy_should_recognize_a_force_parameter
0
- assert_raises(ActiveRecord::RecordNotFound) { @yakko.destroy(:force).reload }
0
+ assert_raises(ActiveRecord::RecordNotFound) { @active.destroy(:force).reload }
0
   end
0
   
0
   def test_destroy_should_ignore_other_parameters
0
- assert Muskrat.find(@yakko.destroy(:hula_dancer).id)
0
+ assert Muskrat.find(@active.destroy(:hula_dancer).id)
0
   end
0
   
0
   def test_revive_should_unfreeze_record
0
- assert !@wakko.revive.frozen?
0
+ assert !@deleted.revive.frozen?
0
   end
0
   
0
   def test_revive_should_unset_deleted_at
0
- assert !@wakko.revive.deleted_at
0
+ assert !@deleted.revive.deleted_at
0
   end
0
   
0
   def test_revive_should_make_deleted_return_false
0
- assert !@wakko.revive.deleted?
0
+ assert !@deleted.revive.deleted?
0
   end
0
   
0
   def test_deleted_returns_true_for_deleted_records
0
- assert @yakko.deleted?
0
+ assert @deleted.deleted?
0
   end
0
   
0
   def test_with_deleted_limits_scope_to_deleted_records

Comments

    No one has commented yet.