seiten 1.0.2 → 1.2.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/seiten/page.rb +33 -1
- data/lib/seiten/railtie.rb +3 -0
- data/lib/seiten/routes_helper.rb +1 -1
- data/lib/seiten/version.rb +1 -1
- data/lib/seiten.rb +64 -6
- data/test/dummy/config/initializers/new_framework_defaults.rb +0 -4
- data/test/dummy/config/locales/guide.de.yml +13 -0
- data/test/dummy/config/locales/guide.en.yml +14 -0
- data/test/dummy/config/navigations/guide.yml +7 -0
- data/test/dummy/log/test.log +11304 -42632
- data/test/dummy/tmp/local_secret.txt +1 -0
- data/test/integration/navigation_test.rb +4 -6
- data/test/lib/seiten/html/helpers_test.rb +4 -3
- data/test/lib/seiten/i18n_navigation_test.rb +47 -0
- data/test/lib/seiten/page_translation_test.rb +64 -0
- metadata +19 -12
- data/test/dummy/log/development.log +0 -1716
|
@@ -0,0 +1 @@
|
|
|
1
|
+
d903bb3e8383977eec8d47e4120fae894fd5c79cc03af889f3473857a60ba3ad3794efa808678887116994828abe094052f4a8991de8b56641a07339a29e2f14
|
|
@@ -2,15 +2,13 @@ require 'test_helper'
|
|
|
2
2
|
|
|
3
3
|
class NavigationTest < ActionDispatch::IntegrationTest
|
|
4
4
|
def test_should_ignore_active_storage_routes
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
end
|
|
5
|
+
get '/rails/active_storage/test'
|
|
6
|
+
assert_response :not_found
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
def test_should_raise_seiten_routing_error
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
10
|
+
get '/non-existing-route'
|
|
11
|
+
assert_response :not_found
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
def test_returns_2_level_deep_navigation
|
|
@@ -2,12 +2,13 @@ require 'test_helper'
|
|
|
2
2
|
|
|
3
3
|
class Seiten::HTML::HelpersTest < ActiveSupport::TestCase
|
|
4
4
|
|
|
5
|
+
# Its own navigation: pages added to a shared one would show up in other tests.
|
|
5
6
|
def navigation
|
|
6
|
-
@navigation ||= Seiten::Navigation.
|
|
7
|
+
@navigation ||= Seiten::Navigation.new(name: :helpers_test, locale: :en).tap { |navigation| Seiten.navigations << navigation }
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
@
|
|
10
|
+
teardown do
|
|
11
|
+
Seiten.navigations -= [@navigation] if @navigation
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
def helpers
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Seiten::I18nNavigationTest < ActiveSupport::TestCase
|
|
4
|
+
def navigation(locale)
|
|
5
|
+
Seiten::Navigation.find_by(name: 'guide', locale: locale)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def page(locale, key)
|
|
9
|
+
navigation(locale).pages.find_by(key: key)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
test 'one structure file gives a navigation in every available locale' do
|
|
13
|
+
assert_equal ['de', 'en'], Seiten::Navigation.where(name: 'guide').map(&:locale).sort
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
test 'titles and slugs come from I18n, nested like the pages' do
|
|
17
|
+
assert_equal 'Account verwalten', page('de', 'account.manage').title
|
|
18
|
+
assert_equal 'dein-account/account-verwalten', page('de', 'account.manage').slug
|
|
19
|
+
assert_equal 'your-account/account-security', page('en', 'account.security').slug, 'a translated slug replaces the title'
|
|
20
|
+
assert_equal '', page('en', 'start').slug, 'url in the structure applies to every locale'
|
|
21
|
+
assert_equal page('en', 'account'), page('en', 'account.manage').parent
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test 'pages with the same key translate each other' do
|
|
25
|
+
assert_equal page('en', 'account.manage'), page('de', 'account.manage').translation(:en)
|
|
26
|
+
assert_equal({ 'de' => page('de', 'billing'), 'en' => page('en', 'billing') }, page('en', 'billing').translations)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
test 'navigations are built again with reloaded translations' do
|
|
30
|
+
I18n.backend.store_translations(:en, navigations: { guide: { billing: { title: 'Invoices' } } })
|
|
31
|
+
Seiten.reset_i18n_navigations!
|
|
32
|
+
|
|
33
|
+
assert_equal 'invoices', page('en', 'billing').slug
|
|
34
|
+
ensure
|
|
35
|
+
I18n.backend.store_translations(:en, navigations: { guide: { billing: { title: 'Billing' } } })
|
|
36
|
+
Seiten.reset_i18n_navigations!
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
test 'a page needs a key and a title or slug' do
|
|
40
|
+
assert_raises(Seiten::Errors::PageError) { Seiten.send(:i18n_pages, [{ 'title' => 'Untitled' }], :en, ['navigations', 'guide']) }
|
|
41
|
+
assert_raises(Seiten::Errors::PageError) { Seiten.send(:i18n_pages, [{ 'key' => 'missing' }], :en, ['navigations', 'guide']) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
test 'navigations of one locale per file keep working' do
|
|
45
|
+
assert_equal 'Produkte', Seiten::Navigation.find_by(name: 'application', locale: 'de').pages.find_by(slug: 'produkte').title
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Seiten::PageTranslationTest < ActiveSupport::TestCase
|
|
4
|
+
def build(locale, pages)
|
|
5
|
+
navigation = Seiten::Navigation.new(name: :manual, locale: locale)
|
|
6
|
+
Seiten.navigations << navigation
|
|
7
|
+
navigation.pages.build(pages: pages)
|
|
8
|
+
navigation
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def page(navigation, title)
|
|
12
|
+
navigation.pages.find_by(title: title)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
setup do
|
|
16
|
+
@de = build(:de, [
|
|
17
|
+
{ 'title' => 'Einleitung', 'nodes' => [{ 'title' => 'Module' }, { 'title' => 'Account einrichten' }] },
|
|
18
|
+
{ 'title' => 'Rechnungen', 'key' => 'invoices' },
|
|
19
|
+
{ 'title' => 'Kontakt' }
|
|
20
|
+
])
|
|
21
|
+
@en = build(:en, [
|
|
22
|
+
{ 'title' => 'Introduction', 'nodes' => [{ 'title' => 'Modules' }, { 'title' => 'Set up your account' }] },
|
|
23
|
+
{ 'title' => 'Pricing' },
|
|
24
|
+
{ 'title' => 'Contact' },
|
|
25
|
+
{ 'title' => 'Invoices', 'key' => 'invoices' }
|
|
26
|
+
])
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
teardown do
|
|
30
|
+
Seiten.navigations -= [@de, @en]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test '#position is the index path in the navigation tree' do
|
|
34
|
+
assert_equal [0], page(@de, 'Einleitung').position
|
|
35
|
+
assert_equal [0, 1], page(@de, 'Account einrichten').position
|
|
36
|
+
assert_equal [2], page(@de, 'Kontakt').position
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
test '#translation finds the page at the same position in the other locale' do
|
|
40
|
+
assert_equal page(@en, 'Introduction'), page(@de, 'Einleitung').translation(:en)
|
|
41
|
+
assert_equal page(@en, 'Set up your account'), page(@de, 'Account einrichten').translation('en')
|
|
42
|
+
assert_equal page(@de, 'Module'), page(@en, 'Modules').translation(:de)
|
|
43
|
+
assert_equal page(@en, 'Contact'), page(@de, 'Kontakt').translation(:en)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
test '#translation matches pages with a key by their key, wherever they are' do
|
|
47
|
+
assert_equal page(@en, 'Invoices'), page(@de, 'Rechnungen').translation(:en)
|
|
48
|
+
assert_equal page(@de, 'Rechnungen'), page(@en, 'Invoices').translation(:de)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
test '#translation leaves out pages without a counterpart' do
|
|
52
|
+
assert_nil page(@en, 'Pricing').translation(:de), 'the German page at its position has a key'
|
|
53
|
+
assert_nil page(@de, 'Einleitung').translation(:fr), 'no French navigation'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
test '#translation of the own locale is the page itself' do
|
|
57
|
+
assert_equal page(@de, 'Module'), page(@de, 'Module').translation(:de)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
test '#translations lists the page in every locale that has it' do
|
|
61
|
+
assert_equal({ 'de' => page(@de, 'Module'), 'en' => page(@en, 'Modules') }, page(@de, 'Module').translations)
|
|
62
|
+
assert_equal({ 'en' => page(@en, 'Pricing') }, page(@en, 'Pricing').translations)
|
|
63
|
+
end
|
|
64
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: seiten
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Puglisi
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -150,18 +149,21 @@ files:
|
|
|
150
149
|
- test/dummy/config/initializers/session_store.rb
|
|
151
150
|
- test/dummy/config/initializers/wrap_parameters.rb
|
|
152
151
|
- test/dummy/config/locales/en.yml
|
|
152
|
+
- test/dummy/config/locales/guide.de.yml
|
|
153
|
+
- test/dummy/config/locales/guide.en.yml
|
|
153
154
|
- test/dummy/config/navigations/application.de.yml
|
|
154
155
|
- test/dummy/config/navigations/application.en.yml
|
|
156
|
+
- test/dummy/config/navigations/guide.yml
|
|
155
157
|
- test/dummy/config/navigations/help.en.yml
|
|
156
158
|
- test/dummy/config/routes.rb
|
|
157
159
|
- test/dummy/config/secrets.yml
|
|
158
|
-
- test/dummy/log/development.log
|
|
159
160
|
- test/dummy/log/test.log
|
|
160
161
|
- test/dummy/public/404.html
|
|
161
162
|
- test/dummy/public/422.html
|
|
162
163
|
- test/dummy/public/500.html
|
|
163
164
|
- test/dummy/public/favicon.ico
|
|
164
165
|
- test/dummy/script/rails
|
|
166
|
+
- test/dummy/tmp/local_secret.txt
|
|
165
167
|
- test/fixtures/breadcrumb.html
|
|
166
168
|
- test/fixtures/navigation.html
|
|
167
169
|
- test/integration/layout_test.rb
|
|
@@ -170,10 +172,12 @@ files:
|
|
|
170
172
|
- test/lib/seiten/html/breadcrumb_test.rb
|
|
171
173
|
- test/lib/seiten/html/helpers_test.rb
|
|
172
174
|
- test/lib/seiten/html/navigation_test.rb
|
|
175
|
+
- test/lib/seiten/i18n_navigation_test.rb
|
|
173
176
|
- test/lib/seiten/navigation_test.rb
|
|
174
177
|
- test/lib/seiten/page_collection_builder_test.rb
|
|
175
178
|
- test/lib/seiten/page_collection_test.rb
|
|
176
179
|
- test/lib/seiten/page_test.rb
|
|
180
|
+
- test/lib/seiten/page_translation_test.rb
|
|
177
181
|
- test/lib/seiten/slug_builder_test.rb
|
|
178
182
|
- test/lib/seiten_test.rb
|
|
179
183
|
- test/test_helper.rb
|
|
@@ -181,7 +185,6 @@ homepage: http://danielpuglisi.com
|
|
|
181
185
|
licenses:
|
|
182
186
|
- MIT
|
|
183
187
|
metadata: {}
|
|
184
|
-
post_install_message:
|
|
185
188
|
rdoc_options: []
|
|
186
189
|
require_paths:
|
|
187
190
|
- lib
|
|
@@ -196,8 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
196
199
|
- !ruby/object:Gem::Version
|
|
197
200
|
version: '0'
|
|
198
201
|
requirements: []
|
|
199
|
-
rubygems_version:
|
|
200
|
-
signing_key:
|
|
202
|
+
rubygems_version: 4.0.10
|
|
201
203
|
specification_version: 4
|
|
202
204
|
summary: Static Pages for Rails.
|
|
203
205
|
test_files:
|
|
@@ -212,18 +214,18 @@ test_files:
|
|
|
212
214
|
- test/dummy/app/controllers/posts_controller.rb
|
|
213
215
|
- test/dummy/app/helpers/application_helper.rb
|
|
214
216
|
- test/dummy/app/pages/application/de/produkte.html.erb
|
|
217
|
+
- test/dummy/app/pages/application/en/about.html.erb
|
|
218
|
+
- test/dummy/app/pages/application/en/about/our-team.html.erb
|
|
215
219
|
- test/dummy/app/pages/application/en/about/our-team/italy.html.erb
|
|
216
220
|
- test/dummy/app/pages/application/en/about/our-team/switzerland.html.erb
|
|
217
|
-
- test/dummy/app/pages/application/en/about/our-team.html.erb
|
|
218
221
|
- test/dummy/app/pages/application/en/about/partners.html.erb
|
|
219
222
|
- test/dummy/app/pages/application/en/about/works.html.erb
|
|
220
|
-
- test/dummy/app/pages/application/en/about.html.erb
|
|
221
223
|
- test/dummy/app/pages/application/en/contact.html.erb
|
|
222
224
|
- test/dummy/app/pages/application/en/home.html.erb
|
|
225
|
+
- test/dummy/app/pages/application/en/products.html.erb
|
|
223
226
|
- test/dummy/app/pages/application/en/products/hire-us.html.erb
|
|
224
227
|
- test/dummy/app/pages/application/en/products/logo-design.html.erb
|
|
225
228
|
- test/dummy/app/pages/application/en/products/web-development.html.erb
|
|
226
|
-
- test/dummy/app/pages/application/en/products.html.erb
|
|
227
229
|
- test/dummy/app/pages/application/localization.html.erb
|
|
228
230
|
- test/dummy/app/pages/help/en/home.html.erb
|
|
229
231
|
- test/dummy/app/pages/help/en/logging-in.html.erb
|
|
@@ -233,6 +235,7 @@ test_files:
|
|
|
233
235
|
- test/dummy/app/views/layouts/team.html.erb
|
|
234
236
|
- test/dummy/app/views/pages/secret.html.erb
|
|
235
237
|
- test/dummy/app/views/posts/index.html.erb
|
|
238
|
+
- test/dummy/config.ru
|
|
236
239
|
- test/dummy/config/application.rb
|
|
237
240
|
- test/dummy/config/boot.rb
|
|
238
241
|
- test/dummy/config/cable.yml
|
|
@@ -252,19 +255,21 @@ test_files:
|
|
|
252
255
|
- test/dummy/config/initializers/session_store.rb
|
|
253
256
|
- test/dummy/config/initializers/wrap_parameters.rb
|
|
254
257
|
- test/dummy/config/locales/en.yml
|
|
258
|
+
- test/dummy/config/locales/guide.de.yml
|
|
259
|
+
- test/dummy/config/locales/guide.en.yml
|
|
255
260
|
- test/dummy/config/navigations/application.de.yml
|
|
256
261
|
- test/dummy/config/navigations/application.en.yml
|
|
262
|
+
- test/dummy/config/navigations/guide.yml
|
|
257
263
|
- test/dummy/config/navigations/help.en.yml
|
|
258
264
|
- test/dummy/config/routes.rb
|
|
259
265
|
- test/dummy/config/secrets.yml
|
|
260
|
-
- test/dummy/config.ru
|
|
261
|
-
- test/dummy/log/development.log
|
|
262
266
|
- test/dummy/log/test.log
|
|
263
267
|
- test/dummy/public/404.html
|
|
264
268
|
- test/dummy/public/422.html
|
|
265
269
|
- test/dummy/public/500.html
|
|
266
270
|
- test/dummy/public/favicon.ico
|
|
267
271
|
- test/dummy/script/rails
|
|
272
|
+
- test/dummy/tmp/local_secret.txt
|
|
268
273
|
- test/fixtures/breadcrumb.html
|
|
269
274
|
- test/fixtures/navigation.html
|
|
270
275
|
- test/integration/layout_test.rb
|
|
@@ -273,10 +278,12 @@ test_files:
|
|
|
273
278
|
- test/lib/seiten/html/breadcrumb_test.rb
|
|
274
279
|
- test/lib/seiten/html/helpers_test.rb
|
|
275
280
|
- test/lib/seiten/html/navigation_test.rb
|
|
281
|
+
- test/lib/seiten/i18n_navigation_test.rb
|
|
276
282
|
- test/lib/seiten/navigation_test.rb
|
|
277
283
|
- test/lib/seiten/page_collection_builder_test.rb
|
|
278
284
|
- test/lib/seiten/page_collection_test.rb
|
|
279
285
|
- test/lib/seiten/page_test.rb
|
|
286
|
+
- test/lib/seiten/page_translation_test.rb
|
|
280
287
|
- test/lib/seiten/slug_builder_test.rb
|
|
281
288
|
- test/lib/seiten_test.rb
|
|
282
289
|
- test/test_helper.rb
|