qbrick 2.6.4 → 2.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/qbrick/page.rb +21 -0
- data/config/locales/models/qbrick/page/de.yml +7 -0
- data/config/locales/models/qbrick/page/en.yml +6 -0
- data/lib/qbrick/version.rb +1 -1
- data/spec/helpers/qbrick/cms/pages_helper_spec.rb +4 -5
- data/spec/models/page_spec.rb +13 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5670c7eb3b792219eaffc87f89487412df39450d
|
4
|
+
data.tar.gz: 61888a9f1c21b859e4d8b523cd5b048b2f0be56e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8007150311018f10e62926597f05c6e06eaa51fcf461a8547272a8487371c1468826b5c1db7ef9ad12e8f1e0fdedf97a920a3d117eb04ba6172b9c9dda0bb07e
|
7
|
+
data.tar.gz: d8cddcf1416dfeb3edb283fe8f7c49c66cd95adb43e69d40790e9b520d95516591418fb5a9099c14c6b77ad034817ea03abfc4ee810f80ee504cf2608d01f543
|
data/app/models/qbrick/page.rb
CHANGED
@@ -34,6 +34,7 @@ module Qbrick
|
|
34
34
|
validates :redirect_url, presence: true, if: :redirect?
|
35
35
|
validates :title, :slug, :keywords, :page_type, length: { maximum: 255 }
|
36
36
|
validates :identifier, uniqueness: true, allow_blank: true
|
37
|
+
validate :slug_uniqueness
|
37
38
|
|
38
39
|
class << self
|
39
40
|
def flat_tree
|
@@ -66,6 +67,26 @@ module Qbrick
|
|
66
67
|
end
|
67
68
|
end # class methods
|
68
69
|
|
70
|
+
def slug_uniqueness
|
71
|
+
path_field = locale_attr :path
|
72
|
+
slug_field = locale_attr :slug
|
73
|
+
[slug_field, path_field].each do |field|
|
74
|
+
self.class.validators_on(field).map { |v| v.validate self }
|
75
|
+
return true if errors[field].present?
|
76
|
+
end
|
77
|
+
|
78
|
+
page_with_duplicated_paths = self.class.where path_field => path
|
79
|
+
page_with_duplicated_paths = page_with_duplicated_paths.where.not id: id if persisted?
|
80
|
+
return true unless page_with_duplicated_paths.exists?
|
81
|
+
|
82
|
+
message = 'page ids: '
|
83
|
+
page_with_duplicated_paths.pluck(:id).each do |id|
|
84
|
+
message << "<a href=\"#{edit_cms_page_path id}#page-metadata\" target=\"_blank\">#{id}</a> "
|
85
|
+
end
|
86
|
+
message = I18n.t 'activerecord.errors.models.qbrick/page.attributes.slug.duplicated_slug', append: " (#{message.strip})"
|
87
|
+
errors.add :slug, message.html_safe
|
88
|
+
end
|
89
|
+
|
69
90
|
def without_self
|
70
91
|
self.class.where.not id: id
|
71
92
|
end
|
@@ -17,3 +17,10 @@ de:
|
|
17
17
|
page_type: 'Seitentyp'
|
18
18
|
parent_id: 'Übergeordnete Seite'
|
19
19
|
parent: 'Übergeordnete Seite'
|
20
|
+
google_verification_key: 'Google Verification Key'
|
21
|
+
errors:
|
22
|
+
models:
|
23
|
+
qbrick/page:
|
24
|
+
attributes:
|
25
|
+
slug:
|
26
|
+
duplicated_slug: 'Der Slug ist leider schon vergeben%{append}'
|
data/lib/qbrick/version.rb
CHANGED
@@ -38,14 +38,13 @@ describe Qbrick::Cms::PagesHelper, type: :helper do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'has a redirect page' do
|
41
|
-
|
42
|
-
|
43
|
-
expect(helper.hide_content_tab?(@page)).to be_truthy
|
41
|
+
page = create :page, title: 'Redirect', page_type: Qbrick::PageType::REDIRECT, redirect_url: 'en/foo'
|
42
|
+
expect(helper.hide_content_tab?(page)).to be_truthy
|
44
43
|
end
|
45
44
|
|
46
45
|
it 'has a not saved page' do
|
47
|
-
|
48
|
-
expect(helper.hide_content_tab?(
|
46
|
+
page = Qbrick::Page.new
|
47
|
+
expect(helper.hide_content_tab?(page)).to be_truthy
|
49
48
|
end
|
50
49
|
end
|
51
50
|
end
|
data/spec/models/page_spec.rb
CHANGED
@@ -376,6 +376,14 @@ describe Qbrick::Page, type: :model do
|
|
376
376
|
describe '#path' do
|
377
377
|
let(:page) { create :page, slug: 'page' }
|
378
378
|
|
379
|
+
it "doesn't allow duplicated paths" do
|
380
|
+
expect(page).to be_valid
|
381
|
+
duplicated_slug_page = build :page, slug: 'page'
|
382
|
+
expect(page.slug).to eq duplicated_slug_page.slug
|
383
|
+
expect(duplicated_slug_page).to be_invalid
|
384
|
+
expect(duplicated_slug_page.errors[:slug]).to be_present
|
385
|
+
end
|
386
|
+
|
379
387
|
context 'without parent' do
|
380
388
|
it 'returns path with leading /' do
|
381
389
|
expect(page.path).to start_with '/'
|
@@ -421,14 +429,14 @@ describe Qbrick::Page, type: :model do
|
|
421
429
|
expect(child.path).to eq('/parent/child')
|
422
430
|
end
|
423
431
|
end
|
424
|
-
end
|
432
|
+
end # path
|
425
433
|
|
426
434
|
describe '#translated' do
|
427
435
|
before :each do
|
428
436
|
I18n.with_locale(:en) do
|
429
|
-
@page_1 = create(:page, title: 'Page 1'
|
430
|
-
@page_2 = create(:page, title: 'Page 2'
|
431
|
-
@page_3 = create(:page, title: 'Page 3'
|
437
|
+
@page_1 = create(:page, title: 'Page 1')
|
438
|
+
@page_2 = create(:page, title: 'Page 2')
|
439
|
+
@page_3 = create(:page, title: 'Page 3')
|
432
440
|
end
|
433
441
|
end
|
434
442
|
|
@@ -456,7 +464,7 @@ describe Qbrick::Page, type: :model do
|
|
456
464
|
it 'should be findable via scope' do
|
457
465
|
expect(Qbrick::Page.by_identifier(cat_page.identifier)).to eq(cat_page)
|
458
466
|
end
|
459
|
-
end
|
467
|
+
end # translated
|
460
468
|
|
461
469
|
describe '#cloning' do
|
462
470
|
around(:each) do |example|
|
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.5
|
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-06-
|
15
|
+
date: 2015-06-26 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rspec-rails
|