friendly_id 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.
@@ -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.klass.uses_friendly_id? }.map(&:klass)
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
@@ -2,7 +2,7 @@ module FriendlyId
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
  BUILD = nil
7
7
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
8
8
  end
@@ -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
- - 2
9
- version: 3.0.2
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-09 00:00:00 -03:00
19
+ date: 2010-04-26 00:00:00 -03:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency