friendly_id 1.9.9 → 2.0.0

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
@@ -1,12 +1,13 @@
1
- == RELEASE DATE COMING SOON
1
+ == 2.0.0 2009-01-03
2
2
 
3
- * FriendlyId 2.0 Released
3
+ * 5 major enhancements:
4
4
  * Support for scoped slugs (Norman Clarke)
5
5
  * Support for UTF-8 friendly_ids (Norman Clarke)
6
6
  * Can now be installed via Ruby Gems, or as a Rails plugin (Norman Clarke)
7
- * Shoulda macro ({Josh Nichols}[http://github.com/technicalpickles])
8
7
  * Improved handling of non-unique slugs (Norman Clarke and Adrian Mugnolo)
9
- * Various small bugfixes, cleanups and refactorings (Norman Clarke and Emilio Tagua)
8
+ * 2 minor enhancements:
9
+ * Shoulda macro (Josh Nichols - http://github.com/technicalpickles)
10
+ * Various small bugfixes, cleanups and refactorings
10
11
 
11
12
  == 2008-12-01
12
13
 
@@ -3,16 +3,6 @@ MIT-LICENSE
3
3
  Manifest.txt
4
4
  README.rdoc
5
5
  Rakefile
6
- coverage/index.html
7
- coverage/lib-friendly_id-non_sluggable_class_methods_rb.html
8
- coverage/lib-friendly_id-non_sluggable_instance_methods_rb.html
9
- coverage/lib-friendly_id-shoulda_macros_rb.html
10
- coverage/lib-friendly_id-sluggable_class_methods_rb.html
11
- coverage/lib-friendly_id-sluggable_instance_methods_rb.html
12
- coverage/lib-friendly_id-string_helpers_rb.html
13
- coverage/lib-friendly_id_rb.html
14
- coverage/lib-slug_rb.html
15
- coverage/rails-init_rb.html
16
6
  friendly_id.gemspec
17
7
  generators/friendly_id/friendly_id_generator.rb
18
8
  generators/friendly_id/templates/create_slugs.rb
@@ -20,6 +10,7 @@ generators/friendly_id_20_upgrade/friendly_id_20_upgrade_generator.rb
20
10
  generators/friendly_id_20_upgrade/templates/upgrade_friendly_id_to_20.rb
21
11
  init.rb
22
12
  lib/friendly_id.rb
13
+ lib/friendly_id/helpers.rb
23
14
  lib/friendly_id/non_sluggable_class_methods.rb
24
15
  lib/friendly_id/non_sluggable_instance_methods.rb
25
16
  lib/friendly_id/shoulda_macros.rb
@@ -213,12 +213,18 @@ that uses a non-Roman writing system, your feedback would be most welcome.
213
213
 
214
214
  FriendlyId is installed as a Ruby Gem:
215
215
 
216
- gem install friendly-id
216
+ gem install friendly_id
217
217
 
218
218
  Alternatively, you can install it as a Rails plugin, though this is
219
219
  discouraged:
220
220
 
221
- ./script/plugin install git://github.com/norman/friendly_id.git
221
+ ./script/plugin install git://github.com/norman/friendly_id.git
222
+
223
+ If you are installing as a plugin, make sure you have installed the unicode gem,
224
+ which FriendlyId depends on:
225
+
226
+ gem install unicode
227
+
222
228
 
223
229
  == Setting it up
224
230
 
@@ -226,7 +232,7 @@ FriendlyId currently works with Rails 2.0.0 and higher. Here's how to set it up.
226
232
 
227
233
  1) Install the Gem:
228
234
 
229
- sudo gem install friendly-id
235
+ sudo gem install friendly_id
230
236
  cd my_app
231
237
  script/generate friendly_id
232
238
  rake db:migrate
@@ -264,15 +270,15 @@ rake:friendly_id:remove_old_slugs MODEL=MyModelName DAYS=60
264
270
  If you installed an older version of FriendlyId and want to upgrade to 2.0,
265
271
  follow these steps:
266
272
 
267
- ==== Install the friendly-id Gem:
273
+ ==== Install the friendly_id Gem:
274
+
275
+ sudo gem install friendly_id
268
276
 
269
- sudo gem install friendly-id
270
-
271
277
  ==== Add FriendlyId to environment.rb:
272
278
 
273
279
  ===== For Rails 2.1 and higher:
274
280
 
275
- config.gem "friendly_id", :version => ">= 2.0.0"
281
+ config.gem "friendly_id"
276
282
 
277
283
  ===== For Rails 2.0:
278
284
 
@@ -293,7 +299,6 @@ Add this to the bottom of environment.rb:
293
299
 
294
300
  That's it!
295
301
 
296
-
297
302
  == Hacking FriendlyId:
298
303
 
299
304
  FriendlyId is {hosted on Github}[git://github.com/norman/friendly_id.git], and
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
- require 'hoe'
2
-
3
- require File.join(File.dirname(__FILE__), 'lib', 'friendly_id', 'version')
1
+ require 'newgem'
2
+ require 'lib/friendly_id/version'
4
3
 
5
4
  Hoe.new("friendly_id", FriendlyId::Version::STRING) do |p|
6
5
  p.rubyforge_name = "friendly-id"
@@ -13,6 +12,9 @@ Hoe.new("friendly_id", FriendlyId::Version::STRING) do |p|
13
12
  p.need_zip = true
14
13
  p.test_globs = ['test/**/*_test.rb']
15
14
  p.extra_deps << ['unicode', '>= 0.1']
15
+ p.extra_dev_deps = [
16
+ ['newgem', ">= #{::Newgem::VERSION}"]
17
+ ]
16
18
  p.rdoc_pattern = /^(lib|bin|ext)|txt|rdoc$/
17
19
  changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
18
20
  p.remote_rdoc_dir = ""
@@ -1,15 +1,15 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{friendly_id}
3
- s.version = "1.9.9"
3
+ s.version = "2.0.0"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Norman Clarke", "Adrian Mugnolo", "Emilio Tagua"]
7
7
  s.cert_chain = ["/Users/norman/.gem/gem-public_cert.pem"]
8
- s.date = %q{2008-12-16}
8
+ s.date = %q{2008-12-30}
9
9
  s.description = %q{A comprehensive slugging and pretty-URL plugin for Ruby on Rails.}
10
10
  s.email = ["norman@randomba.org", "adrian@randomba.org", "miloops@gmail.com"]
11
11
  s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
12
- s.files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "coverage/index.html", "coverage/lib-friendly_id-non_sluggable_class_methods_rb.html", "coverage/lib-friendly_id-non_sluggable_instance_methods_rb.html", "coverage/lib-friendly_id-shoulda_macros_rb.html", "coverage/lib-friendly_id-sluggable_class_methods_rb.html", "coverage/lib-friendly_id-sluggable_instance_methods_rb.html", "coverage/lib-friendly_id-string_helpers_rb.html", "coverage/lib-friendly_id_rb.html", "coverage/lib-slug_rb.html", "coverage/rails-init_rb.html", "friendly_id.gemspec", "generators/friendly_id/friendly_id_generator.rb", "generators/friendly_id/templates/create_slugs.rb", "init.rb", "lib/friendly_id.rb", "lib/friendly_id/non_sluggable_class_methods.rb", "lib/friendly_id/non_sluggable_instance_methods.rb", "lib/friendly_id/shoulda_macros.rb", "lib/friendly_id/slug.rb", "lib/friendly_id/sluggable_class_methods.rb", "lib/friendly_id/sluggable_instance_methods.rb", "lib/friendly_id/version.rb", "lib/tasks/friendly_id.rake", "lib/tasks/friendly_id.rb", "test/database.yml", "test/fixtures/countries.yml", "test/fixtures/country.rb", "test/fixtures/people.yml", "test/fixtures/person.rb", "test/fixtures/post.rb", "test/fixtures/posts.yml", "test/fixtures/slugs.yml", "test/fixtures/user.rb", "test/fixtures/users.yml", "test/non_slugged_test.rb", "test/rails/2.x/app/controllers/application.rb", "test/rails/2.x/config/boot.rb", "test/rails/2.x/config/database.yml", "test/rails/2.x/config/environment.rb", "test/rails/2.x/config/environments/test.rb", "test/rails/2.x/config/routes.rb", "test/schema.rb", "test/scoped_model_test.rb", "test/slug_test.rb", "test/sluggable_test.rb", "test/test_helper.rb"]
12
+ s.files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "friendly_id.gemspec", "generators/friendly_id/friendly_id_generator.rb", "generators/friendly_id/templates/create_slugs.rb", "generators/friendly_id_20_upgrade/friendly_id_20_upgrade_generator.rb", "generators/friendly_id_20_upgrade/templates/upgrade_friendly_id_to_20.rb", "init.rb", "lib/friendly_id.rb", "lib/friendly_id/helpers.rb", "lib/friendly_id/non_sluggable_class_methods.rb", "lib/friendly_id/non_sluggable_instance_methods.rb", "lib/friendly_id/shoulda_macros.rb", "lib/friendly_id/slug.rb", "lib/friendly_id/sluggable_class_methods.rb", "lib/friendly_id/sluggable_instance_methods.rb", "lib/friendly_id/version.rb", "lib/tasks/friendly_id.rake", "lib/tasks/friendly_id.rb", "test/database.yml", "test/fixtures/countries.yml", "test/fixtures/country.rb", "test/fixtures/people.yml", "test/fixtures/person.rb", "test/fixtures/post.rb", "test/fixtures/posts.yml", "test/fixtures/slugs.yml", "test/fixtures/user.rb", "test/fixtures/users.yml", "test/non_slugged_test.rb", "test/rails/2.x/app/controllers/application.rb", "test/rails/2.x/config/boot.rb", "test/rails/2.x/config/database.yml", "test/rails/2.x/config/environment.rb", "test/rails/2.x/config/environments/test.rb", "test/rails/2.x/config/routes.rb", "test/schema.rb", "test/scoped_model_test.rb", "test/slug_test.rb", "test/sluggable_test.rb", "test/test_helper.rb"]
13
13
  s.has_rdoc = true
14
14
  s.homepage = %q{http://randomba.org}
15
15
  s.rdoc_options = ["--main", "README.txt"]
@@ -1,17 +1,12 @@
1
1
  require 'unicode'
2
+ require 'friendly_id/helpers'
2
3
  require 'friendly_id/slug'
3
4
  require 'friendly_id/shoulda_macros'
4
5
 
6
+
5
7
  # FriendlyId is a comprehensize Rails plugin/gem for slugging and permalinks.
6
8
  module FriendlyId
7
9
 
8
- # Load FriendlyId if the gem is included in a Rails app.
9
- def self.enable
10
- return if ActiveRecord::Base.methods.include? 'has_friendly_id'
11
- ActiveRecord::Base.class_eval { extend FriendlyId::ClassMethods }
12
- Test::Unit::TestCase.class_eval { include FriendlyId::ShouldaMacros }
13
- end
14
-
15
10
  # This error is raised when it's not possible to generate a unique slug.
16
11
  class SlugGenerationError < StandardError ; end
17
12
 
@@ -38,7 +33,7 @@ module FriendlyId
38
33
  class_inheritable_reader :friendly_id_options
39
34
 
40
35
  if options[:use_slug]
41
- has_many :slugs, :order => 'id DESC', :as => :sluggable, :dependent => :destroy
36
+ has_many :slugs, :order => 'id DESC', :as => :sluggable, :dependent => :destroy, :readonly => true
42
37
  require 'friendly_id/sluggable_class_methods'
43
38
  require 'friendly_id/sluggable_instance_methods'
44
39
  extend SluggableClassMethods
@@ -54,6 +49,18 @@ module FriendlyId
54
49
 
55
50
  end
56
51
 
52
+ class << self
53
+
54
+ # Load FriendlyId if the gem is included in a Rails app.
55
+ def enable
56
+ return if ActiveRecord::Base.methods.include? 'has_friendly_id'
57
+ ActiveRecord::Base.class_eval { extend FriendlyId::ClassMethods }
58
+ Test::Unit::TestCase.class_eval { include FriendlyId::ShouldaMacros }
59
+ end
60
+
61
+ end
62
+
63
+
57
64
  end
58
65
 
59
66
  if defined?(ActiveRecord)
@@ -0,0 +1,13 @@
1
+ module FriendlyId
2
+
3
+ module Helpers
4
+ # Calculate expected result size for find_some_with_friendly (taken from
5
+ # active_record/base.rb)
6
+ def expected_size(ids_and_names, options) #:nodoc:#
7
+ size = options[:offset] ? ids_and_names.size - options[:offset] : ids_and_names.size
8
+ size = options[:limit] if options[:limit] && size > options[:limit]
9
+ size
10
+ end
11
+ end
12
+
13
+ end
@@ -1,5 +1,7 @@
1
1
  module FriendlyId::NonSluggableClassMethods
2
2
 
3
+ include FriendlyId::Helpers
4
+
3
5
  def self.extended(base) #:nodoc:#
4
6
  class << base
5
7
  alias_method_chain :find_one, :friendly
@@ -19,23 +21,20 @@ module FriendlyId::NonSluggableClassMethods
19
21
  end
20
22
 
21
23
  def find_some_with_friendly(ids_and_names, options) #:nodoc:#
22
- results_by_name = with_scope :find => options do
23
- find :all, :conditions => ["#{ quoted_table_name }.#{ friendly_id_options[:column] } IN (?)", ids_and_names]
24
+
25
+ results = with_scope :find => options do
26
+ find :all, :conditions => ["#{ quoted_table_name }.#{ primary_key } IN (?) OR #{friendly_id_options[:column].to_s} IN (?)",
27
+ ids_and_names, ids_and_names]
24
28
  end
29
+
30
+ expected = expected_size(ids_and_names, options)
31
+ if results.size != expected
32
+ raise ActiveRecord::RecordNotFound, "Couldn't find all #{ name.pluralize } with IDs (#{ ids_and_names * ', ' }) AND #{ sanitize_sql options[:conditions] } (found #{ results.size } results, but was looking for #{ expected })"
33
+ end
34
+
35
+ results.each {|r| r.send(:found_using_friendly_id=, true) if ids_and_names.include?(r.friendly_id)}
25
36
 
26
- ids = ids_and_names - results_by_name.map { |r| r[ friendly_id_options[:column] ] }
27
- results = results_by_name
28
-
29
- results += with_scope :find => options do
30
- find :all, :conditions => ["#{ quoted_table_name }.#{ primary_key } IN (?)", ids]
31
- end unless ids.empty?
32
-
33
- expected_size = options[:offset] ? ids_and_names.size - options[:offset] : ids_and_names.size
34
- expected_size = options[:limit] if options[:limit] && expected_size > options[:limit]
35
-
36
- raise ActiveRecord::RecordNotFound, "Couldn't find all #{ name.pluralize } with IDs (#{ ids_and_names * ', ' }) AND #{ sanitize_sql options[:conditions] } (found #{ results.size } results, but was looking for #{ expected_size })" if results.size != expected_size
37
-
38
- results_by_name.each { |r| r.send(:found_using_friendly_id=, true) }
39
37
  results
38
+
40
39
  end
41
40
  end
@@ -2,9 +2,7 @@
2
2
  class Slug < ActiveRecord::Base
3
3
 
4
4
  belongs_to :sluggable, :polymorphic => true
5
- validates_uniqueness_of :name, :scope => [:sluggable_type, :scope, :sequence]
6
- before_create :set_sequence
7
- before_save :check_for_blank_name
5
+ before_save :check_for_blank_name, :set_sequence
8
6
 
9
7
  class << self
10
8
 
@@ -81,6 +79,7 @@ class Slug < ActiveRecord::Base
81
79
  end
82
80
 
83
81
  def set_sequence
82
+ return unless new_record?
84
83
  last = Slug.find(:first, :conditions => { :name => name, :scope => scope,
85
84
  :sluggable_type => sluggable_type}, :order => "sequence DESC",
86
85
  :select => 'sequence')
@@ -1,4 +1,6 @@
1
1
  module FriendlyId::SluggableClassMethods
2
+
3
+ include FriendlyId::Helpers
2
4
 
3
5
  def self.extended(base) #:nodoc:#
4
6
 
@@ -48,11 +50,10 @@ module FriendlyId::SluggableClassMethods
48
50
  find_options = {:select => "#{self.table_name}.*"}
49
51
  find_options[:joins] = :slugs unless options[:include] && [*options[:include]].flatten.include?(:slugs)
50
52
  find_options[:conditions] = "#{quoted_table_name}.#{primary_key} IN (#{ids.empty? ? 'NULL' : ids.join(',')}) "
51
- find_options[:conditions] << "OR #{Slug.quoted_table_name}.#{Slug.primary_key} IN (#{slugs.to_s(:db)})"
53
+ find_options[:conditions] << "OR slugs.id IN (#{slugs.to_s(:db)})"
52
54
 
53
55
  results = with_scope(:find => find_options) { find_every(options) }
54
56
 
55
- # calculate expected size, taken from active_record/base.rb
56
57
  expected = expected_size(ids_and_names, options)
57
58
  if results.size != expected
58
59
  raise ActiveRecord::RecordNotFound, "Couldn't find all #{ name.pluralize } with IDs (#{ ids_and_names * ', ' }) AND #{ sanitize_sql options[:conditions] } (found #{ results.size } results, but was looking for #{ expected })"
@@ -79,13 +80,6 @@ module FriendlyId::SluggableClassMethods
79
80
  end
80
81
  end
81
82
 
82
- # Calculate expected result size for find_some_with_friendly
83
- def expected_size(ids_and_names, options) #:nodoc:#
84
- size = options[:offset] ? ids_and_names.size - options[:offset] : ids_and_names.size
85
- size = options[:limit] if options[:limit] && size > options[:limit]
86
- size
87
- end
88
-
89
83
  # Build arrays of slugs and ids, for the find_some_with_friendly method.
90
84
  def get_slugs_and_ids(ids_and_names, options) #:nodoc:#
91
85
  scope = options.delete(:scope)
@@ -53,23 +53,6 @@ module FriendlyId::SluggableInstanceMethods
53
53
  slug ? slug.to_friendly_id : id.to_s
54
54
  end
55
55
 
56
- # Set the slug using the generated friendly id.
57
- def set_slug
58
- if self.class.friendly_id_options[:use_slug] && new_slug_needed?
59
- @most_recent_slug = nil
60
- slug_attributes = {:name => slug_text}
61
- if friendly_id_options[:scope]
62
- scope = send(friendly_id_options[:scope])
63
- slug_attributes[:scope] = scope.respond_to?(:to_param) ? scope.to_param : scope.to_s
64
- end
65
- # If we're renaming back to a previously used friendly_id, delete the
66
- # slug so that we can recycle the name without having to use a sequence.
67
- slugs.find(:all, :conditions => {:name => slug_text, :scope => scope}).each { |s| s.destroy }
68
- s = slugs.build slug_attributes
69
- s.send(:set_sequence)
70
- end
71
- end
72
-
73
56
  # Get the processed string used as the basis of the friendly id.
74
57
  def slug_text
75
58
  base = send friendly_id_options[:column]
@@ -98,8 +81,25 @@ module FriendlyId::SluggableInstanceMethods
98
81
 
99
82
  def init_finder_slug
100
83
  return false if !@finder_slug_name
101
- slug = Slug.find(:first, :conditions => {:sluggable_id => id, :name => @finder_slug_name})
84
+ slug = Slug.find(:first, :conditions => {:sluggable_id => id, :name => @finder_slug_name, :sluggable_type => self.class.name })
102
85
  finder_slug = slug
103
86
  end
104
87
 
88
+ # Set the slug using the generated friendly id.
89
+ def set_slug
90
+ if self.class.friendly_id_options[:use_slug] && new_slug_needed?
91
+ @most_recent_slug = nil
92
+ slug_attributes = {:name => slug_text}
93
+ if friendly_id_options[:scope]
94
+ scope = send(friendly_id_options[:scope])
95
+ slug_attributes[:scope] = scope.respond_to?(:to_param) ? scope.to_param : scope.to_s
96
+ end
97
+ # If we're renaming back to a previously used friendly_id, delete the
98
+ # slug so that we can recycle the name without having to use a sequence.
99
+ slugs.find(:all, :conditions => {:name => slug_text, :scope => scope}).each { |s| s.destroy }
100
+ slug = slugs.build slug_attributes
101
+ slug
102
+ end
103
+ end
104
+
105
105
  end
@@ -1,8 +1,8 @@
1
1
  module FriendlyId #:nodoc:
2
2
  module Version #:nodoc:
3
- MAJOR = 1
4
- MINOR = 9
5
- TINY = 9
3
+ MAJOR = 2
4
+ MINOR = 0
5
+ TINY = 0
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
  end
8
8
  end
@@ -8,7 +8,7 @@ namespace :friendly_id do
8
8
  while records = sluggable_class.find(:all, :include => :slugs, :conditions => "slugs.id IS NULL", :limit => 1000) do
9
9
  break if records.size == 0
10
10
  records.each do |r|
11
- r.set_slug
11
+ r.send(:set_slug)
12
12
  r.save!
13
13
  puts "#{sluggable_class.to_s}(#{r.id}) friendly_id set to \"#{r.slug.name}\""
14
14
  end
@@ -16,4 +16,8 @@ common_title:
16
16
 
17
17
  common_title2:
18
18
  name: Common Title
19
- content: A second post with a very common title
19
+ content: A second post with a very common title
20
+
21
+ john_smith:
22
+ name: John Smith
23
+ content: Should allow for identical slug names between sluggable types
@@ -1,3 +1,11 @@
1
+ post_with_same_friendly_id_as_person:
2
+ name: john-smith
3
+ sluggable: john_smith (Post)
4
+
5
+ person_with_same_friendly_id_as_post:
6
+ name: john-smith
7
+ sluggable: john_smith (Person)
8
+
1
9
  one:
2
10
  name: with-one-slug
3
11
  sluggable: with_one_slug
@@ -11,24 +11,39 @@ class NonSluggedTest < Test::Unit::TestCase
11
11
  assert User.find(users(:joe).friendly_id)
12
12
  end
13
13
 
14
- def test_to_param_should_return_a_string
15
- assert_equal String, users(:joe).to_param.class
14
+ def test_should_find_users_using_friendly_id
15
+ assert User.find([users(:joe).friendly_id])
16
16
  end
17
17
 
18
- def test_should_find_users_using_friendly_ids
19
- assert_equal 2, User.find([users(:joe).friendly_id, users(:jane).friendly_id]).length
18
+ def test_to_param_should_return_a_string
19
+ assert_equal String, users(:joe).to_param.class
20
20
  end
21
21
 
22
22
  def test_should_not_find_users_using_non_existent_friendly_ids
23
23
  assert_raises ActiveRecord::RecordNotFound do
24
- User.find(['non-existent-slug', 'yet-another-non-existent-slug'])
24
+ User.find(['bad', 'bad2'])
25
25
  end
26
26
  end
27
+
28
+ def test_finding_by_array_with_friendly_and_non_friendly_id_for_same_record_raises_error
29
+ assert_raises ActiveRecord::RecordNotFound do
30
+ User.find([users(:joe).id, "joe"]).size
31
+ end
32
+ end
33
+
34
+ def test_finding_with_mixed_array_should_indicate_whether_found_by_numeric_or_friendly
35
+ @users = User.find([users(:jane).id, "joe"], :order => "login ASC")
36
+ assert @users[0].found_using_numeric_id?
37
+ assert @users[1].found_using_friendly_id?
38
+ end
27
39
 
28
40
  def test_finder_options_are_not_ignored
29
41
  assert_raises ActiveRecord::RecordNotFound do
30
42
  User.find(users(:joe).friendly_id, :conditions => "1 = 2")
31
43
  end
44
+ assert_raises ActiveRecord::RecordNotFound do
45
+ User.find([users(:joe).friendly_id], :conditions => "1 = 2")
46
+ end
32
47
  end
33
48
 
34
49
  def test_user_should_have_friendly_id_options
@@ -36,8 +51,12 @@ class NonSluggedTest < Test::Unit::TestCase
36
51
  end
37
52
 
38
53
  def test_user_should_not_be_found_using_friendly_id_unless_it_really_was
39
- @user = User.new
40
- assert !@user.found_using_friendly_id?
54
+ assert !User.find(users(:joe).id).found_using_friendly_id?
55
+ end
56
+
57
+ def test_users_should_not_be_found_using_friendly_id_unless_they_really_were
58
+ @users = User.find([users(:jane).id])
59
+ assert @users[0].found_using_numeric_id?
41
60
  end
42
61
 
43
62
  def test_user_should_be_considered_found_by_numeric_id_as_default
@@ -48,15 +67,18 @@ class NonSluggedTest < Test::Unit::TestCase
48
67
  def test_user_should_indicate_if_it_was_found_using_numeric_id
49
68
  @user = User.find(users(:joe).id)
50
69
  assert @user.found_using_numeric_id?
70
+ assert !@user.found_using_friendly_id?
51
71
  end
52
72
 
53
73
  def test_user_should_indicate_if_it_was_found_using_friendly_id
54
74
  @user = User.find(users(:joe).friendly_id)
75
+ assert !@user.found_using_numeric_id?
55
76
  assert @user.found_using_friendly_id?
56
77
  end
57
78
 
58
79
  def test_should_indicate_there_is_a_better_id_if_found_by_numeric_id
59
80
  @user = User.find(users(:joe).id)
81
+ assert @user.found_using_numeric_id?
60
82
  assert @user.has_better_id?
61
83
  end
62
84