dzema_dm-counter-cache 0.9.12 → 0.9.12.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.9.12.1 / 2009-11-19
2
+
3
+ * Fix an error occured when parent object was deleted and child tries to adjust counter cache
4
+
1
5
  === 0.9.12 / 2009-11-15
2
6
 
3
7
  * Version without class_eval
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ AUTHOR = ['Saimon Moore', 'Dmitriy Dzema']
13
13
  EMAIL = ['daimonmoore [a] gmail [d] com', 'dima [a] dzema [d] name']
14
14
  GEM_NAME = 'dzema_dm-counter-cache'
15
15
  GEM_VERSION = DataMapper::CounterCacheable::VERSION
16
- GEM_DEPENDENCIES = [['dm-core', "=#{GEM_VERSION}"]]
16
+ GEM_DEPENDENCIES = [['dm-core', "=0.9.12"]]
17
17
  GEM_CLEAN = %w[ log pkg coverage ]
18
18
  GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO History.txt ] }
19
19
 
@@ -67,6 +67,7 @@ module DataMapper
67
67
  protected
68
68
  def adjust_counter_cache_for(relationship, counter_cache_attribute, amount)
69
69
  association = get_association(relationship)
70
+ return if association.nil?
70
71
 
71
72
  return unless relationship.parent_model.properties.has_property?(counter_cache_attribute)
72
73
  association.update_attributes(counter_cache_attribute => association.reload.__send__(counter_cache_attribute) + amount)
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module CounterCacheable
3
- VERSION = '0.9.12'
3
+ VERSION = '0.9.12.1'
4
4
  end
5
5
  end
@@ -84,4 +84,12 @@ describe DataMapper::CounterCacheable do
84
84
  @group.reload.members_count.should == 1
85
85
  end
86
86
 
87
+ it "should not try to adjust counter on nil relationship" do
88
+ comment = @post.comments.create
89
+ @post.destroy
90
+
91
+ lambda do
92
+ comment.reload.destroy
93
+ end.should_not raise_error(NoMethodError)
94
+ end
87
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dzema_dm-counter-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.12
4
+ version: 0.9.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saimon Moore
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-11-15 00:00:00 +10:00
13
+ date: 2009-11-19 00:00:00 +10:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements: []
87
87
 
88
88
  rubyforge_project: datamapper
89
- rubygems_version: 1.3.4
89
+ rubygems_version: 1.3.5
90
90
  signing_key:
91
91
  specification_version: 3
92
92
  summary: DataMapper plugin for counter caches ala ActiveRecord. Original idea and implementation by Saimon Moore (daimonmoore [a] gmail [d] com)