friendly_id 5.2.5 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd9172f2c624c948c208a4e89b1d8de61f895d8d2cf0d233a3622d1f03da53f2
4
- data.tar.gz: 1cb881d8be37a992cbac2d8def2c18338829e84b577bb364b36901a627849533
3
+ metadata.gz: 8fb8d2b37002508059b4480fe303a2ff277e4ee1264cd4dd3de6261a127aaa8d
4
+ data.tar.gz: 8cc571f9b42192a2ff254ed5f134817b6b3d0d7c37bb5cd82df1493055e21830
5
5
  SHA512:
6
- metadata.gz: 9bca1be76cbc05a4d5dde5b936121ecf89b44c9949eb9b7ad574a20affd34fef104a443379b13d9a1a4843bbba9812366bd99d9b6db7eb56ace44581fecdad4a
7
- data.tar.gz: d9c2ba647f04848ab3a690fd064e1669316bfc69116aa868a17034bed6916758e643365e425bc88f024fdec9bc7b5faaba89a5200696e0c1a3fddac04f140a30
6
+ metadata.gz: 7549da1a767fefcf3cd05913fc59801d4ffe9fe1bac77429d39ad42e544dcd1a03942c74515c5eee47207269c0a7e34a48a728e1d66b2e8d4a86cb7dabe9a84b
7
+ data.tar.gz: 181750c6dc3a12cb6e0948504aa2888fbd95823ee3282d2c18938eb3805cc3c86b9ddaabefd18e1d2bcaec3ea8d3e8546260caed38cf9504af768e8fa905c02d
@@ -1,16 +1,26 @@
1
1
  language: ruby
2
2
  cache: bundler
3
-
3
+ services:
4
+ - postgresql
5
+ - mysql
6
+ dist: trusty
7
+ addons:
8
+ postgresql: "9.6"
4
9
  rvm:
5
- - 2.4.0
6
- - 2.3.0
10
+ - 2.6.3
11
+ - 2.5.5
12
+ - 2.4.6
13
+ - 2.3.8
7
14
  - 2.2.0
8
15
  - 2.1.0
9
16
  - jruby-9.1.13.0
10
17
 
11
18
  env:
12
- - DB=postgres
13
- - DB=mysql
19
+ global:
20
+ - COVERALLS=true
21
+ matrix:
22
+ - DB=postgres
23
+ - DB=mysql
14
24
 
15
25
  gemfile:
16
26
  - gemfiles/Gemfile.rails-4.0.rb
@@ -19,6 +29,7 @@ gemfile:
19
29
  - gemfiles/Gemfile.rails-5.0.rb
20
30
  - gemfiles/Gemfile.rails-5.1.rb
21
31
  - gemfiles/Gemfile.rails-5.2.rb
32
+ - gemfiles/Gemfile.rails-6.0.rb
22
33
 
23
34
  before_install:
24
35
  - gem update bundler
@@ -27,31 +38,59 @@ matrix:
27
38
  exclude:
28
39
  - rvm: 2.1.0
29
40
  gemfile: gemfiles/Gemfile.rails-5.2.rb
41
+ - rvm: 2.1.0
42
+ gemfile: gemfiles/Gemfile.rails-6.0.rb
30
43
  - rvm: 2.2.0
31
44
  gemfile: gemfiles/Gemfile.rails-5.2.rb
45
+ - rvm: 2.2.0
46
+ gemfile: gemfiles/Gemfile.rails-6.0.rb
32
47
  - rvm: jruby-9.1.13.0
33
48
  gemfile: gemfiles/Gemfile.rails-5.2.rb
49
+ - rvm: jruby-9.1.13.0
50
+ gemfile: gemfiles/Gemfile.rails-6.0.rb
51
+ - rvm: 2.1.0
52
+ gemfile: gemfiles/Gemfile.rails-5.0.rb
34
53
  - rvm: 2.1.0
35
54
  gemfile: gemfiles/Gemfile.rails-5.1.rb
55
+ - rvm: 2.1.0
56
+ gemfile: gemfiles/Gemfile.rails-6.0.rb
36
57
  - rvm: 2.2.0
37
58
  gemfile: gemfiles/Gemfile.rails-5.1.rb
38
- - rvm: 2.1.0
59
+ - rvm: 2.2.0
39
60
  gemfile: gemfiles/Gemfile.rails-5.0.rb
40
61
  - rvm: 2.2.0
62
+ gemfile: gemfiles/Gemfile.rails-6.0.rb
63
+ - rvm: 2.3.8
64
+ gemfile: gemfiles/Gemfile.rails-6.0.rb
65
+ - rvm: 2.4.6
66
+ gemfile: gemfiles/Gemfile.rails-4.0.rb
67
+ - rvm: 2.4.6
68
+ gemfile: gemfiles/Gemfile.rails-4.1.rb
69
+ - rvm: 2.4.6
70
+ gemfile: gemfiles/Gemfile.rails-6.0.rb
71
+ - rvm: 2.5.5
72
+ gemfile: gemfiles/Gemfile.rails-4.0.rb
73
+ - rvm: 2.5.5
74
+ gemfile: gemfiles/Gemfile.rails-4.1.rb
75
+ - rvm: 2.5.5
41
76
  gemfile: gemfiles/Gemfile.rails-5.0.rb
42
- - rvm: 2.4.0
77
+ - rvm: 2.5.5
78
+ gemfile: gemfiles/Gemfile.rails-5.1.rb
79
+ - rvm: 2.6.3
43
80
  gemfile: gemfiles/Gemfile.rails-4.0.rb
44
- - rvm: 2.4.0
81
+ - rvm: 2.6.3
45
82
  gemfile: gemfiles/Gemfile.rails-4.1.rb
83
+ - rvm: 2.6.3
84
+ gemfile: gemfiles/Gemfile.rails-5.0.rb
85
+ - rvm: 2.6.3
86
+ gemfile: gemfiles/Gemfile.rails-5.1.rb
46
87
  allow_failures:
47
88
  - rvm: jruby-9.1.13.0
48
89
  gemfile: gemfiles/Gemfile.rails-5.1.rb
49
90
  - rvm: jruby-9.1.13.0
50
91
  gemfile: gemfiles/Gemfile.rails-5.0.rb
51
92
 
52
- sudo: false
53
-
54
93
  before_script:
55
94
  - bundle exec rake db:create db:up
56
95
 
57
- script: 'COVERALLS=true bundle exec rake test'
96
+ script: 'bundle exec rake test'
@@ -3,6 +3,21 @@
3
3
  We would like to think our many [contributors](https://github.com/norman/friendly_id/graphs/contributors) for
4
4
  suggestions, ideas and improvements to FriendlyId.
5
5
 
6
+ ## 5.3.0 (2019-09-25)
7
+
8
+ * Record history when scope changes but slug does not ([#916](https://github.com/norman/friendly_id/pull/916))
9
+ * Add support for Rails 6 ([#897](https://github.com/norman/friendly_id/pull/897))
10
+
11
+ ## 5.2.5 (2018-12-30)
12
+
13
+ * Pass all possible parameters to ActiveRecord::RecordNotFound.new when raising the exception ([#890](https://github.com/norman/friendly_id/pull/890))
14
+ * Use composite index for queries by sluggable ([#882](https://github.com/norman/friendly_id/pull/882))
15
+ * Scoped: generate new slug if scope changed ([#878](https://github.com/norman/friendly_id/pull/878))
16
+ * Fix History + SequentiallySlugged issues ([#877](https://github.com/norman/friendly_id/pull/877))
17
+ * Support scoped with STI ([#745](https://github.com/norman/friendly_id/pull/745))
18
+ * Fix exists? to behave the same as find for numeric slugs ([#875](https://github.com/norman/friendly_id/pull/875))
19
+ * Remove dirty tracking code from to_param ([#867](https://github.com/norman/friendly_id/pull/867))
20
+
6
21
  ## 5.2.4 (2018-04-24)
7
22
 
8
23
  * Fix compatibility with Rails versions 4.0 -> 5.2. ([#863](https://github.com/norman/friendly_id/pull/863)).
data/README.md CHANGED
@@ -117,8 +117,8 @@ If you have a bug to report, please include the following information:
117
117
  If you are able to, it helps even more if you can fork FriendlyId on Github,
118
118
  and add a test that reproduces the error you are experiencing.
119
119
 
120
- For more info on how to report bugs, please see [this
121
- article](http://yourbugreportneedsmore.info/).
120
+ For more inspiration on how to report bugs, please see [this
121
+ article](https://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
122
122
 
123
123
  ## Thanks and Credits
124
124
 
@@ -8,7 +8,6 @@ Gem::Specification.new do |s|
8
8
  s.email = ["norman@njclarke.com", "p@arndt.io"]
9
9
  s.homepage = "https://github.com/norman/friendly_id"
10
10
  s.summary = "A comprehensive slugging and pretty-URL plugin."
11
- s.rubyforge_project = "friendly_id"
12
11
  s.files = `git ls-files`.split("\n")
13
12
  s.test_files = `git ls-files -- {test}/*`.split("\n")
14
13
  s.require_paths = ["lib"]
@@ -0,0 +1,27 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '../'
4
+
5
+ gem 'activerecord', '~> 6.0.0'
6
+ gem 'railties', '~> 6.0.0'
7
+
8
+ # Database Configuration
9
+ group :development, :test do
10
+ platforms :jruby do
11
+ gem 'activerecord-jdbcmysql-adapter', '~> 51.1'
12
+ gem 'activerecord-jdbcpostgresql-adapter', '~> 51.1'
13
+ gem 'kramdown'
14
+ end
15
+
16
+ platforms :ruby, :rbx do
17
+ gem 'sqlite3'
18
+ gem 'mysql2'
19
+ gem 'pg'
20
+ gem 'redcarpet'
21
+ end
22
+
23
+ platforms :rbx do
24
+ gem 'rubysl', '~> 2.0'
25
+ gem 'rubinius-developer_tools'
26
+ end
27
+ end
@@ -76,7 +76,7 @@ for models that use FriendlyId with something similar to the following:
76
76
  def self.setup(model_class)
77
77
  model_class.instance_eval do
78
78
  relation.class.send(:include, friendly_id_config.finder_methods)
79
- if (ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR == 2) || ActiveRecord::VERSION::MAJOR == 5
79
+ if (ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR == 2) || ActiveRecord::VERSION::MAJOR >= 5
80
80
  model_class.send(:extend, friendly_id_config.finder_methods)
81
81
  end
82
82
  end
@@ -122,7 +122,7 @@ method.
122
122
 
123
123
  def create_slug
124
124
  return unless friendly_id
125
- return if slugs.first.try(:slug) == friendly_id
125
+ return if history_is_up_to_date?
126
126
  # Allow reversion back to a previously used slug
127
127
  relation = slugs.where(:slug => friendly_id)
128
128
  if friendly_id_config.uses?(:scoped)
@@ -134,5 +134,14 @@ method.
134
134
  record.scope = serialized_scope if friendly_id_config.uses?(:scoped)
135
135
  end
136
136
  end
137
+
138
+ def history_is_up_to_date?
139
+ latest_history = slugs.first
140
+ check = latest_history.try(:slug) == friendly_id
141
+ if friendly_id_config.uses?(:scoped)
142
+ check = check && latest_history.scope == serialized_scope
143
+ end
144
+ check
145
+ end
137
146
  end
138
147
  end
@@ -1,3 +1,3 @@
1
1
  module FriendlyId
2
- VERSION = '5.2.5'.freeze
2
+ VERSION = '5.3.0'.freeze
3
3
  end
@@ -377,6 +377,33 @@ class ScopedHistoryTest < TestCaseClass
377
377
  end
378
378
  end
379
379
 
380
+ test "should record history when scope changes" do
381
+ transaction do
382
+ city1 = City.create!
383
+ city2 = City.create!
384
+ with_instance_of(Restaurant) do |record|
385
+ record.name = "x"
386
+ record.slug = nil
387
+
388
+ record.city = city1
389
+ record.save!
390
+ assert_equal("city_id:#{city1.id}", record.slugs.reload.first.scope)
391
+ assert_equal("x", record.slugs.reload.first.slug)
392
+
393
+ record.city = city2
394
+ record.save!
395
+ assert_equal("city_id:#{city2.id}", record.slugs.reload.first.scope)
396
+
397
+ record.name = "y"
398
+ record.slug = nil
399
+ record.city = city1
400
+ record.save!
401
+ assert_equal("city_id:#{city1.id}", record.slugs.reload.first.scope)
402
+ assert_equal("y", record.slugs.reload.first.slug)
403
+ end
404
+ end
405
+ end
406
+
380
407
  test "should allow equal slugs in different scopes" do
381
408
  transaction do
382
409
  city = City.create!
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.2.5
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Norman Clarke
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-12-30 00:00:00.000000000 Z
12
+ date: 2019-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -167,6 +167,7 @@ files:
167
167
  - gemfiles/Gemfile.rails-5.0.rb
168
168
  - gemfiles/Gemfile.rails-5.1.rb
169
169
  - gemfiles/Gemfile.rails-5.2.rb
170
+ - gemfiles/Gemfile.rails-6.0.rb
170
171
  - guide.rb
171
172
  - lib/friendly_id.rb
172
173
  - lib/friendly_id/.gitattributes
@@ -228,8 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
229
  - !ruby/object:Gem::Version
229
230
  version: '0'
230
231
  requirements: []
231
- rubyforge_project: friendly_id
232
- rubygems_version: 2.7.6
232
+ rubygems_version: 3.0.3
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: A comprehensive slugging and pretty-URL plugin.