seiten 1.0.1 → 1.1.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.
@@ -0,0 +1 @@
1
+ d903bb3e8383977eec8d47e4120fae894fd5c79cc03af889f3473857a60ba3ad3794efa808678887116994828abe094052f4a8991de8b56641a07339a29e2f14
@@ -1 +1 @@
1
- <ul class="breadcrumb"><li class="breadcrumb__item"><a href="/our-team">About</a></li><li class="breadcrumb__item"><span class="breadcrumb__separator">&gt;</span><a href="/about/our-team">Our Team</a></li><li class="breadcrumb__item breadcrumb__item--current"><span class="breadcrumb__separator">&gt;</span><a href="/about/our-team/switzerland">Switzerland</a></li></ul>
1
+ <ul class="breadcrumb"><li class="breadcrumb__item"><a href="/about/our-team">About</a></li><li class="breadcrumb__item"><span class="breadcrumb__separator">&gt;</span><a href="/about/our-team">Our Team</a></li><li class="breadcrumb__item breadcrumb__item--current"><span class="breadcrumb__separator">&gt;</span><a href="/about/our-team/switzerland">Switzerland</a></li></ul>
@@ -1 +1 @@
1
- <ul class="navigation"><li class="navigation__item navigation__item--active navigation__item--current test-class" data-behaviour="hello"><a href="/">Home</a></li><li class="navigation__item"><a href="/blog">Blog</a></li><li class="navigation__item navigation__item--parent"><a href="/products">Products</a><ul class="navigation__nodes"><li class="navigation__item"><a href="/products/logo-design">Logo Design</a></li><li class="navigation__item"><a href="/products/web-development">Web Development</a></li><li class="navigation__item"><a href="/contact">Hire us</a></li></ul></li><li class="navigation__item navigation__item--parent"><a href="/our-team">About</a><ul class="navigation__nodes"><li class="navigation__item navigation__item--parent"><a href="/about/our-team">Our Team</a></li><li class="navigation__item"><a href="/about/works">Works</a></li><li class="navigation__item navigation__item--parent"><a href="/about/partners">Partners</a></li></ul></li><li class="navigation__item"><a href="/contact">Contact</a></li><li class="navigation__item"><a href="/localization">I18n</a></li></ul>
1
+ <ul class="navigation"><li class="navigation__item navigation__item--active navigation__item--current test-class" data-behaviour="hello"><a href="/">Home</a></li><li class="navigation__item"><a href="/blog">Blog</a></li><li class="navigation__item navigation__item--parent"><a href="/products">Products</a><ul class="navigation__nodes"><li class="navigation__item"><a href="/products/logo-design">Logo Design</a></li><li class="navigation__item"><a href="/products/web-development">Web Development</a></li><li class="navigation__item"><a href="/contact">Hire us</a></li></ul></li><li class="navigation__item navigation__item--parent"><a href="/about/our-team">About</a><ul class="navigation__nodes"><li class="navigation__item navigation__item--parent"><a href="/about/our-team">Our Team</a></li><li class="navigation__item"><a href="/about/works">Works</a></li><li class="navigation__item navigation__item--parent"><a href="/about/partners">Partners</a></li></ul></li><li class="navigation__item"><a href="/contact">Contact</a></li><li class="navigation__item"><a href="/localization">I18n</a></li></ul>
@@ -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
- assert_raise ActionController::RoutingError do
6
- get '/rails/active_storage/test'
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
- assert_raise Seiten::Errors::RoutingError do
12
- get '/non-existing-route'
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
@@ -75,7 +75,7 @@ class Seiten::PageCollectionBuilderTest < ActiveSupport::TestCase
75
75
  options[:pages] << { "title" => "About us", "refer" => true, "nodes" => [{ "title" => "Team" }] }
76
76
  Seiten::PageCollectionBuilder.call(page_collection, options)
77
77
 
78
- assert_equal "/team", page_collection.where(slug: nil).first.refer
78
+ assert_equal "/about-us/team", page_collection.where(slug: nil).first.refer
79
79
  end
80
80
 
81
81
  test 'should build a referer page with an absolute path' do
@@ -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.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Puglisi
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-05-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -155,13 +154,13 @@ files:
155
154
  - test/dummy/config/navigations/help.en.yml
156
155
  - test/dummy/config/routes.rb
157
156
  - test/dummy/config/secrets.yml
158
- - test/dummy/log/development.log
159
157
  - test/dummy/log/test.log
160
158
  - test/dummy/public/404.html
161
159
  - test/dummy/public/422.html
162
160
  - test/dummy/public/500.html
163
161
  - test/dummy/public/favicon.ico
164
162
  - test/dummy/script/rails
163
+ - test/dummy/tmp/local_secret.txt
165
164
  - test/fixtures/breadcrumb.html
166
165
  - test/fixtures/navigation.html
167
166
  - test/integration/layout_test.rb
@@ -174,6 +173,7 @@ files:
174
173
  - test/lib/seiten/page_collection_builder_test.rb
175
174
  - test/lib/seiten/page_collection_test.rb
176
175
  - test/lib/seiten/page_test.rb
176
+ - test/lib/seiten/page_translation_test.rb
177
177
  - test/lib/seiten/slug_builder_test.rb
178
178
  - test/lib/seiten_test.rb
179
179
  - test/test_helper.rb
@@ -181,7 +181,6 @@ homepage: http://danielpuglisi.com
181
181
  licenses:
182
182
  - MIT
183
183
  metadata: {}
184
- post_install_message:
185
184
  rdoc_options: []
186
185
  require_paths:
187
186
  - lib
@@ -196,87 +195,87 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
195
  - !ruby/object:Gem::Version
197
196
  version: '0'
198
197
  requirements: []
199
- rubygems_version: 3.0.3.1
200
- signing_key:
198
+ rubygems_version: 4.0.10
201
199
  specification_version: 4
202
200
  summary: Static Pages for Rails.
203
201
  test_files:
202
+ - test/controllers/helper_methods_test.rb
203
+ - test/controllers/pages_controller_test.rb
204
+ - test/controllers/posts_controller_test.rb
205
+ - test/controllers/seiten/pages_controller_test.rb
206
+ - test/dummy/README.rdoc
207
+ - test/dummy/Rakefile
204
208
  - test/dummy/app/controllers/application_controller.rb
205
209
  - test/dummy/app/controllers/pages_controller.rb
206
210
  - test/dummy/app/controllers/posts_controller.rb
207
- - test/dummy/app/views/posts/index.html.erb
208
- - test/dummy/app/views/layouts/products.html.erb
209
- - test/dummy/app/views/layouts/team.html.erb
210
- - test/dummy/app/views/layouts/application.html.erb
211
- - test/dummy/app/views/layouts/home.html.erb
212
- - test/dummy/app/views/pages/secret.html.erb
213
- - test/dummy/app/pages/application/localization.html.erb
211
+ - test/dummy/app/helpers/application_helper.rb
214
212
  - test/dummy/app/pages/application/de/produkte.html.erb
215
- - test/dummy/app/pages/application/en/products/logo-design.html.erb
216
- - test/dummy/app/pages/application/en/products/web-development.html.erb
217
- - test/dummy/app/pages/application/en/products/hire-us.html.erb
218
- - test/dummy/app/pages/application/en/products.html.erb
219
- - test/dummy/app/pages/application/en/contact.html.erb
220
- - test/dummy/app/pages/application/en/about/works.html.erb
213
+ - test/dummy/app/pages/application/en/about.html.erb
221
214
  - test/dummy/app/pages/application/en/about/our-team.html.erb
222
- - test/dummy/app/pages/application/en/about/partners.html.erb
223
- - test/dummy/app/pages/application/en/about/our-team/switzerland.html.erb
224
215
  - test/dummy/app/pages/application/en/about/our-team/italy.html.erb
216
+ - test/dummy/app/pages/application/en/about/our-team/switzerland.html.erb
217
+ - test/dummy/app/pages/application/en/about/partners.html.erb
218
+ - test/dummy/app/pages/application/en/about/works.html.erb
219
+ - test/dummy/app/pages/application/en/contact.html.erb
225
220
  - test/dummy/app/pages/application/en/home.html.erb
226
- - test/dummy/app/pages/application/en/about.html.erb
227
- - test/dummy/app/pages/help/en/logging-in.html.erb
221
+ - test/dummy/app/pages/application/en/products.html.erb
222
+ - test/dummy/app/pages/application/en/products/hire-us.html.erb
223
+ - test/dummy/app/pages/application/en/products/logo-design.html.erb
224
+ - test/dummy/app/pages/application/en/products/web-development.html.erb
225
+ - test/dummy/app/pages/application/localization.html.erb
228
226
  - test/dummy/app/pages/help/en/home.html.erb
229
- - test/dummy/app/helpers/application_helper.rb
230
- - test/dummy/config/secrets.yml
231
- - test/dummy/config/routes.rb
232
- - test/dummy/config/locales/en.yml
227
+ - test/dummy/app/pages/help/en/logging-in.html.erb
228
+ - test/dummy/app/views/layouts/application.html.erb
229
+ - test/dummy/app/views/layouts/home.html.erb
230
+ - test/dummy/app/views/layouts/products.html.erb
231
+ - test/dummy/app/views/layouts/team.html.erb
232
+ - test/dummy/app/views/pages/secret.html.erb
233
+ - test/dummy/app/views/posts/index.html.erb
234
+ - test/dummy/config.ru
235
+ - test/dummy/config/application.rb
236
+ - test/dummy/config/boot.rb
233
237
  - test/dummy/config/cable.yml
234
- - test/dummy/config/environments/production.rb
238
+ - test/dummy/config/database.yml
239
+ - test/dummy/config/environment.rb
235
240
  - test/dummy/config/environments/development.rb
241
+ - test/dummy/config/environments/production.rb
236
242
  - test/dummy/config/environments/test.rb
237
- - test/dummy/config/environment.rb
238
- - test/dummy/config/application.rb
239
- - test/dummy/config/database.yml
240
- - test/dummy/config/navigations/application.en.yml
241
- - test/dummy/config/navigations/help.en.yml
242
- - test/dummy/config/navigations/application.de.yml
243
- - test/dummy/config/boot.rb
244
243
  - test/dummy/config/initializers/application_controller_renderer.rb
245
244
  - test/dummy/config/initializers/backtrace_silencers.rb
246
- - test/dummy/config/initializers/mime_types.rb
245
+ - test/dummy/config/initializers/cookies_serializer.rb
247
246
  - test/dummy/config/initializers/filter_parameter_logging.rb
248
- - test/dummy/config/initializers/session_store.rb
249
- - test/dummy/config/initializers/wrap_parameters.rb
247
+ - test/dummy/config/initializers/inflections.rb
248
+ - test/dummy/config/initializers/mime_types.rb
250
249
  - test/dummy/config/initializers/new_framework_defaults.rb
251
- - test/dummy/config/initializers/cookies_serializer.rb
252
250
  - test/dummy/config/initializers/secret_token.rb
253
- - test/dummy/config/initializers/inflections.rb
254
- - test/dummy/config.ru
255
- - test/dummy/script/rails
256
- - test/dummy/Rakefile
257
- - test/dummy/public/favicon.ico
251
+ - test/dummy/config/initializers/session_store.rb
252
+ - test/dummy/config/initializers/wrap_parameters.rb
253
+ - test/dummy/config/locales/en.yml
254
+ - test/dummy/config/navigations/application.de.yml
255
+ - test/dummy/config/navigations/application.en.yml
256
+ - test/dummy/config/navigations/help.en.yml
257
+ - test/dummy/config/routes.rb
258
+ - test/dummy/config/secrets.yml
259
+ - test/dummy/log/test.log
260
+ - test/dummy/public/404.html
258
261
  - test/dummy/public/422.html
259
262
  - test/dummy/public/500.html
260
- - test/dummy/public/404.html
261
- - test/dummy/log/test.log
262
- - test/dummy/log/development.log
263
- - test/dummy/README.rdoc
263
+ - test/dummy/public/favicon.ico
264
+ - test/dummy/script/rails
265
+ - test/dummy/tmp/local_secret.txt
266
+ - test/fixtures/breadcrumb.html
267
+ - test/fixtures/navigation.html
264
268
  - test/integration/layout_test.rb
265
269
  - test/integration/navigation_test.rb
266
- - test/lib/seiten/slug_builder_test.rb
270
+ - test/lib/seiten/helpers/frontend_test.rb
267
271
  - test/lib/seiten/html/breadcrumb_test.rb
268
272
  - test/lib/seiten/html/helpers_test.rb
269
273
  - test/lib/seiten/html/navigation_test.rb
270
- - test/lib/seiten/page_test.rb
271
- - test/lib/seiten/page_collection_builder_test.rb
272
274
  - test/lib/seiten/navigation_test.rb
275
+ - test/lib/seiten/page_collection_builder_test.rb
273
276
  - test/lib/seiten/page_collection_test.rb
274
- - test/lib/seiten/helpers/frontend_test.rb
277
+ - test/lib/seiten/page_test.rb
278
+ - test/lib/seiten/page_translation_test.rb
279
+ - test/lib/seiten/slug_builder_test.rb
275
280
  - test/lib/seiten_test.rb
276
- - test/fixtures/breadcrumb.html
277
- - test/fixtures/navigation.html
278
281
  - test/test_helper.rb
279
- - test/controllers/seiten/pages_controller_test.rb
280
- - test/controllers/posts_controller_test.rb
281
- - test/controllers/helper_methods_test.rb
282
- - test/controllers/pages_controller_test.rb