qbrick 2.6.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/qbrick/pages_controller.rb +4 -5
- data/app/controllers/qbrick/sitemaps_controller.rb +1 -1
- data/app/helpers/sitemaps_helper.rb +2 -5
- data/app/models/qbrick/page.rb +27 -30
- data/app/views/qbrick/cms/pages/_form.html.haml +6 -6
- data/app/views/qbrick/search/_results_entry.html.haml +1 -1
- data/app/views/qbrick/sitemaps/index.xml.haml +1 -1
- data/config/locales/models/qbrick/admin/de.yml +1 -1
- data/config/routes.rb +5 -5
- data/db/migrate/25_rename_qbrick_pages_url_to_path.rb +33 -0
- data/lib/qbrick/brick_list.rb +1 -0
- data/lib/qbrick/translatable.rb +5 -1
- data/lib/qbrick/version.rb +1 -1
- data/lib/tasks/qbrick_tasks.rake +3 -2
- data/spec/controllers/qbrick/api/pages_controller_spec.rb +13 -11
- data/spec/controllers/qbrick/cms/pages_controller_spec.rb +5 -7
- data/spec/controllers/qbrick/pages_controller_spec.rb +30 -43
- data/spec/controllers/qbrick/sitemaps_controller_spec.rb +4 -5
- data/spec/factories.rb +7 -1
- data/spec/features/administrator_management_spec.rb +10 -13
- data/spec/features/cms_pages_spec.rb +19 -13
- data/spec/features/search_spec.rb +15 -17
- data/spec/helpers/qbrick/cms/pages_helper_spec.rb +10 -5
- data/spec/lib/translatable_spec.rb +17 -16
- data/spec/models/page_spec.rb +77 -52
- data/spec/spec_helper.rb +1 -1
- data/spec/views/qbrick/sitemaps/index.xml.haml_spec.rb +7 -6
- metadata +4 -3
data/spec/models/page_spec.rb
CHANGED
@@ -32,10 +32,10 @@ describe Qbrick::Page, type: :model do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe '.
|
35
|
+
describe '.find_by_path' do
|
36
36
|
it 'should find its translated content by url' do
|
37
37
|
page = create(:page)
|
38
|
-
expect(Qbrick::Page.
|
38
|
+
expect(Qbrick::Page.find_by_path(page.path)).to eq(page)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -253,7 +253,7 @@ describe Qbrick::Page, type: :model do
|
|
253
253
|
it 'returns the concatenated slug of the whole child/parent tree' do
|
254
254
|
page = create(:page, slug: 'parent-slug')
|
255
255
|
child = create(:page, slug: 'child-slug', parent: page)
|
256
|
-
expect(child.
|
256
|
+
expect(child.path).to eq('/parent-slug/child-slug')
|
257
257
|
end
|
258
258
|
end
|
259
259
|
|
@@ -261,21 +261,25 @@ describe Qbrick::Page, type: :model do
|
|
261
261
|
it 'returns without the parent page slug' do
|
262
262
|
page = create(:page, slug: 'parent-slug', page_type: Qbrick::PageType::NAVIGATION)
|
263
263
|
child = create(:page, slug: 'child-slug', parent: page)
|
264
|
-
expect(child.
|
264
|
+
expect(child.path).to eq('/child-slug')
|
265
265
|
end
|
266
266
|
end
|
267
267
|
|
268
268
|
context 'when it is a redirect? page' do
|
269
269
|
it 'returns the absolute url' do
|
270
|
-
|
271
|
-
|
270
|
+
I18n.with_locale(:en) do
|
271
|
+
page = create(:page, page_type: Qbrick::PageType::REDIRECT, redirect_url: 'en/references', slug: 'news')
|
272
|
+
expect(page.link).to eq('/en/news')
|
273
|
+
end
|
272
274
|
end
|
273
275
|
end
|
274
276
|
|
275
277
|
context 'when url part is empty' do
|
276
278
|
it 'strips the trailing slash' do
|
277
|
-
|
278
|
-
|
279
|
+
I18n.with_locale(:en) do
|
280
|
+
page = create(:page, page_type: Qbrick::PageType::NAVIGATION)
|
281
|
+
expect(page.link).to eq('/en')
|
282
|
+
end
|
279
283
|
end
|
280
284
|
end
|
281
285
|
end
|
@@ -324,14 +328,14 @@ describe Qbrick::Page, type: :model do
|
|
324
328
|
|
325
329
|
describe '#translated?' do
|
326
330
|
it 'returns true when page is translated' do
|
327
|
-
|
328
|
-
expect(
|
331
|
+
page = create(:page, title: 'Page 1', slug: 'page1')
|
332
|
+
expect(page.translated?).to be_truthy
|
329
333
|
end
|
330
334
|
|
331
335
|
it 'returns false when page has no translation' do
|
332
|
-
|
336
|
+
page = I18n.with_locale(:en) { create :page, title: 'Page 1', slug: 'page1' }
|
333
337
|
I18n.with_locale :de do
|
334
|
-
expect(
|
338
|
+
expect(page.translated?).to be_falsey
|
335
339
|
end
|
336
340
|
end
|
337
341
|
end
|
@@ -361,46 +365,24 @@ describe Qbrick::Page, type: :model do
|
|
361
365
|
end
|
362
366
|
|
363
367
|
describe '#before_validation' do
|
364
|
-
it 'generates
|
368
|
+
it 'generates path automatically' do
|
365
369
|
page = Qbrick::Page.new slug: 'slug'
|
366
|
-
expect(page.
|
370
|
+
expect(page.path).to be_nil
|
367
371
|
page.valid?
|
368
|
-
expect(page.
|
372
|
+
expect(page.path).to be_present
|
369
373
|
end
|
370
374
|
end
|
371
375
|
|
372
|
-
describe '#
|
373
|
-
|
374
|
-
it 'updates the child pages url if parent is changed to navigation' do
|
375
|
-
@parent_page = FactoryGirl.create(:page, slug: 'le_parent')
|
376
|
-
@child_page = FactoryGirl.create(:page, slug: 'le_child', parent: @parent_page)
|
377
|
-
|
378
|
-
@parent_page.update_attributes(page_type: Qbrick::PageType::NAVIGATION)
|
379
|
-
expect(@child_page.reload.url).to eq("#{I18n.locale}/le_child")
|
380
|
-
end
|
381
|
-
|
382
|
-
it 'updates the child pages url if parent is changed to content' do
|
383
|
-
@parent_page = FactoryGirl.create(:page, slug: 'le_parent', page_type: Qbrick::PageType::NAVIGATION)
|
384
|
-
@child_page = FactoryGirl.create(:page, slug: 'le_child', parent: @parent_page)
|
385
|
-
|
386
|
-
@parent_page.update_attributes(page_type: Qbrick::PageType::CONTENT)
|
387
|
-
expect(@child_page.reload.url).to eq("#{I18n.locale}/le_parent/le_child")
|
388
|
-
end
|
389
|
-
end
|
390
|
-
end
|
391
|
-
|
392
|
-
describe '#url_without_locale' do
|
393
|
-
let :page do
|
394
|
-
create(:page, slug: 'page')
|
395
|
-
end
|
376
|
+
describe '#path' do
|
377
|
+
let(:page) { create :page, slug: 'page' }
|
396
378
|
|
397
379
|
context 'without parent' do
|
398
|
-
it 'returns
|
399
|
-
expect(page.
|
380
|
+
it 'returns path with leading /' do
|
381
|
+
expect(page.path).to start_with '/'
|
400
382
|
end
|
401
383
|
|
402
384
|
it 'returns a single slug' do
|
403
|
-
expect(page.
|
385
|
+
expect(page.path).to eq('/page')
|
404
386
|
end
|
405
387
|
end
|
406
388
|
|
@@ -413,12 +395,12 @@ describe Qbrick::Page, type: :model do
|
|
413
395
|
create(:page, slug: 'child', parent: parent)
|
414
396
|
end
|
415
397
|
|
416
|
-
it 'returns
|
417
|
-
expect(child.
|
398
|
+
it 'returns path with leading /' do
|
399
|
+
expect(child.path).to start_with '/'
|
418
400
|
end
|
419
401
|
|
420
402
|
it 'does not concatenate the parent slug' do
|
421
|
-
expect(child.
|
403
|
+
expect(child.path).to eq('/child')
|
422
404
|
end
|
423
405
|
end
|
424
406
|
|
@@ -431,25 +413,29 @@ describe Qbrick::Page, type: :model do
|
|
431
413
|
create(:page, slug: 'child', parent: parent)
|
432
414
|
end
|
433
415
|
|
434
|
-
it 'returns
|
435
|
-
expect(child.
|
416
|
+
it 'returns path with leading /' do
|
417
|
+
expect(child.path).to start_with '/'
|
436
418
|
end
|
437
419
|
|
438
420
|
it 'does not concatenate the parent slug' do
|
439
|
-
expect(child.
|
421
|
+
expect(child.path).to eq('/parent/child')
|
440
422
|
end
|
441
423
|
end
|
442
424
|
end
|
443
425
|
|
444
426
|
describe '#translated' do
|
445
427
|
before :each do
|
446
|
-
|
447
|
-
|
448
|
-
|
428
|
+
I18n.with_locale(:en) do
|
429
|
+
@page_1 = create(:page, title: 'Page 1', slug: 'page1')
|
430
|
+
@page_2 = create(:page, title: 'Page 2', slug: 'page1')
|
431
|
+
@page_3 = create(:page, title: 'Page 3', slug: 'page1')
|
432
|
+
end
|
449
433
|
end
|
450
434
|
|
451
435
|
it 'returns all pages that have a translation' do
|
452
|
-
|
436
|
+
I18n.with_locale(:en) do
|
437
|
+
expect(Qbrick::Page.translated).to eq [@page_1, @page_2, @page_3]
|
438
|
+
end
|
453
439
|
end
|
454
440
|
|
455
441
|
it 'does not return untranslated pages' do
|
@@ -512,4 +498,43 @@ describe Qbrick::Page, type: :model do
|
|
512
498
|
expect(@page.bricks.unscoped.where(locale: :en).count).to eq(3)
|
513
499
|
end
|
514
500
|
end
|
501
|
+
|
502
|
+
describe '#create_path' do
|
503
|
+
context 'when parent was saved' do
|
504
|
+
it 'updates the child pages url if parent is changed to navigation' do
|
505
|
+
parent_page = create :page, slug: 'le_parent'
|
506
|
+
child_page = create :page, slug: 'le_child', parent: parent_page
|
507
|
+
parent_page.save
|
508
|
+
expect(child_page.reload.path).to eq '/le_parent/le_child'
|
509
|
+
|
510
|
+
parent_page.update_attributes page_type: Qbrick::PageType::NAVIGATION
|
511
|
+
expect(child_page.reload.path).to eq '/le_child'
|
512
|
+
end
|
513
|
+
|
514
|
+
it 'updates the child pages url if parent is changed to content' do
|
515
|
+
parent_page = create(:page, slug: 'le_parent', page_type: Qbrick::PageType::NAVIGATION)
|
516
|
+
child_page = create(:page, slug: 'le_child', parent: parent_page)
|
517
|
+
|
518
|
+
parent_page.update_attributes(page_type: Qbrick::PageType::CONTENT)
|
519
|
+
expect(child_page.reload.path).to eq '/le_parent/le_child'
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
it 'creates a root path' do
|
524
|
+
root_page = Qbrick::Page.new slug: 'ruth', page_type: Qbrick::PageType::NAVIGATION
|
525
|
+
expect(root_page.create_path).to eq ''
|
526
|
+
end
|
527
|
+
|
528
|
+
it 'creates a content page path' do
|
529
|
+
content_page = Qbrick::Page.new slug: 'meersaeuli', page_type: Qbrick::PageType::CONTENT
|
530
|
+
expect(content_page.create_path).to eq '/meersaeuli'
|
531
|
+
end
|
532
|
+
|
533
|
+
it 'creates a path with children' do
|
534
|
+
parent = create :page, slug: 'le_parent'
|
535
|
+
child_page = Qbrick::Page.new slug: 'le_child', parent: parent
|
536
|
+
|
537
|
+
expect(child_page.create_path).to eq '/le_parent/le_child'
|
538
|
+
end
|
539
|
+
end
|
515
540
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -72,7 +72,7 @@ RSpec.configure do |config|
|
|
72
72
|
# config.mock_with :rr
|
73
73
|
|
74
74
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
75
|
-
config.fixture_path =
|
75
|
+
config.fixture_path = ::Rails.root.join('spec/fixtures').to_s
|
76
76
|
|
77
77
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
78
78
|
# examples within a transaction, remove the following line or assign false
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
include SitemapsHelper
|
3
3
|
|
4
|
-
describe 'qbrick/sitemaps/index.xml.haml', :
|
4
|
+
describe 'qbrick/sitemaps/index.xml.haml', type: :view do
|
5
5
|
describe 'structure' do
|
6
|
+
let(:page) { create :page }
|
7
|
+
|
6
8
|
before :each do
|
7
|
-
@
|
8
|
-
@pages = [@page]
|
9
|
+
@pages = [page]
|
9
10
|
render
|
10
11
|
end
|
11
12
|
|
@@ -18,11 +19,11 @@ describe 'qbrick/sitemaps/index.xml.haml', :type => :view do
|
|
18
19
|
end
|
19
20
|
|
20
21
|
it 'includes the loc tag content' do
|
21
|
-
expect(rendered).to include "<loc>http://#{@request.host}
|
22
|
+
expect(rendered).to include "<loc>http://#{@request.host}#{page.path_with_prefixed_locale}</loc>"
|
22
23
|
end
|
23
24
|
|
24
25
|
it 'includes the lastmod tag content' do
|
25
|
-
expect(rendered).to include "<lastmod>#{
|
26
|
+
expect(rendered).to include "<lastmod>#{page.created_at.utc}</lastmod>"
|
26
27
|
end
|
27
28
|
|
28
29
|
it 'includes the changefreq tag content' do
|
@@ -39,7 +40,7 @@ describe 'qbrick/sitemaps/index.xml.haml', :type => :view do
|
|
39
40
|
allow(I18n).to receive(:available_locales).and_return([:de, :en])
|
40
41
|
|
41
42
|
I18n.with_locale(:de) do
|
42
|
-
@page = create(:page, title: 'Dummy Page 1 DE')
|
43
|
+
@page = create(:page, title: 'Dummy Page 1 DE', published_de: 1, published_en: 1)
|
43
44
|
@page_de = create(:page, title: 'German Page')
|
44
45
|
end
|
45
46
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qbrick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Immanuel Häussermann
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-
|
15
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rspec-rails
|
@@ -745,6 +745,7 @@ files:
|
|
745
745
|
- db/migrate/23_add_metadata_to_asset.rb
|
746
746
|
- db/migrate/23_devise_create_qbrick_admins.rb
|
747
747
|
- db/migrate/24_localize_publish_column.rb
|
748
|
+
- db/migrate/25_rename_qbrick_pages_url_to_path.rb
|
748
749
|
- db/seeds.rb
|
749
750
|
- lib/generators/qbrick/assets/install_generator.rb
|
750
751
|
- lib/generators/qbrick/custom_model_generator.rb
|
@@ -885,7 +886,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
885
886
|
version: '0'
|
886
887
|
requirements: []
|
887
888
|
rubyforge_project: qbrick
|
888
|
-
rubygems_version: 2.
|
889
|
+
rubygems_version: 2.4.5
|
889
890
|
signing_key:
|
890
891
|
specification_version: 4
|
891
892
|
summary: A tool that helps you to manage your content within your app.
|