friendly_id 2.1.0 → 2.1.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.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,6 +1,14 @@
1
+ == 2.1.1 2009-03-25
2
+
3
+ * 2 minor enhancements:
4
+ * Fixed bug with find_some; if a record has old slugs, find_some will no longer return
5
+ multiple copies of that record when finding by numerical ID. (Steve Luscher)
6
+ * Fixed bug with find_some: you can now find_some with an array of numerical IDs without
7
+ an error being thrown. (Steve Luscher)
8
+
1
9
  == 2.1.0 2009-03-25
2
10
 
3
- 2 major enhancements:
11
+ * 2 major enhancements:
4
12
  * Ruby 1.9 compatibility.
5
13
  * Removed dependency on ancient Unicode gem.
6
14
 
data/friendly_id.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{friendly_id}
5
- s.version = "2.1.0"
5
+ s.version = "2.1.1"
6
6
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
7
  s.authors = ["Norman Clarke", "Adrian Mugnolo", "Emilio Tagua"]
8
8
  s.date = %q{2009-03-25}
@@ -63,7 +63,7 @@ module FriendlyId::SluggableClassMethods
63
63
  find_options[:conditions] = "#{quoted_table_name}.#{primary_key} IN (#{ids.empty? ? 'NULL' : ids.join(',')}) "
64
64
  find_options[:conditions] << "OR slugs.id IN (#{slugs.to_s(:db)})"
65
65
 
66
- results = with_scope(:find => find_options) { find_every(options) }
66
+ results = with_scope(:find => find_options) { find_every(options) }.uniq
67
67
 
68
68
  expected = expected_size(ids_and_names, options)
69
69
  if results.size != expected
@@ -97,7 +97,7 @@ module FriendlyId::SluggableClassMethods
97
97
  slugs = []
98
98
  ids = []
99
99
  ids_and_names.each do |id_or_name|
100
- name, sequence = Slug.parse id_or_name
100
+ name, sequence = Slug.parse id_or_name.to_s
101
101
  slug = Slug.find(:first, :conditions => {
102
102
  :name => name,
103
103
  :scope => scope,
@@ -106,7 +106,7 @@ module FriendlyId::SluggableClassMethods
106
106
  })
107
107
  # If the slug was found, add it to the array for later use. If not, and
108
108
  # the id_or_name is a number, assume that it is a regular record id.
109
- slug ? slugs << slug : (ids << id_or_name if id_or_name =~ /\A\d*\z/)
109
+ slug ? slugs << slug : (ids << id_or_name if id_or_name.to_s =~ /\A\d*\z/)
110
110
  end
111
111
  return slugs, ids
112
112
  end
@@ -2,7 +2,7 @@ module FriendlyId #:nodoc:
2
2
  module Version #:nodoc:
3
3
  MAJOR = 2
4
4
  MINOR = 1
5
- TINY = 0
5
+ TINY = 1
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
  end
8
8
  end
@@ -95,7 +95,7 @@ class SluggedModelTest < Test::Unit::TestCase
95
95
  @post = Post.new(:title => "katakana: ゲコゴサザシジ")
96
96
  assert_equal "katakana-ゲコゴサザシジ", @post.slug_text
97
97
  end
98
-
98
+
99
99
  should "allow the same friendly_id across models" do
100
100
  @person = Person.create!(:name => @post.title)
101
101
  assert_equal @person.friendly_id, @post.friendly_id
@@ -235,10 +235,23 @@ class SluggedModelTest < Test::Unit::TestCase
235
235
  @post2 = Post.create!(:title => "another post", :content => "more content")
236
236
  end
237
237
 
238
- should "return results" do
238
+ should "return results when passed an array of non-friendly ids" do
239
+ assert_equal 2, Post.find([@post.id, @post2.id]).size
240
+ end
241
+
242
+ should "return results when passed an array of friendly ids" do
239
243
  assert_equal 2, Post.find([@post.friendly_id, @post2.friendly_id]).size
240
244
  end
241
245
 
246
+ should "return results when passed a mixed array of friendly and non-friendly ids" do
247
+ assert_equal 2, Post.find([@post.friendly_id, @post2.id]).size
248
+ end
249
+
250
+ should "return results when passed an array of non-friendly ids, of which one represents a record with multiple slugs" do
251
+ @post2.update_attributes(:title => 'another post [updated]')
252
+ assert_equal 2, Post.find([@post.id, @post2.id]).size
253
+ end
254
+
242
255
  should "indicate that the results were found using a friendly_id" do
243
256
  @posts = Post.find [@post.friendly_id, @post2.friendly_id]
244
257
  @posts.each { |p| assert p.found_using_friendly_id? }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendly_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Norman Clarke
metadata.gz.sig CHANGED
Binary file