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 +0 -0
- data/History.txt +5 -0
- data/friendly_id.gemspec +5 -6
- data/lib/friendly_id.rb +2 -2
- data/lib/friendly_id/non_sluggable_instance_methods.rb +1 -1
- data/lib/friendly_id/version.rb +1 -1
- data/test/non_slugged_test.rb +6 -0
- data/test/schema.rb +5 -0
- data/test/sti_test.rb +48 -0
- data/test/test_helper.rb +2 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
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.
|
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.
|
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<
|
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<
|
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<
|
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>:
|
44
|
-
# * <tt>:
|
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)
|
data/lib/friendly_id/version.rb
CHANGED
data/test/non_slugged_test.rb
CHANGED
@@ -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
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
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.
|
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-
|
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
|