friendly_id 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 2.0.3 2009-02-11
2
+
3
+ * 1 minor enhancment:
4
+ * Fixed to_param returning an empty string for non-slugged models with a null friendly_id.
5
+
1
6
  == 2.0.2 2009-02-09
2
7
 
3
8
  * 2 major enhancements:
data/friendly_id.gemspec CHANGED
@@ -2,12 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{friendly_id}
5
- s.version = "2.0.2"
5
+ s.version = "2.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Norman Clarke", "Adrian Mugnolo", "Emilio Tagua"]
9
- s.cert_chain = ["/Users/norman/.gem/gem-public_cert.pem"]
10
- s.date = %q{2009-02-09}
9
+ s.date = %q{2009-02-11}
11
10
  s.description = %q{A comprehensive slugging and pretty-URL plugin for ActiveRecord.}
12
11
  s.email = ["norman@randomba.org", "adrian@randomba.org", "miloops@gmail.com"]
13
12
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc"]
@@ -27,14 +26,14 @@ Gem::Specification.new do |s|
27
26
 
28
27
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
28
  s.add_runtime_dependency(%q<unicode>, [">= 0.1"])
30
- s.add_runtime_dependency(%q<active_record>, [">= 2.0.0"])
29
+ s.add_runtime_dependency(%q<activerecord>, [">= 2.0.0"])
31
30
  s.add_development_dependency(%q<newgem>, [">= 1.2.3"])
32
31
  s.add_development_dependency(%q<Shoulda>, [">= 1.2.0"])
33
32
  s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
34
33
  s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
35
34
  else
36
35
  s.add_dependency(%q<unicode>, [">= 0.1"])
37
- s.add_dependency(%q<active_record>, [">= 2.0.0"])
36
+ s.add_dependency(%q<activerecord>, [">= 2.0.0"])
38
37
  s.add_dependency(%q<newgem>, [">= 1.2.3"])
39
38
  s.add_dependency(%q<Shoulda>, [">= 1.2.0"])
40
39
  s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
@@ -42,7 +41,7 @@ Gem::Specification.new do |s|
42
41
  end
43
42
  else
44
43
  s.add_dependency(%q<unicode>, [">= 0.1"])
45
- s.add_dependency(%q<active_record>, [">= 2.0.0"])
44
+ s.add_dependency(%q<activerecord>, [">= 2.0.0"])
46
45
  s.add_dependency(%q<newgem>, [">= 1.2.3"])
47
46
  s.add_dependency(%q<Shoulda>, [">= 1.2.0"])
48
47
  s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
data/lib/friendly_id.rb CHANGED
@@ -40,8 +40,8 @@ module FriendlyId
40
40
  # * <tt>:max_length</tt> - Defaults to 255. The maximum allowed length for a slug.
41
41
  # * <tt>:strip_diacritics</tt> - Defaults to false. If true, it will remove accents, umlauts, etc. from western characters.
42
42
  # * <tt>:strip_non_ascii</tt> - Defaults to false. If true, it will all non-ascii ([^a-z0-9]) characters.
43
- # * <tt>:reseved</tt> - Array of words that are reserved and can't be used as friendly_id's. For sluggable models, if such a word is used, it will be treated the same as if that slug was already taken (numeric extension will be appended). Defaults to ["new", "index"].
44
- # * <tt>:reseved_message</tt> - The validation message that will be shown when a reserved word is used as a frindly_id. Defaults to '"%s" is reserved'.
43
+ # * <tt>:reserved</tt> - Array of words that are reserved and can't be used as friendly_id's. For sluggable models, if such a word is used, it will be treated the same as if that slug was already taken (numeric extension will be appended). Defaults to ["new", "index"].
44
+ # * <tt>:reserved_message</tt> - The validation message that will be shown when a reserved word is used as a frindly_id. Defaults to '"%s" is reserved'.
45
45
  def has_friendly_id(column, options = {})
46
46
  options.assert_valid_keys VALID_FRIENDLY_ID_KEYS
47
47
  options = DEFAULT_FRIENDLY_ID_OPTIONS.merge(options).merge(:column => column)
@@ -21,7 +21,7 @@ module FriendlyId::NonSluggableInstanceMethods
21
21
 
22
22
  # Returns the friendly id, or if none is available, the numeric id.
23
23
  def to_param
24
- friendly_id.to_s || id.to_s
24
+ (friendly_id || id).to_s
25
25
  end
26
26
 
27
27
  private
@@ -2,7 +2,7 @@ module FriendlyId #:nodoc:
2
2
  module Version #:nodoc:
3
3
  MAJOR = 2
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
  end
8
8
  end
@@ -55,6 +55,12 @@ class NonSluggedTest < Test::Unit::TestCase
55
55
  assert_equal String, @user.to_param.class
56
56
  end
57
57
 
58
+ should "return its id if the friendly_id is null" do
59
+ @user.login = nil
60
+ assert_equal @user.id.to_s, @user.to_param
61
+ end
62
+
63
+
58
64
  context "when using an array as the find argument" do
59
65
 
60
66
  setup do
data/test/schema.rb CHANGED
@@ -1,4 +1,9 @@
1
1
  ActiveRecord::Schema.define(:version => 1) do
2
+
3
+ create_table "books", :force => true do |t|
4
+ t.column "title", "string"
5
+ t.column "type", "text"
6
+ end
2
7
 
3
8
  create_table "posts", :force => true do |t|
4
9
  t.column "title", "string"
data/test/sti_test.rb ADDED
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/test_helper'
4
+
5
+ class SluggedModelTest < Test::Unit::TestCase
6
+
7
+ context "A slugged model using single table inheritance" do
8
+
9
+ setup do
10
+ Novel.friendly_id_options = FriendlyId::DEFAULT_FRIENDLY_ID_OPTIONS.merge(:column => :title, :use_slug => true)
11
+ Novel.delete_all
12
+ Slug.delete_all
13
+ @novel = Novel.new :title => "Test novel"
14
+ @novel.save!
15
+ end
16
+
17
+ should "have a slug" do
18
+ assert_not_nil @novel.slug
19
+ end
20
+
21
+ context "found by its friendly id" do
22
+
23
+ setup do
24
+ @novel = Novel.find(@novel.friendly_id)
25
+ end
26
+
27
+ should "not indicate that it has a better id" do
28
+ assert !@novel.has_better_id?
29
+ end
30
+
31
+ end
32
+
33
+
34
+ context "found by its numeric id" do
35
+
36
+ setup do
37
+ @novel = Novel.find(@novel.id)
38
+ end
39
+
40
+ should "indicate that it has a better id" do
41
+ assert @novel.has_better_id?
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+ end
data/test/test_helper.rb CHANGED
@@ -16,6 +16,8 @@ require 'models/post'
16
16
  require 'models/person'
17
17
  require 'models/user'
18
18
  require 'models/country'
19
+ require 'models/book'
20
+ require 'models/novel'
19
21
 
20
22
  # Borrowed from ActiveSupport
21
23
  def silence_stream(stream)
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.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Norman Clarke
@@ -32,7 +32,7 @@ cert_chain:
32
32
  h7fbBRfStxI=
33
33
  -----END CERTIFICATE-----
34
34
 
35
- date: 2009-02-09 00:00:00 -02:00
35
+ date: 2009-02-11 00:00:00 -02:00
36
36
  default_executable:
37
37
  dependencies:
38
38
  - !ruby/object:Gem::Dependency
@@ -173,3 +173,4 @@ test_files:
173
173
  - test/scoped_model_test.rb
174
174
  - test/slug_test.rb
175
175
  - test/slugged_model_test.rb
176
+ - test/sti_test.rb
metadata.gz.sig CHANGED
Binary file