friendly_id 2.3.1 → 2.3.2

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.
@@ -6,6 +6,18 @@ suggestions, ideas and improvements to FriendlyId.
6
6
  * Table of Contents
7
7
  {:toc}
8
8
 
9
+ ## 2.3.2 (2010-02-14)
10
+
11
+ * Fixed finding by old slug when using cached slugs.
12
+ * Sequence separator parsing now correctly handles occurrences of the sequence
13
+ separator string inside the friendly_id text (Johan Kok).
14
+ * Fixed missing quotes on table names in a few places (Brian Collins).
15
+
16
+
17
+ ## 2.3.1 (2010-02-09)
18
+
19
+ * Fixed stack level too deep error on #strip_diacritics.
20
+
9
21
 
10
22
  ## 2.3.0 (2010-02-04)
11
23
 
@@ -20,10 +32,10 @@ fork, then this upgrade may causes issues.
20
32
  **Changes:**
21
33
 
22
34
  * Sequence separator can now be configured to something other than "--".
23
- * New option to pass arguments to {FriendlyId::SlugString#approximate_ascii!},
35
+ * New option to pass arguments to {FriendlyId::SlugString#approximate_ascii!},
24
36
  allowing custom approximations specific to German or Spanish.
25
37
  * FriendlyId now queries against the cached_slug column, which improves performance.
26
- * {FriendlyId::SlugString} class added, allowing finer-grained control over
38
+ * {FriendlyId::SlugString} class added, allowing finer-grained control over
27
39
  Unicode friendly_id strings.
28
40
  * {FriendlyId::Configuration} class added, offering more flexible/hackable
29
41
  options.
@@ -222,4 +234,4 @@ fork, then this upgrade may causes issues.
222
234
  * Applied patch from Dan Blue to make friendly_id no longer ignore options on
223
235
  ActiveRecordBase#find.
224
236
  * Added call to options.assert_valid_keys in has_friendly_id. Thanks to W.
225
- Andrew Loe III for pointing out that this was missing.
237
+ Andrew Loe III for pointing out that this was missing.
@@ -7,6 +7,7 @@ community, in particular from the following people:
7
7
  * Andrew Loe III
8
8
  * Ben Woosley
9
9
  * Bence Nagy
10
+ * Brian Collins
10
11
  * Bruno Michel
11
12
  * Chris Nolan
12
13
  * David Ramalho
@@ -17,6 +18,7 @@ community, in particular from the following people:
17
18
  * Ian Stewart
18
19
  * Jesse Crouch
19
20
  * Joe Van Dyk
21
+ * Johan Kok
20
22
  * Josh Nichols
21
23
  * Mikhail Shirkov
22
24
  * Nathan Phelps
@@ -60,7 +60,8 @@ end
60
60
 
61
61
  class String
62
62
  def parse_friendly_id(separator = nil)
63
- name, sequence = split(separator || FriendlyId::Configuration::DEFAULTS[:sequence_separator])
63
+ separator ||= FriendlyId::Configuration::DEFAULTS[:sequence_separator]
64
+ name, sequence = split(/#{Regexp.escape(separator)}(\d)*\z/)
64
65
  return name, sequence ||= "1"
65
66
  end
66
- end
67
+ end
@@ -37,7 +37,7 @@ module FriendlyId
37
37
  end
38
38
 
39
39
  def find_options
40
- {:select => "#{table_name}.*", :conditions => find_conditions,
40
+ {:select => "#{quoted_table_name}.*", :conditions => find_conditions,
41
41
  :joins => slugs_included? ? options[:joins] : :slugs}
42
42
  end
43
43
 
@@ -112,7 +112,7 @@ module FriendlyId
112
112
  def find_options
113
113
  slug_table = Slug.table_name
114
114
  {
115
- :select => "#{model_class.table_name}.*",
115
+ :select => "#{model_class.quoted_table_name}.*",
116
116
  :joins => slugs_included? ? options[:joins] : :slugs,
117
117
  :conditions => {
118
118
  "#{slug_table}.name" => name,
@@ -135,6 +135,12 @@ module FriendlyId
135
135
  # circumstances unless the +:scope+ argument is present.
136
136
  class CachedSingleFinder < SimpleModel::SingleFinder
137
137
 
138
+ def find
139
+ super
140
+ rescue ActiveRecord::RecordNotFound
141
+ SingleFinder.new(id, model_class, options).find
142
+ end
143
+
138
144
  # The column used to store the cached slug.
139
145
  def column
140
146
  "#{table_name}.#{friendly_id_config.cache_column}"
@@ -139,6 +139,13 @@ module FriendlyId
139
139
  assert_equal instance2, klass.send(find_method, instance2.friendly_id)
140
140
  end
141
141
 
142
+ test "should remain findable by previous slugs" do
143
+ old_friendly_id = instance.friendly_id
144
+ instance.update_attributes :name => "#{old_friendly_id} updated"
145
+ assert_not_equal old_friendly_id, instance.friendly_id
146
+ assert_equal instance, klass.find(old_friendly_id)
147
+ end
148
+
142
149
  end
143
150
 
144
151
  # Tests for models to ensure that they properly implement using the
@@ -165,4 +172,4 @@ module FriendlyId
165
172
 
166
173
  end
167
174
  end
168
- end
175
+ end
@@ -2,7 +2,7 @@ module FriendlyId
2
2
  module Version
3
3
  MAJOR = 2
4
4
  MINOR = 3
5
- TINY = 1
5
+ TINY = 2
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
  end
8
8
  end
@@ -18,6 +18,22 @@ module FriendlyId
18
18
  assert_equal ["test", "2"], "test:2".parse_friendly_id(":")
19
19
  end
20
20
 
21
+ test "should parse when default sequence separator occurs in friendly_id name" do
22
+ assert_equal ["test--test", "2"], "test--test--2".parse_friendly_id
23
+ end
24
+
25
+ test "should parse when custom sequence separator occurs in friendly_id name" do
26
+ assert_equal ["test:test", "2"], "test:test:2".parse_friendly_id(":")
27
+ end
28
+
29
+ test "should parse when sequence separator and number occur in friendly_id name" do
30
+ assert_equal ["test--2--test", "1"], "test--2--test".parse_friendly_id
31
+ end
32
+
33
+ test "should parse when sequence separator, number and sequence occur in friendly_id name" do
34
+ assert_equal ["test--2--test", "2"], "test--2--test--2".parse_friendly_id
35
+ end
36
+
21
37
  end
22
38
  end
23
- end
39
+ 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: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Norman Clarke
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2010-02-09 00:00:00 -08:00
14
+ date: 2010-02-14 00:00:00 -08:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency