semanticart-is_paranoid 0.9.4 → 0.9.5

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.
data/CHANGELOG CHANGED
@@ -1,5 +1,8 @@
1
1
  This will only document major changes. Please see the commit log for minor changes.
2
2
 
3
+ -2009-09-18
4
+ * making is_paranoid play nice with habtm relationships
5
+
3
6
  -2009-09-17
4
7
  * fixed when primary key was not "id" (ie: "uuid") via Thibaud Guillaume-Gentil
5
8
 
@@ -34,4 +37,4 @@ This will only document major changes. Please see the commit log for minor chan
34
37
  * requiring specific syntax to include calculations
35
38
 
36
39
  -2009-03-21
37
- * initial release
40
+ * initial release
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 9
3
- :patch: 4
3
+ :patch: 5
4
4
  :major: 0
data/is_paranoid.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{is_paranoid}
8
- s.version = "0.9.4"
8
+ s.version = "0.9.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeffrey Chupp"]
12
- s.date = %q{2009-09-17}
12
+ s.date = %q{2009-09-18}
13
13
  s.description = %q{}
14
14
  s.email = %q{jeff@semanticart.com}
15
15
  s.extra_rdoc_files = [
data/lib/is_paranoid.rb CHANGED
@@ -209,7 +209,7 @@ module IsParanoid
209
209
  end
210
210
 
211
211
  # Mark the model deleted_at as now.
212
- def destroy_without_callbacks
212
+ def alt_destroy_without_callbacks
213
213
  self.class.update_all(
214
214
  "#{destroyed_field} = #{self.class.connection.quote(( field_destroyed.respond_to?(:call) ? field_destroyed.call : field_destroyed))}",
215
215
  self.class.primary_key.to_sym => self.id
@@ -224,7 +224,7 @@ module IsParanoid
224
224
  # separately.
225
225
  def destroy
226
226
  return false if callback(:before_destroy) == false
227
- result = destroy_without_callbacks
227
+ result = alt_destroy_without_callbacks
228
228
  callback(:after_destroy)
229
229
  self
230
230
  end
@@ -17,6 +17,8 @@ describe IsParanoid do
17
17
 
18
18
  @r2d2.memories.create(:name => 'A pretty sunset')
19
19
  @c3p0.sticker = Sticker.create(:name => 'OMG, PONIES!')
20
+ @tatooine = Place.create(:name => "Tatooine")
21
+ @r2d2.places << @tatooine
20
22
  end
21
23
 
22
24
  describe 'non-is_paranoid models' do
@@ -69,6 +71,14 @@ describe IsParanoid do
69
71
  }.should change(Android, :count).from(2).to(0)
70
72
  Android.count_with_destroyed.should == 2
71
73
  end
74
+
75
+ it "should not choke has_and_belongs_to_many relationships" do
76
+ @r2d2.places.should include(@tatooine)
77
+ @tatooine.destroy
78
+ @r2d2.reload
79
+ @r2d2.places.should_not include(@tatooine)
80
+ Place.all_with_destroyed.should include(@tatooine)
81
+ end
72
82
  end
73
83
  end
74
84
 
data/spec/models.rb CHANGED
@@ -8,6 +8,7 @@ class Android < ActiveRecord::Base #:nodoc:
8
8
  has_many :components, :dependent => :destroy
9
9
  has_one :sticker
10
10
  has_many :memories, :foreign_key => 'parent_id'
11
+ has_and_belongs_to_many :places
11
12
 
12
13
  is_paranoid
13
14
 
@@ -41,7 +42,7 @@ class Memory < ActiveRecord::Base #:nodoc:
41
42
  belongs_to :android, :class_name => "Android", :foreign_key => "parent_id"
42
43
  end
43
44
 
44
- class Sticker < ActiveRecord::Base #:nodoc
45
+ class Sticker < ActiveRecord::Base #:nodoc:
45
46
  MM_NAME = "You've got method_missing"
46
47
 
47
48
  # this simply serves to ensure that we don't break method_missing
@@ -60,6 +61,14 @@ class AndroidWithScopedUniqueness < ActiveRecord::Base #:nodoc:
60
61
  is_paranoid
61
62
  end
62
63
 
64
+ class Place < ActiveRecord::Base #:nodoc:
65
+ is_paranoid
66
+ has_and_belongs_to_many :androids
67
+ end
68
+
69
+ class AndroidsPlaces < ActiveRecord::Base #:nodoc:
70
+ end
71
+
63
72
  class Ninja < ActiveRecord::Base #:nodoc:
64
73
  validates_uniqueness_of :name, :scope => :visible
65
74
  is_paranoid :field => [:visible, false, true]
data/spec/schema.rb CHANGED
@@ -7,6 +7,16 @@ ActiveRecord::Schema.define(:version => 20090317164830) do
7
7
  t.datetime "updated_at"
8
8
  end
9
9
 
10
+ create_table "androids_places", :force => true, :id => false do |t|
11
+ t.integer "android_id"
12
+ t.integer "place_id"
13
+ end
14
+
15
+ create_table "places", :force => true do |t|
16
+ t.string "name"
17
+ t.datetime "deleted_at"
18
+ end
19
+
10
20
  create_table "people", :force => true do |t|
11
21
  t.string "name"
12
22
  t.datetime "created_at"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semanticart-is_paranoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Chupp
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-17 00:00:00 -07:00
12
+ date: 2009-09-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15