kuhsaft 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/Rakefile +18 -3
- data/app/models/kuhsaft/brick.rb +2 -0
- data/app/models/kuhsaft/page.rb +5 -0
- data/app/models/kuhsaft/placeholder_brick.rb +2 -0
- data/db/migrate/20140327141200_add_identifier_to_kuhsaft_pages.rb +6 -0
- data/lib/kuhsaft.rb +1 -0
- data/lib/kuhsaft/touch_placeholders.rb +32 -0
- data/lib/kuhsaft/version.rb +1 -1
- data/spec/factories.rb +5 -0
- data/spec/lib/touch_placeholders_spec.rb +44 -0
- data/spec/models/page_spec.rb +17 -5
- data/spec/spec_helper.rb +1 -1
- metadata +12 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c60f8ceefd0183f0e24eee551f4560d802969351
|
4
|
+
data.tar.gz: bc32915f907f3630621dea9ca3283d5961f0fdb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5196609fd60806c055d1501f725d3347e5f875da67f952d3a4b249739cea4c80c82ba72665bd7a81e68c085ab1124b9d3eb0ace015cd9335aa609909480cb37c
|
7
|
+
data.tar.gz: a226eaf1a6674895c40d81655b82df983c174618cbc15693b5b7f5873e3cb84e7dcbc24c158180e471d74b44754f7529572cf1fb27a89a2b296871ac95f40e9e
|
data/README.md
CHANGED
@@ -193,6 +193,18 @@ de:
|
|
193
193
|
your_partial: Your Partial
|
194
194
|
```
|
195
195
|
|
196
|
+
## Invalidating placeholder bricks containing other models on model changes
|
197
|
+
|
198
|
+
Include the TouchPlaceholders module if your model is used within a
|
199
|
+
placeholder brick and define which templates it appears in:
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
class Dummy < ActiveRecord::Base
|
203
|
+
include Kuhsaft::TouchPlaceholders
|
204
|
+
placeholder_templates 'some_template', 'some_other_template'
|
205
|
+
end
|
206
|
+
```
|
207
|
+
|
196
208
|
## Adding additional content languages
|
197
209
|
|
198
210
|
If you want to translate your pages into another language, generate a new translation migration:
|
data/Rakefile
CHANGED
@@ -32,6 +32,13 @@ module Postgres
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def within_dummy_app
|
36
|
+
Dir.chdir('spec/dummy') do
|
37
|
+
ENV['BUNDLE_GEMFILE'] = File.join File.dirname(__FILE__), 'Gemfile'
|
38
|
+
yield
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
35
42
|
desc 'Run specs'
|
36
43
|
RSpec::Core::RakeTask.new(spec: :setup)
|
37
44
|
|
@@ -46,7 +53,7 @@ end
|
|
46
53
|
desc 'set up the dummy app for testing'
|
47
54
|
task :setup do
|
48
55
|
Postgres.create_user 'screenconcept'
|
49
|
-
|
56
|
+
within_dummy_app do
|
50
57
|
`bundle exec rake kuhsaft:install:migrations`
|
51
58
|
`bundle exec rails generate kuhsaft:install:assets`
|
52
59
|
`bundle exec rake db:create`
|
@@ -60,8 +67,16 @@ task default: [:spec]
|
|
60
67
|
|
61
68
|
desc 'start the dummy app'
|
62
69
|
task :start_dummy do
|
63
|
-
|
64
|
-
ENV['BUNDLE_GEMFILE'] = '../../Gemfile'
|
70
|
+
within_dummy_app do
|
65
71
|
`bundle exec rails server`
|
66
72
|
end
|
67
73
|
end
|
74
|
+
|
75
|
+
namespace :dummy_db do
|
76
|
+
desc 'migrate in dummy app'
|
77
|
+
task :migrate do
|
78
|
+
within_dummy_app do
|
79
|
+
`bundle exec rake db:migrate 2>&1`
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/app/models/kuhsaft/brick.rb
CHANGED
data/app/models/kuhsaft/page.rb
CHANGED
@@ -31,6 +31,7 @@ module Kuhsaft
|
|
31
31
|
validates :slug, presence: true
|
32
32
|
validates :redirect_url, presence: true, if: :redirect?
|
33
33
|
validates :title, :slug, :keywords, :page_type, length: { maximum: 255 }
|
34
|
+
validates :identifier, uniqueness: true, allow_blank: true
|
34
35
|
|
35
36
|
class << self
|
36
37
|
def flat_tree(pages = nil)
|
@@ -48,6 +49,10 @@ module Kuhsaft
|
|
48
49
|
|
49
50
|
arr
|
50
51
|
end
|
52
|
+
|
53
|
+
def by_identifier(identifier)
|
54
|
+
where(identifier: identifier).first
|
55
|
+
end
|
51
56
|
end
|
52
57
|
|
53
58
|
def without_self
|
data/lib/kuhsaft.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative '../../app/models/kuhsaft/placeholder_brick'
|
2
|
+
|
3
|
+
module Kuhsaft
|
4
|
+
module TouchPlaceholders
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
|
8
|
+
base.class_eval do
|
9
|
+
after_save :touch_placeholders
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def touch_placeholders
|
14
|
+
if self.class.placeholder_templates.present?
|
15
|
+
self.class.placeholder_templates.each do |template_name|
|
16
|
+
related_templates = Kuhsaft::PlaceholderBrick.where(template_name: template_name)
|
17
|
+
related_templates.each { |p| p.touch } if related_templates
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module ClassMethods
|
23
|
+
def placeholder_templates(*attributes)
|
24
|
+
if attributes.empty?
|
25
|
+
@shoestrap_placeholder_templates
|
26
|
+
else
|
27
|
+
@shoestrap_placeholder_templates = attributes
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/kuhsaft/version.rb
CHANGED
data/spec/factories.rb
CHANGED
@@ -15,6 +15,11 @@ FactoryGirl.define do
|
|
15
15
|
tb.text 'DummyText'
|
16
16
|
end
|
17
17
|
|
18
|
+
factory :placeholder_brick, class: 'Kuhsaft::PlaceholderBrick' do |tb|
|
19
|
+
tb.type 'Kuhsaft::PlaceholderBrick'
|
20
|
+
tb.template_name 'foo'
|
21
|
+
end
|
22
|
+
|
18
23
|
factory :asset, class: Kuhsaft::Asset do |a|
|
19
24
|
a.file File.open("#{Kuhsaft::Engine.root}/spec/dummy/app/assets/images/spec-image.png")
|
20
25
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/kuhsaft/touch_placeholders'
|
3
|
+
|
4
|
+
describe Kuhsaft::TouchPlaceholders do
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
m = ActiveRecord::Migration.new
|
8
|
+
m.verbose = false
|
9
|
+
m.create_table :dummy_models do |t|
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
class DummyModel < ActiveRecord::Base
|
14
|
+
include Kuhsaft::TouchPlaceholders
|
15
|
+
end
|
16
|
+
|
17
|
+
@page = FactoryGirl.create(:page)
|
18
|
+
@placeholder = FactoryGirl.create(:placeholder_brick, brick_list: @page, template_name: 'foo')
|
19
|
+
end
|
20
|
+
|
21
|
+
after :all do
|
22
|
+
m = ActiveRecord::Migration.new
|
23
|
+
m.verbose = false
|
24
|
+
m.drop_table :dummy_models
|
25
|
+
|
26
|
+
@page.destroy
|
27
|
+
@placeholder.destroy
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'placeholder_templates class method' do
|
31
|
+
it 'returns the attribute names defined with class macro' do
|
32
|
+
DummyModel.class_eval { placeholder_templates 'key_benefit_slider', 'key_benefit_grid' }
|
33
|
+
expect(DummyModel.placeholder_templates).to eq %w(key_benefit_slider key_benefit_grid)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'after_save_callback' do
|
38
|
+
it 'looks for the bricks with affected templates and touches them' do
|
39
|
+
DummyModel.class_eval { placeholder_templates 'foo' }
|
40
|
+
expect_any_instance_of(Kuhsaft::PlaceholderBrick).to receive(:touch)
|
41
|
+
DummyModel.create
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/spec/models/page_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Kuhsaft::Page do
|
4
|
-
subject { described_class }
|
4
|
+
# subject { described_class }
|
5
5
|
|
6
6
|
describe '.search' do
|
7
7
|
before do
|
@@ -336,10 +336,10 @@ describe Kuhsaft::Page do
|
|
336
336
|
|
337
337
|
describe '#fulltext' do
|
338
338
|
let :page do
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
339
|
+
create(:page, keywords: 'key words', description: 'descrip tion', title: 'my title').tap do |p|
|
340
|
+
p.bricks << Kuhsaft::TextBrick.new(locale: I18n.locale, text: 'oh la la')
|
341
|
+
p.save
|
342
|
+
end
|
343
343
|
end
|
344
344
|
|
345
345
|
context 'when saved' do
|
@@ -437,4 +437,16 @@ describe Kuhsaft::Page do
|
|
437
437
|
end
|
438
438
|
end
|
439
439
|
end
|
440
|
+
|
441
|
+
describe '#identifier' do
|
442
|
+
let(:cat_page) { create :page, identifier: 'cat_content' }
|
443
|
+
|
444
|
+
it 'should check for uniqueness' do
|
445
|
+
expect(build(:page, identifier: cat_page.identifier)).to be_invalid
|
446
|
+
end
|
447
|
+
|
448
|
+
it 'should be findable via scope' do
|
449
|
+
expect(Kuhsaft::Page.by_identifier(cat_page.identifier)).to eq(cat_page)
|
450
|
+
end
|
451
|
+
end
|
440
452
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuhsaft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.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: 2014-
|
15
|
+
date: 2014-04-01 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rspec
|
@@ -32,16 +32,16 @@ dependencies:
|
|
32
32
|
name: rspec-rails
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 2.14.2
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ~>
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
44
|
+
version: 2.14.2
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: factory_girl_rails
|
47
47
|
requirement: !ruby/object:Gem::Requirement
|
@@ -398,14 +398,14 @@ dependencies:
|
|
398
398
|
requirements:
|
399
399
|
- - ~>
|
400
400
|
- !ruby/object:Gem::Version
|
401
|
-
version: 4.0.
|
401
|
+
version: 4.0.2
|
402
402
|
type: :runtime
|
403
403
|
prerelease: false
|
404
404
|
version_requirements: !ruby/object:Gem::Requirement
|
405
405
|
requirements:
|
406
406
|
- - ~>
|
407
407
|
- !ruby/object:Gem::Version
|
408
|
-
version: 4.0.
|
408
|
+
version: 4.0.2
|
409
409
|
- !ruby/object:Gem::Dependency
|
410
410
|
name: rails
|
411
411
|
requirement: !ruby/object:Gem::Requirement
|
@@ -627,6 +627,7 @@ files:
|
|
627
627
|
- db/migrate/15_add_alt_text_to_bricks.rb
|
628
628
|
- db/migrate/16_update_default_value_for_page_type.rb
|
629
629
|
- db/migrate/17_set_page_type_to_content_for_empty_fields.rb
|
630
|
+
- db/migrate/20140327141200_add_identifier_to_kuhsaft_pages.rb
|
630
631
|
- db/seeds.rb
|
631
632
|
- lib/generators/kuhsaft/assets/install_generator.rb
|
632
633
|
- lib/generators/kuhsaft/translations/add_generator.rb
|
@@ -637,6 +638,7 @@ files:
|
|
637
638
|
- lib/kuhsaft/page_tree.rb
|
638
639
|
- lib/kuhsaft/partial_extractor.rb
|
639
640
|
- lib/kuhsaft/searchable.rb
|
641
|
+
- lib/kuhsaft/touch_placeholders.rb
|
640
642
|
- lib/kuhsaft/translatable.rb
|
641
643
|
- lib/kuhsaft/version.rb
|
642
644
|
- lib/kuhsaft.rb
|
@@ -704,6 +706,7 @@ files:
|
|
704
706
|
- spec/lib/image_uploader_mounting_spec.rb
|
705
707
|
- spec/lib/page_tree_spec.rb
|
706
708
|
- spec/lib/searchable_spec.rb
|
709
|
+
- spec/lib/touch_placeholders_spec.rb
|
707
710
|
- spec/lib/translatable_spec.rb
|
708
711
|
- spec/models/accordion_brick_spec.rb
|
709
712
|
- spec/models/accordion_item_brick_spec.rb
|
@@ -807,6 +810,7 @@ test_files:
|
|
807
810
|
- spec/lib/image_uploader_mounting_spec.rb
|
808
811
|
- spec/lib/page_tree_spec.rb
|
809
812
|
- spec/lib/searchable_spec.rb
|
813
|
+
- spec/lib/touch_placeholders_spec.rb
|
810
814
|
- spec/lib/translatable_spec.rb
|
811
815
|
- spec/models/accordion_brick_spec.rb
|
812
816
|
- spec/models/accordion_item_brick_spec.rb
|