friendly_id 5.6.0 → 5.7.0
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.
- checksums.yaml +4 -4
- data/lib/friendly_id/version.rb +1 -1
- metadata +2 -44
- data/.gemtest +0 -0
- data/.github/FUNDING.yml +0 -1
- data/.github/dependabot.yml +0 -6
- data/.github/stale.yml +0 -17
- data/.github/workflows/release.yml +0 -29
- data/.github/workflows/test.yml +0 -86
- data/.gitignore +0 -14
- data/.yardopts +0 -8
- data/CONTRIBUTING.md +0 -11
- data/Gemfile +0 -23
- data/Rakefile +0 -100
- data/UPGRADING.md +0 -115
- data/bench.rb +0 -84
- data/friendly_id.gemspec +0 -31
- data/gemfiles/Gemfile.rails-6.0.rb +0 -22
- data/gemfiles/Gemfile.rails-6.1.rb +0 -22
- data/gemfiles/Gemfile.rails-7.0.rb +0 -22
- data/gemfiles/Gemfile.rails-7.1.rb +0 -22
- data/gemfiles/Gemfile.rails-7.2.rb +0 -22
- data/gemfiles/Gemfile.rails-8.0.rb +0 -22
- data/guide.rb +0 -24
- data/test/base_test.rb +0 -69
- data/test/benchmarks/finders.rb +0 -90
- data/test/benchmarks/object_utils.rb +0 -56
- data/test/candidates_test.rb +0 -142
- data/test/configuration_test.rb +0 -60
- data/test/core_test.rb +0 -35
- data/test/databases.yml +0 -22
- data/test/finders_test.rb +0 -76
- data/test/generator_test.rb +0 -38
- data/test/helper.rb +0 -125
- data/test/history_test.rb +0 -434
- data/test/numeric_slug_test.rb +0 -100
- data/test/object_utils_test.rb +0 -27
- data/test/reserved_test.rb +0 -73
- data/test/schema.rb +0 -117
- data/test/scoped_test.rb +0 -95
- data/test/sequentially_slugged_test.rb +0 -214
- data/test/shared.rb +0 -181
- data/test/simple_i18n_test.rb +0 -144
- data/test/slugged_test.rb +0 -628
- data/test/sti_test.rb +0 -135
data/test/simple_i18n_test.rb
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
require "helper"
|
|
2
|
-
|
|
3
|
-
class SimpleI18nTest < TestCaseClass
|
|
4
|
-
include FriendlyId::Test
|
|
5
|
-
|
|
6
|
-
class Journalist < ActiveRecord::Base
|
|
7
|
-
extend FriendlyId
|
|
8
|
-
friendly_id :name, use: :simple_i18n
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def setup
|
|
12
|
-
I18n.locale = :en
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
test "friendly_id should return the current locale's slug" do
|
|
16
|
-
journalist = Journalist.new(name: "John Doe")
|
|
17
|
-
journalist.slug_es = "juan-fulano"
|
|
18
|
-
journalist.slug_fr_ca = "jean-dupont"
|
|
19
|
-
journalist.valid?
|
|
20
|
-
I18n.with_locale(I18n.default_locale) do
|
|
21
|
-
assert_equal "john-doe", journalist.friendly_id
|
|
22
|
-
end
|
|
23
|
-
I18n.with_locale(:es) do
|
|
24
|
-
assert_equal "juan-fulano", journalist.friendly_id
|
|
25
|
-
end
|
|
26
|
-
I18n.with_locale(:"fr-CA") do
|
|
27
|
-
assert_equal "jean-dupont", journalist.friendly_id
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
test "should create record with slug in column for the current locale" do
|
|
32
|
-
I18n.with_locale(I18n.default_locale) do
|
|
33
|
-
journalist = Journalist.new(name: "John Doe")
|
|
34
|
-
journalist.valid?
|
|
35
|
-
assert_equal "john-doe", journalist.slug_en
|
|
36
|
-
assert_nil journalist.slug_es
|
|
37
|
-
end
|
|
38
|
-
I18n.with_locale(:es) do
|
|
39
|
-
journalist = Journalist.new(name: "John Doe")
|
|
40
|
-
journalist.valid?
|
|
41
|
-
assert_equal "john-doe", journalist.slug_es
|
|
42
|
-
assert_nil journalist.slug_en
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
test "to_param should return the numeric id when there's no slug for the current locale" do
|
|
47
|
-
transaction do
|
|
48
|
-
journalist = Journalist.new(name: "Juan Fulano")
|
|
49
|
-
I18n.with_locale(:es) do
|
|
50
|
-
journalist.save!
|
|
51
|
-
assert_equal "juan-fulano", journalist.to_param
|
|
52
|
-
end
|
|
53
|
-
assert_equal journalist.id.to_s, journalist.to_param
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
test "should set friendly id for locale" do
|
|
58
|
-
transaction do
|
|
59
|
-
journalist = Journalist.create!(name: "John Smith")
|
|
60
|
-
journalist.set_friendly_id("Juan Fulano", :es)
|
|
61
|
-
journalist.save!
|
|
62
|
-
assert_equal "juan-fulano", journalist.slug_es
|
|
63
|
-
I18n.with_locale(:es) do
|
|
64
|
-
assert_equal "juan-fulano", journalist.to_param
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
test "set friendly_id should fall back default locale when none is given" do
|
|
70
|
-
transaction do
|
|
71
|
-
journalist = I18n.with_locale(:es) do
|
|
72
|
-
Journalist.create!(name: "Juan Fulano")
|
|
73
|
-
end
|
|
74
|
-
journalist.set_friendly_id("John Doe")
|
|
75
|
-
journalist.save!
|
|
76
|
-
assert_equal "john-doe", journalist.slug_en
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
test "should sequence localized slugs" do
|
|
81
|
-
transaction do
|
|
82
|
-
journalist = Journalist.create!(name: "John Smith")
|
|
83
|
-
I18n.with_locale(:es) do
|
|
84
|
-
Journalist.create!(name: "Juan Fulano")
|
|
85
|
-
end
|
|
86
|
-
journalist.set_friendly_id("Juan Fulano", :es)
|
|
87
|
-
journalist.save!
|
|
88
|
-
assert_equal "john-smith", journalist.to_param
|
|
89
|
-
I18n.with_locale(:es) do
|
|
90
|
-
assert_match(/juan-fulano-.+/, journalist.to_param)
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
class RegressionTest < TestCaseClass
|
|
96
|
-
include FriendlyId::Test
|
|
97
|
-
|
|
98
|
-
test "should not overwrite other locale's slugs on update" do
|
|
99
|
-
transaction do
|
|
100
|
-
journalist = Journalist.create!(name: "John Smith")
|
|
101
|
-
journalist.set_friendly_id("Juan Fulano", :es)
|
|
102
|
-
journalist.save!
|
|
103
|
-
assert_equal "john-smith", journalist.to_param
|
|
104
|
-
journalist.slug = nil
|
|
105
|
-
journalist.update name: "Johnny Smith"
|
|
106
|
-
assert_equal "johnny-smith", journalist.to_param
|
|
107
|
-
I18n.with_locale(:es) do
|
|
108
|
-
assert_equal "juan-fulano", journalist.to_param
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
class ConfigurationTest < TestCaseClass
|
|
115
|
-
test "should add locale to slug column for a non-default locale" do
|
|
116
|
-
I18n.with_locale :es do
|
|
117
|
-
assert_equal "slug_es", Journalist.friendly_id_config.slug_column
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
test "should add locale to slug column for a locale with a region subtag" do
|
|
122
|
-
I18n.with_locale :"fr-CA" do
|
|
123
|
-
assert_equal "slug_fr_ca", Journalist.friendly_id_config.slug_column
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
test "should add locale to non-default slug column and non-default locale" do
|
|
128
|
-
model_class = Class.new(ActiveRecord::Base) do
|
|
129
|
-
self.abstract_class = true
|
|
130
|
-
extend FriendlyId
|
|
131
|
-
friendly_id :name, use: :simple_i18n, slug_column: :foo
|
|
132
|
-
end
|
|
133
|
-
I18n.with_locale :es do
|
|
134
|
-
assert_equal "foo_es", model_class.friendly_id_config.slug_column
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
test "should add locale to slug column for default locale" do
|
|
139
|
-
I18n.with_locale(I18n.default_locale) do
|
|
140
|
-
assert_equal "slug_en", Journalist.friendly_id_config.slug_column
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|