friendly_id 3.0.2 → 3.0.3
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/Changelog.md +4 -0
- data/Contributors.md +3 -1
- data/lib/friendly_id/active_record_adapter/configuration.rb +4 -2
- data/lib/friendly_id/version.rb +1 -1
- data/test/active_record_adapter/ar_test_helper.rb +11 -0
- data/test/active_record_adapter/scoped_model_test.rb +7 -0
- data/test/active_record_adapter/support/models.rb +9 -0
- metadata +3 -3
data/Changelog.md
CHANGED
@@ -6,6 +6,10 @@ suggestions, ideas and improvements to FriendlyId.
|
|
6
6
|
* Table of Contents
|
7
7
|
{:toc}
|
8
8
|
|
9
|
+
## 3.0.3 (2010-04-26)
|
10
|
+
|
11
|
+
* Fixed scope update when models use polymorphic relations.
|
12
|
+
|
9
13
|
## 3.0.2 (2010-04-09)
|
10
14
|
|
11
15
|
* Fixed finding non-slugged models by an array of ids.
|
data/Contributors.md
CHANGED
@@ -24,13 +24,15 @@ community, in particular from the following people:
|
|
24
24
|
* Josh Nichols
|
25
25
|
* Juan Schwindt
|
26
26
|
* Kamal Fariz Mahyuddin
|
27
|
+
* Laurence A. Lee
|
27
28
|
* Louis T.
|
28
29
|
* Mikhail Shirkov
|
29
|
-
* Nathan Phelps
|
30
30
|
* Nash Kabbara
|
31
|
+
* Nathan Phelps
|
31
32
|
* Ramon Soares
|
32
33
|
* Rdavila
|
33
34
|
* Rob Ingram
|
35
|
+
* Ryan Wood
|
34
36
|
* Sean Abrahams
|
35
37
|
* Steve Luscher
|
36
38
|
* Steven Noble
|
@@ -57,9 +57,11 @@ module FriendlyId
|
|
57
57
|
|
58
58
|
def associated_friendly_classes
|
59
59
|
configured_class.reflect_on_all_associations.select { |assoc|
|
60
|
-
assoc.
|
60
|
+
!assoc.options[:polymorphic] &&
|
61
|
+
assoc.klass.uses_friendly_id?
|
62
|
+
}.map(&:klass)
|
61
63
|
end
|
62
64
|
|
63
65
|
end
|
64
66
|
end
|
65
|
-
end
|
67
|
+
end
|
data/lib/friendly_id/version.rb
CHANGED
@@ -105,4 +105,15 @@ end
|
|
105
105
|
# A model with no table
|
106
106
|
class Question < ActiveRecord::Base
|
107
107
|
has_friendly_id :name, :use_slug => true
|
108
|
+
end
|
109
|
+
|
110
|
+
# A model to test polymorphic associations
|
111
|
+
class Site < ActiveRecord::Base
|
112
|
+
belongs_to :owner, :polymorphic => true
|
113
|
+
has_friendly_id :name, :use_slug => true
|
114
|
+
end
|
115
|
+
|
116
|
+
# A model used as a polymorphic owner
|
117
|
+
class Company < ActiveRecord::Base
|
118
|
+
has_many :sites, :as => :owner
|
108
119
|
end
|
@@ -17,6 +17,8 @@ module FriendlyId
|
|
17
17
|
@canada = Country.create!(:name => "Canada")
|
18
18
|
@resident = Resident.create!(:name => "John Smith", :country => @usa)
|
19
19
|
@resident2 = Resident.create!(:name => "John Smith", :country => @canada)
|
20
|
+
@owner = Company.create!(:name => "Acme Events")
|
21
|
+
@site = Site.create!(:name => "Downtown Venue", :owner => @owner)
|
20
22
|
end
|
21
23
|
|
22
24
|
def teardown
|
@@ -105,6 +107,11 @@ module FriendlyId
|
|
105
107
|
assert_match(/scope: badscope/, e.message)
|
106
108
|
end
|
107
109
|
end
|
110
|
+
|
111
|
+
test "should update the sluggable field when a polymorphic relationship exists" do
|
112
|
+
@site.update_attributes(:name => "Uptown Venue")
|
113
|
+
assert_equal "Uptown Venue", @site.name
|
114
|
+
end
|
108
115
|
|
109
116
|
end
|
110
117
|
end
|
@@ -71,6 +71,15 @@ class CreateSupportModels < ActiveRecord::Migration
|
|
71
71
|
end
|
72
72
|
add_index :users, :name, :unique => true
|
73
73
|
|
74
|
+
create_table :sites do |t|
|
75
|
+
t.string :name
|
76
|
+
t.integer :owner_id
|
77
|
+
t.string :owner_type
|
78
|
+
end
|
79
|
+
|
80
|
+
create_table :companies do |t|
|
81
|
+
t.string :name
|
82
|
+
end
|
74
83
|
end
|
75
84
|
|
76
85
|
def self.down
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 3
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 3.0.
|
8
|
+
- 3
|
9
|
+
version: 3.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Norman Clarke
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-04-
|
19
|
+
date: 2010-04-26 00:00:00 -03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|