slugable 0.0.3 → 0.0.4

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.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.0.4 (May 30, 2013)
2
+ ## fixed
3
+ * `to_slug` method not skip nil in path
4
+
1
5
  # 0.0.3 (March 04, 2013)
2
6
  ## added
3
7
  * config for allowing or disabling caching
@@ -101,9 +101,9 @@ module Slugable
101
101
  # def to_slug
102
102
  # if respond_to?(:path_ids)
103
103
  # slugs = if true
104
- # path_ids.map{|id| self.class.cached_slug(id)}.select{|i| i.size > 0 }
104
+ # path_ids.map{|id| self.class.cached_slug(id)}.compact.select{|i| i.size > 0 }
105
105
  # else
106
- # path.map{|record| record.send(:"slug")}.select{|i| i.size > 0 }
106
+ # path.map{|record| record.send(:"slug")}.compact.select{|i| i.size > 0 }
107
107
  # end
108
108
  # slugs.empty? ? "" : slugs
109
109
  # else
@@ -114,9 +114,9 @@ module Slugable
114
114
  def to_#{to}
115
115
  if respond_to?(:path_ids)
116
116
  slugs = if #{cache_tree}
117
- path_ids.map{|id| self.class.cached_#{to}(id)}.select{|i| i.size > 0 }
117
+ path_ids.map{|id| self.class.cached_#{to}(id)}.compact.select{|i| i.size > 0 }
118
118
  else
119
- path.map{|record| record.send(:"#{to}")}.select{|i| i.size > 0 }
119
+ path.map{|record| record.send(:"#{to}")}.compact.select{|i| i.size > 0 }
120
120
  end
121
121
  slugs.empty? ? "" : slugs
122
122
  else
@@ -1,3 +1,3 @@
1
1
  module Slugable
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -144,6 +144,18 @@ describe Slugable::HasSlug do
144
144
 
145
145
  child.to_slug.should eq ["root", "child"]
146
146
  end
147
+
148
+ it "should skip nil values from slug path" do
149
+ root = Category.create!(:name => "root", :slug => "root")
150
+ child = Category.new(:name => "child", :slug => "child")
151
+ child.parent = root
152
+ child.save!
153
+
154
+ Category.update_all({:slug => nil}, {:id => root.id})
155
+ Category.clear_cached_slugs
156
+
157
+ child.to_slug.should eq ["child"]
158
+ end
147
159
  end
148
160
  end
149
161
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slugable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-04 00:00:00.000000000 Z
12
+ date: 2013-05-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -159,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
159
  version: '0'
160
160
  segments:
161
161
  - 0
162
- hash: 2198894308197098802
162
+ hash: -494734928332233680
163
163
  required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  none: false
165
165
  requirements:
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  segments:
170
170
  - 0
171
- hash: 2198894308197098802
171
+ hash: -494734928332233680
172
172
  requirements: []
173
173
  rubyforge_project:
174
174
  rubygems_version: 1.8.24