jchupp-is_paranoid 0.8.0 → 0.8.1

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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 0
2
+ :patch: 1
3
3
  :major: 0
4
4
  :minor: 8
data/lib/is_paranoid.rb CHANGED
@@ -119,12 +119,15 @@ module IsParanoid
119
119
 
120
120
  self.class.send(
121
121
  :include,
122
- Module.new{ # Example:
123
- define_method name do |*args| # def android_with_destroyed
124
- parent_klass.find_with_destroyed( # Android.find_with_destroyed(
125
- self.send(assoc.primary_key_name) # self.send(:android_id)
126
- ) # )
127
- end # end
122
+ Module.new{ # Example:
123
+ define_method name do |*args| # def android_with_destroyed
124
+ parent_klass.first_with_destroyed( # Android.first_with_destroyed(
125
+ :conditions => { # :conditions => {
126
+ parent_klass.primary_key => # :id =>
127
+ self.send(assoc.primary_key_name) # self.send(:android_id)
128
+ } # }
129
+ ) # )
130
+ end # end
128
131
  }
129
132
  )
130
133
  self.send(name, *args)
@@ -167,8 +167,8 @@ describe IsParanoid do
167
167
  end
168
168
  end
169
169
 
170
- describe 'accessing destroyed parent models' do
171
- it "should be able to access destroyed parents via parent_with_destroyed" do
170
+ describe '(parent)_with_destroyed' do
171
+ it "should be able to access destroyed parents" do
172
172
  # Memory is has_many with a non-default primary key
173
173
  # Sticker is a has_one with a default primary key
174
174
  [Memory, Sticker].each do |klass|
@@ -182,6 +182,13 @@ describe IsParanoid do
182
182
  instance.android_with_destroyed.should == parent
183
183
  end
184
184
  end
185
+
186
+ it "should return nil if no destroyed parent exists" do
187
+ sticker = Sticker.new(:name => 'Rainbows')
188
+ # because the default relationship works this way, i.e.
189
+ sticker.android.should == nil
190
+ sticker.android_with_destroyed.should == nil
191
+ end
185
192
  end
186
193
 
187
194
  describe 'alternate fields and field values' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jchupp-is_paranoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Chupp