friendly_id 5.0.2 → 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -1
- data/Changelog.md +2 -0
- data/Gemfile +8 -2
- data/README.md +1 -0
- data/friendly_id.gemspec +1 -2
- data/gemfiles/Gemfile.rails-4.0.rb +9 -2
- data/gemfiles/Gemfile.rails-4.1.rb +29 -0
- data/gemfiles/Gemfile.rails-stable.rb +8 -2
- data/lib/friendly_id/base.rb +5 -1
- data/lib/friendly_id/configuration.rb +1 -1
- data/lib/friendly_id/finders.rb +19 -7
- data/lib/friendly_id/history.rb +1 -0
- data/lib/friendly_id/initializer.rb +1 -1
- data/lib/friendly_id/scoped.rb +4 -4
- data/lib/friendly_id/slugged.rb +5 -5
- data/lib/friendly_id/version.rb +1 -1
- data/test/scoped_test.rb +34 -0
- data/test/slugged_test.rb +30 -1
- data/test/sti_test.rb +62 -2
- metadata +28 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae540f2127bb8f4e872640deb40fe582eedad06a
|
4
|
+
data.tar.gz: 8d9e0ddb7339a440bd8000240a083b5586dee6a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcbcea5a8df1f5919c72ac9775ad619953fc776a7191c5e163d04c3361d9338fda12e37a7b50104345ef8583c3e8ac589b563231aa99e97cf52ed5305550fd2d
|
7
|
+
data.tar.gz: 2f48d2758e511c32ad5de5187c28509799cd2a46180d6d9b69ee6e190a5d8449b076e9f8cf7ef1159a69b6fc572f650bcb907087303ac2396b483418b2fe71d1
|
data/.travis.yml
CHANGED
@@ -1,13 +1,27 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
- 2.0.0
|
4
|
+
- 2.1.0
|
5
|
+
- jruby-19mode
|
6
|
+
- rbx
|
4
7
|
env:
|
5
8
|
- DB=postgres
|
6
9
|
- DB=mysql
|
7
|
-
- DB=sqlite3
|
8
10
|
gemfile:
|
9
11
|
- gemfiles/Gemfile.rails-4.0.rb
|
10
12
|
- gemfiles/Gemfile.rails-stable.rb
|
13
|
+
- gemfiles/Gemfile.rails-4.1.rb
|
11
14
|
|
12
15
|
before_script: 'bundle exec rake db:create db:up'
|
13
16
|
script: 'COVERAGE=true bundle exec rake test'
|
17
|
+
matrix:
|
18
|
+
allow_failures:
|
19
|
+
- rvm: jruby-19mode
|
20
|
+
gemfile: gemfiles/Gemfile.rails-4.1.rb
|
21
|
+
env: DB=postgres
|
22
|
+
- rvm: jruby-19mode
|
23
|
+
gemfile: gemfiles/Gemfile.rails-4.1.rb
|
24
|
+
env: DB=mysql
|
25
|
+
- rvm: jruby-19mode
|
26
|
+
gemfile: gemfiles/Gemfile.rails-4.1.rb
|
27
|
+
env: DB=sqlite3
|
data/Changelog.md
CHANGED
@@ -9,6 +9,8 @@ suggestions, ideas and improvements to FriendlyId.
|
|
9
9
|
* Documentation improvements (thanks [John Bachir](https://github.com/jjb)).
|
10
10
|
* Minor refactoring of internals (thanks [Gagan Ahwad](https://github.com/gaganawhad)).
|
11
11
|
* Set slug to `nil` on call to `dup` to ensure slug is generated ([#483](https://github.com/norman/friendly_id/pull/483)).
|
12
|
+
* Bug fixes for STI ([#516](https://github.com/norman/friendly_id/pull/516)).
|
13
|
+
* Bug fix for finds with models that use the :history module ([#509](https://github.com/norman/friendly_id/pull/509)).
|
12
14
|
|
13
15
|
## 5.0.1 (2013-10-27)
|
14
16
|
|
data/Gemfile
CHANGED
@@ -6,10 +6,16 @@ gemspec
|
|
6
6
|
group :development, :test do
|
7
7
|
platforms :jruby do
|
8
8
|
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0.beta2'
|
9
|
-
gem '
|
9
|
+
gem 'kramdown'
|
10
10
|
end
|
11
11
|
|
12
|
-
platforms :ruby do
|
12
|
+
platforms :ruby, :rbx do
|
13
13
|
gem 'sqlite3'
|
14
|
+
gem 'redcarpet'
|
15
|
+
end
|
16
|
+
|
17
|
+
platforms :rbx do
|
18
|
+
gem 'rubysl', '~> 2.0'
|
19
|
+
gem 'rubinius-developer_tools'
|
14
20
|
end
|
15
21
|
end
|
data/README.md
CHANGED
@@ -57,6 +57,7 @@ The most important changes are:
|
|
57
57
|
* Finders are no longer overridden by default. If you want to do friendly finds,
|
58
58
|
you must do `Model.friendly.find` rather than `Model.find`. You can however
|
59
59
|
restore FriendlyId 4-style finders by using the `:finders` addon:
|
60
|
+
|
60
61
|
```ruby
|
61
62
|
friendly_id :foo, use: :slugged # you must do MyClass.friendly.find('bar')
|
62
63
|
# or...
|
data/friendly_id.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.required_ruby_version = '>= 1.9.3'
|
18
18
|
|
19
|
-
s.add_dependency 'activerecord', '
|
19
|
+
s.add_dependency 'activerecord', '>= 4.0.0'
|
20
20
|
|
21
21
|
s.add_development_dependency 'coveralls'
|
22
22
|
s.add_development_dependency 'railties', '~> 4.0.0'
|
@@ -26,7 +26,6 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_development_dependency 'i18n'
|
27
27
|
s.add_development_dependency 'ffaker'
|
28
28
|
s.add_development_dependency 'simplecov'
|
29
|
-
s.add_development_dependency 'redcarpet'
|
30
29
|
|
31
30
|
s.description = <<-EOM
|
32
31
|
FriendlyId is the "Swiss Army bulldozer" of slugging and permalink plugins for
|
@@ -8,12 +8,19 @@ group :development, :test do
|
|
8
8
|
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0.beta2'
|
9
9
|
gem 'activerecord-jdbcmysql-adapter', '>= 1.3.0.beta2'
|
10
10
|
gem 'activerecord-jdbcpostgresql-adapter', '>= 1.3.0.beta2'
|
11
|
-
gem '
|
11
|
+
gem 'kramdown'
|
12
12
|
end
|
13
13
|
|
14
|
-
platforms :ruby do
|
14
|
+
platforms :ruby, :rbx do
|
15
15
|
gem 'sqlite3'
|
16
16
|
gem 'mysql2'
|
17
17
|
gem 'pg'
|
18
|
+
gem 'redcarpet'
|
19
|
+
end
|
20
|
+
|
21
|
+
platforms :rbx do
|
22
|
+
gem 'rubysl', '~> 2.0'
|
23
|
+
gem 'rubinius-developer_tools'
|
24
|
+
gem 'json'
|
18
25
|
end
|
19
26
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec path: '../'
|
4
|
+
|
5
|
+
gem 'activerecord', '~> 4.1.0.beta1'
|
6
|
+
gem 'railties', '~> 4.1.0.beta1'
|
7
|
+
|
8
|
+
# Database Configuration
|
9
|
+
group :development, :test do
|
10
|
+
platforms :jruby do
|
11
|
+
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0.beta2'
|
12
|
+
gem 'activerecord-jdbcmysql-adapter', '>= 1.3.0.beta2'
|
13
|
+
gem 'activerecord-jdbcpostgresql-adapter', '>= 1.3.0.beta2'
|
14
|
+
gem 'kramdown'
|
15
|
+
end
|
16
|
+
|
17
|
+
platforms :ruby, :rbx do
|
18
|
+
gem 'sqlite3'
|
19
|
+
gem 'mysql2'
|
20
|
+
gem 'pg'
|
21
|
+
gem 'redcarpet'
|
22
|
+
end
|
23
|
+
|
24
|
+
platforms :rbx do
|
25
|
+
gem 'rubysl', '~> 2.0'
|
26
|
+
gem 'rubinius-developer_tools'
|
27
|
+
gem 'json'
|
28
|
+
end
|
29
|
+
end
|
@@ -13,12 +13,18 @@ group :development, :test do
|
|
13
13
|
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0.beta2'
|
14
14
|
gem 'activerecord-jdbcmysql-adapter', '>= 1.3.0.beta2'
|
15
15
|
gem 'activerecord-jdbcpostgresql-adapter', '>= 1.3.0.beta2'
|
16
|
-
gem '
|
16
|
+
gem 'kramdown'
|
17
17
|
end
|
18
18
|
|
19
|
-
platforms :ruby do
|
19
|
+
platforms :ruby, :rbx do
|
20
20
|
gem 'sqlite3'
|
21
21
|
gem 'mysql2'
|
22
22
|
gem 'pg'
|
23
|
+
gem 'redcarpet'
|
24
|
+
end
|
25
|
+
|
26
|
+
platforms :rbx do
|
27
|
+
gem 'rubysl', '~> 2.0'
|
28
|
+
gem 'rubinius-developer_tools'
|
23
29
|
end
|
24
30
|
end
|
data/lib/friendly_id/base.rb
CHANGED
@@ -18,6 +18,10 @@ addons it should use. See the documentation for this method for a list of all
|
|
18
18
|
available addons, or skim through the rest of the docs to get a high-level
|
19
19
|
overview.
|
20
20
|
|
21
|
+
*A note about single table inheritance (STI): you must extend FriendlyId in
|
22
|
+
all classes that participate in STI, both your parent classes and their
|
23
|
+
children.*
|
24
|
+
|
21
25
|
### The Default Setup: Simple Models
|
22
26
|
|
23
27
|
The simplest way to use FriendlyId is with a model that has a uniquely indexed
|
@@ -249,7 +253,7 @@ often better and easier to use {FriendlyId::Slugged slugs}.
|
|
249
253
|
|
250
254
|
# Clears slug on duplicate records when calling `dup`.
|
251
255
|
def dup
|
252
|
-
super.tap { |duplicate| duplicate.slug = nil }
|
256
|
+
super.tap { |duplicate| duplicate.slug = nil if duplicate.respond_to?('slug=') }
|
253
257
|
end
|
254
258
|
end
|
255
259
|
end
|
data/lib/friendly_id/finders.rb
CHANGED
@@ -18,7 +18,7 @@ By default, these methods are available only on the `friendly` scope:
|
|
18
18
|
Prior to version 5.0, FriendlyId overrode the default finder methods to perform
|
19
19
|
friendly finds all the time. This required modifying parts of Rails that did
|
20
20
|
not have a public API, which was harder to maintain and at times caused
|
21
|
-
compatiblity problems. In 5.0 we decided change the library's defaults and add
|
21
|
+
compatiblity problems. In 5.0 we decided to change the library's defaults and add
|
22
22
|
the friendly finder methods only to the `friendly` scope in order to boost
|
23
23
|
compatiblity. However, you can still opt-in to original functionality very
|
24
24
|
easily by using the `:finders` addon:
|
@@ -63,18 +63,30 @@ for models that use FriendlyId with something similar to the following:
|
|
63
63
|
|
64
64
|
=end
|
65
65
|
module Finders
|
66
|
-
|
66
|
+
|
67
|
+
module ClassMethods
|
68
|
+
if (ActiveRecord::VERSION::MAJOR == 4) && (ActiveRecord::VERSION::MINOR == 0)
|
69
|
+
def relation_delegate_class(klass)
|
70
|
+
relation_class_name = :"#{klass.to_s.gsub('::', '_')}_#{self.to_s.gsub('::', '_')}"
|
71
|
+
klass.const_get(relation_class_name)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.setup(model_class)
|
67
77
|
model_class.instance_eval do
|
68
78
|
relation.class.send(:include, friendly_id_config.finder_methods)
|
69
79
|
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.included(model_class)
|
83
|
+
model_class.extend(ClassMethods)
|
70
84
|
|
71
85
|
# Support for friendly finds on associations for Rails 4.0.1 and above.
|
72
|
-
# As of 1 October 2013 this works on Rails 4-0-stable, but may change.
|
73
86
|
if ::ActiveRecord.const_defined?('AssociationRelation')
|
74
|
-
|
75
|
-
|
76
|
-
association_relation_class.send(:include, model_class.friendly_id_config.finder_methods)
|
87
|
+
association_relation_delegate_class = model_class.relation_delegate_class(::ActiveRecord::AssociationRelation)
|
88
|
+
association_relation_delegate_class.send(:include, model_class.friendly_id_config.finder_methods)
|
77
89
|
end
|
78
90
|
end
|
79
91
|
end
|
80
|
-
end
|
92
|
+
end
|
data/lib/friendly_id/history.rb
CHANGED
@@ -64,7 +64,7 @@ FriendlyId.defaults do |config|
|
|
64
64
|
# ### Controlling when slugs are generated
|
65
65
|
#
|
66
66
|
# As of FriendlyId 5.0, new slugs are generated only when the slug field is
|
67
|
-
# nil, but
|
67
|
+
# nil, but if you're using a column as your base method can change this
|
68
68
|
# behavior by overriding the `should_generate_new_friendly_id` method that
|
69
69
|
# FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave
|
70
70
|
# more like 4.0.
|
data/lib/friendly_id/scoped.rb
CHANGED
@@ -58,7 +58,7 @@ All supplied values will be used to determine scope.
|
|
58
58
|
### Finding Records by Friendly ID
|
59
59
|
|
60
60
|
If you are using scopes your friendly ids may not be unique, so a simple find
|
61
|
-
like
|
61
|
+
like:
|
62
62
|
|
63
63
|
Restaurant.friendly.find("joes-diner")
|
64
64
|
|
@@ -127,13 +127,13 @@ an example of one way to set this up:
|
|
127
127
|
relation = relation.where(column => send(column))
|
128
128
|
end
|
129
129
|
if changed.include?(friendly_id_config.slug_column)
|
130
|
-
|
131
|
-
relation = relation.where(
|
130
|
+
primary_key_name = self.class.primary_key
|
131
|
+
relation = relation.where.not(primary_key_name => send(primary_key_name))
|
132
132
|
end
|
133
133
|
relation
|
134
134
|
end
|
135
135
|
private :scope_for_slug_generator
|
136
|
-
|
136
|
+
|
137
137
|
def slug_generator
|
138
138
|
friendly_id_config.slug_generator_class.new(scope_for_slug_generator)
|
139
139
|
end
|
data/lib/friendly_id/slugged.rb
CHANGED
@@ -76,7 +76,7 @@ dashes, and Unicode Latin characters with ASCII approximations:
|
|
76
76
|
|
77
77
|
#### Column or Method?
|
78
78
|
|
79
|
-
FriendlyId always uses a method as the basis of the slug text - not a column.
|
79
|
+
FriendlyId always uses a method as the basis of the slug text - not a column. At
|
80
80
|
first glance, this may sound confusing, but remember that Active Record provides
|
81
81
|
methods for each column in a model's associated table, and that's what
|
82
82
|
FriendlyId uses.
|
@@ -106,7 +106,7 @@ FriendlyId will append a UUID to the generated slug to ensure uniqueness:
|
|
106
106
|
car.friendly_id #=> "peugot-206"
|
107
107
|
car2.friendly_id #=> "peugot-206-f9f3789a-daec-4156-af1d-fab81aa16ee5"
|
108
108
|
|
109
|
-
Previous versions of FriendlyId appended a numeric sequence
|
109
|
+
Previous versions of FriendlyId appended a numeric sequence to make slugs
|
110
110
|
unique, but this was removed to simplify using FriendlyId in concurrent code.
|
111
111
|
|
112
112
|
#### Candidates
|
@@ -299,11 +299,11 @@ Github issue](https://github.com/norman/friendly_id/issues/185) for discussion.
|
|
299
299
|
|
300
300
|
def scope_for_slug_generator
|
301
301
|
scope = self.class.base_class.unscoped
|
302
|
-
scope = scope.friendly unless
|
302
|
+
scope = scope.friendly unless scope.respond_to?(:exists_by_friendly_id?)
|
303
303
|
|
304
304
|
if changed.include?(friendly_id_config.slug_column)
|
305
|
-
|
306
|
-
scope = scope.where(
|
305
|
+
primary_key_name = self.class.primary_key
|
306
|
+
scope = scope.where.not(primary_key_name => send(primary_key_name))
|
307
307
|
end
|
308
308
|
scope
|
309
309
|
end
|
data/lib/friendly_id/version.rb
CHANGED
data/test/scoped_test.rb
CHANGED
@@ -10,6 +10,10 @@ class Novel < ActiveRecord::Base
|
|
10
10
|
belongs_to :novelist
|
11
11
|
belongs_to :publisher
|
12
12
|
friendly_id :name, :use => :scoped, :scope => [:publisher, :novelist]
|
13
|
+
|
14
|
+
def should_generate_new_friendly_id?
|
15
|
+
new_record? || super
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
class Publisher < ActiveRecord::Base
|
@@ -54,6 +58,36 @@ class ScopedTest < MiniTest::Unit::TestCase
|
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
61
|
+
test "should not allow duplicate slugs inside scope after regeneration for persisted record" do
|
62
|
+
with_instance_of Novelist do |novelist|
|
63
|
+
novel1 = Novel.create! :name => "a", :novelist => novelist
|
64
|
+
novel2 = Novel.new :name => "a", :novelist => novelist
|
65
|
+
novel2.save!
|
66
|
+
|
67
|
+
novel2.send(:set_slug)
|
68
|
+
first_generated_friendly_id = novel2.friendly_id
|
69
|
+
novel2.send(:set_slug)
|
70
|
+
second_generated_friendly_id = novel2.friendly_id
|
71
|
+
|
72
|
+
assert novel1.friendly_id != novel2.friendly_id
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
test "should not allow duplicate slugs inside scope after regeneration for new record" do
|
77
|
+
with_instance_of Novelist do |novelist|
|
78
|
+
novel1 = Novel.create! :name => "a", :novelist => novelist
|
79
|
+
novel2 = Novel.new :name => "a", :novelist => novelist
|
80
|
+
|
81
|
+
novel2.send(:set_slug)
|
82
|
+
first_generated_friendly_id = novel2.friendly_id
|
83
|
+
novel2.send(:set_slug)
|
84
|
+
second_generated_friendly_id = novel2.friendly_id
|
85
|
+
novel2.save!
|
86
|
+
|
87
|
+
assert novel1.friendly_id != novel2.friendly_id
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
57
91
|
test "should apply scope with multiple columns" do
|
58
92
|
transaction do
|
59
93
|
novelist = Novelist.create! :name => "a"
|
data/test/slugged_test.rb
CHANGED
@@ -141,6 +141,35 @@ class SlugGeneratorTest < MiniTest::Unit::TestCase
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
+
test "should not allow duplicate slugs after regeneration for persisted record" do
|
145
|
+
transaction do
|
146
|
+
model1 = model_class.create! :name => "a"
|
147
|
+
model2 = model_class.new :name => "a"
|
148
|
+
model2.save!
|
149
|
+
|
150
|
+
model2.send(:set_slug)
|
151
|
+
first_generated_friendly_id = model2.friendly_id
|
152
|
+
model2.send(:set_slug)
|
153
|
+
second_generated_friendly_id = model2.friendly_id
|
154
|
+
|
155
|
+
assert model1.friendly_id != model2.friendly_id
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
test "should not allow duplicate slugs after regeneration for new record" do
|
160
|
+
transaction do
|
161
|
+
model1 = model_class.create! :name => "a"
|
162
|
+
model2 = model_class.new :name => "a"
|
163
|
+
|
164
|
+
model2.send(:set_slug)
|
165
|
+
first_generated_friendly_id = model2.friendly_id
|
166
|
+
model2.send(:set_slug)
|
167
|
+
second_generated_friendly_id = model2.friendly_id
|
168
|
+
|
169
|
+
assert model1.friendly_id != model2.friendly_id
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
144
173
|
end
|
145
174
|
|
146
175
|
class SlugSeparatorTest < MiniTest::Unit::TestCase
|
@@ -220,7 +249,7 @@ class StringAsPrimaryKeyFindTest < MiniTest::Unit::TestCase
|
|
220
249
|
friendly_id :name, :use => :slugged
|
221
250
|
before_create :init_primary_key
|
222
251
|
|
223
|
-
def self.primary_key
|
252
|
+
def self.primary_key
|
224
253
|
"string_key"
|
225
254
|
end
|
226
255
|
|
data/test/sti_test.rb
CHANGED
@@ -8,7 +8,7 @@ class StiTest < MiniTest::Unit::TestCase
|
|
8
8
|
|
9
9
|
class Journalist < ActiveRecord::Base
|
10
10
|
extend FriendlyId
|
11
|
-
friendly_id :name, :use => :slugged
|
11
|
+
friendly_id :name, :use => [:slugged]
|
12
12
|
end
|
13
13
|
|
14
14
|
class Editorialist < Journalist
|
@@ -59,7 +59,6 @@ class StiTest < MiniTest::Unit::TestCase
|
|
59
59
|
assert_match(/foo-bar-.+/, editoralist.slug)
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
63
62
|
end
|
64
63
|
|
65
64
|
class StiTestWithHistory < StiTest
|
@@ -74,4 +73,65 @@ class StiTestWithHistory < StiTest
|
|
74
73
|
def model_class
|
75
74
|
Editorialist
|
76
75
|
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
class StiTestWithFinders < MiniTest::Unit::TestCase
|
80
|
+
|
81
|
+
include FriendlyId::Test
|
82
|
+
|
83
|
+
class Journalist < ActiveRecord::Base
|
84
|
+
extend FriendlyId
|
85
|
+
friendly_id :name, :use => [:slugged, :finders]
|
86
|
+
end
|
87
|
+
|
88
|
+
class Editorialist < Journalist
|
89
|
+
extend FriendlyId
|
90
|
+
friendly_id :name, :use => [:slugged, :finders]
|
91
|
+
end
|
92
|
+
|
93
|
+
def model_class
|
94
|
+
Editorialist
|
95
|
+
end
|
96
|
+
|
97
|
+
test "friendly_id slugs should be looked up from subclass with friendly" do
|
98
|
+
transaction do
|
99
|
+
editoralist = model_class.create! :name => 'foo bar'
|
100
|
+
assert_equal editoralist, model_class.friendly.find(editoralist.slug)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
test "friendly_id slugs should be looked up from subclass" do
|
105
|
+
transaction do
|
106
|
+
editoralist = model_class.create! :name => 'foo bar'
|
107
|
+
assert_equal editoralist, model_class.find(editoralist.slug)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
class StiTestSubClass < MiniTest::Unit::TestCase
|
114
|
+
|
115
|
+
include FriendlyId::Test
|
116
|
+
|
117
|
+
class Journalist < ActiveRecord::Base
|
118
|
+
extend FriendlyId
|
119
|
+
end
|
120
|
+
|
121
|
+
class Editorialist < Journalist
|
122
|
+
extend FriendlyId
|
123
|
+
friendly_id :name, :use => [:slugged, :finders]
|
124
|
+
end
|
125
|
+
|
126
|
+
def model_class
|
127
|
+
Editorialist
|
128
|
+
end
|
129
|
+
|
130
|
+
test "friendly_id slugs can be created and looked up from subclass" do
|
131
|
+
transaction do
|
132
|
+
editoralist = model_class.create! :name => 'foo bar'
|
133
|
+
assert_equal editoralist, model_class.find(editoralist.slug)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
77
137
|
end
|
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: 5.0.
|
4
|
+
version: 5.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Norman Clarke
|
@@ -9,146 +9,132 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 4.0.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 4.0.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: coveralls
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: railties
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - ~>
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 4.0.0
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - ~>
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 4.0.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: minitest
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 4.4.0
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 4.4.0
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: mocha
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - ~>
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: 0.13.3
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - ~>
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: 0.13.3
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: yard
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: i18n
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: ffaker
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: simplecov
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- -
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- -
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version: '0'
|
140
|
-
- !ruby/object:Gem::Dependency
|
141
|
-
name: redcarpet
|
142
|
-
requirement: !ruby/object:Gem::Requirement
|
143
|
-
requirements:
|
144
|
-
- - '>='
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
version: '0'
|
147
|
-
type: :development
|
148
|
-
prerelease: false
|
149
|
-
version_requirements: !ruby/object:Gem::Requirement
|
150
|
-
requirements:
|
151
|
-
- - '>='
|
137
|
+
- - ">="
|
152
138
|
- !ruby/object:Gem::Version
|
153
139
|
version: '0'
|
154
140
|
description: |
|
@@ -162,10 +148,10 @@ executables: []
|
|
162
148
|
extensions: []
|
163
149
|
extra_rdoc_files: []
|
164
150
|
files:
|
165
|
-
- .gemtest
|
166
|
-
- .gitignore
|
167
|
-
- .travis.yml
|
168
|
-
- .yardopts
|
151
|
+
- ".gemtest"
|
152
|
+
- ".gitignore"
|
153
|
+
- ".travis.yml"
|
154
|
+
- ".yardopts"
|
169
155
|
- CONTRIBUTING.md
|
170
156
|
- Changelog.md
|
171
157
|
- Gemfile
|
@@ -175,6 +161,7 @@ files:
|
|
175
161
|
- bench.rb
|
176
162
|
- friendly_id.gemspec
|
177
163
|
- gemfiles/Gemfile.rails-4.0.rb
|
164
|
+
- gemfiles/Gemfile.rails-4.1.rb
|
178
165
|
- gemfiles/Gemfile.rails-stable.rb
|
179
166
|
- guide.rb
|
180
167
|
- lib/friendly_id.rb
|
@@ -222,17 +209,17 @@ require_paths:
|
|
222
209
|
- lib
|
223
210
|
required_ruby_version: !ruby/object:Gem::Requirement
|
224
211
|
requirements:
|
225
|
-
- -
|
212
|
+
- - ">="
|
226
213
|
- !ruby/object:Gem::Version
|
227
214
|
version: 1.9.3
|
228
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
216
|
requirements:
|
230
|
-
- -
|
217
|
+
- - ">="
|
231
218
|
- !ruby/object:Gem::Version
|
232
219
|
version: '0'
|
233
220
|
requirements: []
|
234
221
|
rubyforge_project: friendly_id
|
235
|
-
rubygems_version: 2.0
|
222
|
+
rubygems_version: 2.2.0
|
236
223
|
signing_key:
|
237
224
|
specification_version: 4
|
238
225
|
summary: A comprehensive slugging and pretty-URL plugin.
|