kuhsaft 2.4.3 → 2.5.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +207 -130
  3. data/app/assets/javascripts/kuhsaft/cms/application.js.coffee.erb +14 -12
  4. data/app/controllers/kuhsaft/cms/admin_controller.rb +1 -1
  5. data/app/controllers/kuhsaft/pages_controller.rb +1 -0
  6. data/app/helpers/kuhsaft/cms/admin_helper.rb +51 -0
  7. data/app/helpers/kuhsaft/cms/pages_helper.rb +1 -1
  8. data/app/helpers/pages_helper.rb +4 -0
  9. data/app/models/kuhsaft/page.rb +6 -1
  10. data/app/models/kuhsaft/page_type.rb +2 -1
  11. data/app/views/shoestrap/base/_form.html.haml +9 -0
  12. data/config/routes.rb +1 -1
  13. data/lib/kuhsaft/version.rb +1 -1
  14. data/spec/controllers/kuhsaft/api/pages_controller_spec.rb +1 -1
  15. data/spec/controllers/kuhsaft/pages_controller_spec.rb +4 -4
  16. data/spec/controllers/kuhsaft/sitemaps_controller_spec.rb +1 -1
  17. data/spec/features/cms_pages_spec.rb +5 -5
  18. data/spec/features/search_spec.rb +10 -10
  19. data/spec/helpers/kuhsaft/cms/admin_helper_spec.rb +5 -5
  20. data/spec/helpers/kuhsaft/cms/pages_helper_spec.rb +4 -4
  21. data/spec/helpers/kuhsaft/pages_helper_spec.rb +4 -4
  22. data/spec/kuhsaft_spec.rb +1 -1
  23. data/spec/lib/brick_list_spec.rb +9 -7
  24. data/spec/lib/engine_spec.rb +2 -2
  25. data/spec/lib/gridded_spec.rb +2 -2
  26. data/spec/lib/image_uploader_mounting_spec.rb +1 -1
  27. data/spec/lib/page_tree_spec.rb +2 -2
  28. data/spec/lib/searchable_spec.rb +1 -1
  29. data/spec/lib/translatable_spec.rb +16 -16
  30. data/spec/models/accordion_brick_spec.rb +6 -6
  31. data/spec/models/accordion_item_brick_spec.rb +7 -7
  32. data/spec/models/anchor_brick_spec.rb +4 -4
  33. data/spec/models/asset_brick_spec.rb +7 -7
  34. data/spec/models/asset_spec.rb +6 -6
  35. data/spec/models/brick_spec.rb +22 -22
  36. data/spec/models/brick_type_filter_spec.rb +12 -12
  37. data/spec/models/column_brick_spec.rb +5 -5
  38. data/spec/models/image_brick_spec.rb +8 -8
  39. data/spec/models/image_size_spec.rb +5 -5
  40. data/spec/models/link_brick_spec.rb +8 -8
  41. data/spec/models/page_spec.rb +50 -50
  42. data/spec/models/placeholder_brick_spec.rb +6 -6
  43. data/spec/models/publish_state_spec.rb +4 -4
  44. data/spec/models/slider_brick_spec.rb +4 -4
  45. data/spec/models/text_brick_spec.rb +4 -4
  46. data/spec/models/two_column_brick_spec.rb +13 -13
  47. data/spec/models/video_brick_spec.rb +4 -4
  48. data/spec/support/write_expectation.rb +2 -2
  49. data/spec/views/kuhsaft/sitemaps/index.xml.haml_spec.rb +3 -3
  50. metadata +13 -26
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::AssetBrick do
3
+ describe Kuhsaft::AssetBrick, type: :model do
4
4
 
5
5
  let :asset_brick do
6
6
  Kuhsaft::AssetBrick.new
@@ -13,33 +13,33 @@ describe Kuhsaft::AssetBrick do
13
13
 
14
14
  context 'without a #caption' do
15
15
  it 'has an error' do
16
- asset_brick.should have(1).error_on(:caption)
16
+ expect(asset_brick.errors[:caption].count).to eq(1)
17
17
  end
18
18
  end
19
19
  end
20
20
 
21
21
  describe '#bricks' do
22
22
  it 'can not have childs' do
23
- asset_brick.should_not respond_to(:bricks)
23
+ expect(asset_brick).not_to respond_to(:bricks)
24
24
  end
25
25
  end
26
26
 
27
27
  describe '.styles' do
28
28
  it 'returns the available link styles' do
29
- Kuhsaft::AssetBrick.styles.should == %w(pdf word excel button)
29
+ expect(Kuhsaft::AssetBrick.styles).to eq(%w(pdf word excel button))
30
30
  end
31
31
  end
32
32
 
33
33
  describe '#to_style_class' do
34
34
  it 'includes the link style' do
35
- asset_brick.stub(:link_style).and_return('pdf')
36
- asset_brick.to_style_class.should == 'kuhsaft-asset-brick pdf'
35
+ allow(asset_brick).to receive(:link_style).and_return('pdf')
36
+ expect(asset_brick.to_style_class).to eq('kuhsaft-asset-brick pdf')
37
37
  end
38
38
  end
39
39
 
40
40
  describe '#user_can_add_childs?' do
41
41
  it 'returns false' do
42
- asset_brick.user_can_add_childs?.should be_false
42
+ expect(asset_brick.user_can_add_childs?).to be_falsey
43
43
  end
44
44
  end
45
45
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::Asset do
3
+ describe Kuhsaft::Asset, type: :model do
4
4
 
5
5
  let :asset do
6
6
  create(:asset)
@@ -8,7 +8,7 @@ describe Kuhsaft::Asset do
8
8
 
9
9
  let :uploader do
10
10
  u = Kuhsaft::AssetUploader.new(asset, :file)
11
- u.store!(File.open(File.join(Kuhsaft::Engine.root, 'spec', 'dummy', 'app', 'assets', 'images', 'spec-image.png')))
11
+ u.store! File.open(Kuhsaft::Engine.root.join('spec/dummy/app/assets/images/spec-image.png'))
12
12
  u
13
13
  end
14
14
 
@@ -21,21 +21,21 @@ describe Kuhsaft::Asset do
21
21
  end
22
22
 
23
23
  it 'has a thumbnail' do
24
- uploader.should respond_to(:thumb)
24
+ expect(uploader).to respond_to(:thumb)
25
25
  end
26
26
 
27
27
  it 'makes the image readable only to the owner and not executable' do
28
28
  pending 'how and where do we ensure permissions?'
29
- uploader.should have_permissions(0600)
29
+ expect(uploader).to have_permissions(0600)
30
30
  end
31
31
 
32
32
  describe '#file_type' do
33
33
  it 'has a file_type' do
34
- asset.should respond_to(:file_type)
34
+ expect(asset).to respond_to(:file_type)
35
35
  end
36
36
 
37
37
  it 'is symbolized' do
38
- asset.file_type.should be_a(Symbol)
38
+ expect(asset.file_type).to be_a(Symbol)
39
39
  end
40
40
  end
41
41
  end
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::Brick do
3
+ describe Kuhsaft::Brick, type: :model do
4
4
  let :brick do
5
5
  Kuhsaft::Brick.new
6
6
  end
7
7
 
8
8
  describe '#valid?' do
9
9
  it 'sets a default position' do
10
- brick.should_receive(:set_position)
10
+ expect(brick).to receive(:set_position)
11
11
  brick.valid?
12
12
  end
13
13
  end
@@ -16,7 +16,7 @@ describe Kuhsaft::Brick do
16
16
  context 'witout a position' do
17
17
  it 'sets a default' do
18
18
  brick.set_position
19
- brick.position.should be(1)
19
+ expect(brick.position).to be(1)
20
20
  end
21
21
  end
22
22
 
@@ -30,70 +30,70 @@ describe Kuhsaft::Brick do
30
30
 
31
31
  describe '#brick_list_type' do
32
32
  it 'returns Kuhsaft::Brick' do
33
- brick.brick_list_type.should == 'Kuhsaft::Brick'
33
+ expect(brick.brick_list_type).to eq('Kuhsaft::Brick')
34
34
  end
35
35
  end
36
36
 
37
37
  describe '#parents' do
38
38
  it 'returns the chain of parents' do
39
39
  item1, item2, item3 = double, double, Kuhsaft::Brick.new
40
- item2.stub(:brick_list).and_return(item1)
41
- item3.stub(:brick_list).and_return(item2)
42
- item3.parents.should == [item1, item2]
40
+ allow(item2).to receive(:brick_list).and_return(item1)
41
+ allow(item3).to receive(:brick_list).and_return(item2)
42
+ expect(item3.parents).to eq([item1, item2])
43
43
  end
44
44
  end
45
45
 
46
46
  describe '#to_edit_partial_path' do
47
47
  it 'returns the path to the form partial' do
48
- Kuhsaft::TextBrick.new.to_edit_partial_path.should == 'kuhsaft/text_bricks/text_brick/edit'
48
+ expect(Kuhsaft::TextBrick.new.to_edit_partial_path).to eq('kuhsaft/text_bricks/text_brick/edit')
49
49
  end
50
50
  end
51
51
 
52
52
  describe '#has_siblings?' do
53
53
  it 'returns false if the brick has no siblings' do
54
54
  brick = Kuhsaft::Brick.new
55
- brick.has_siblings?.should be_false
55
+ expect(brick.has_siblings?).to be_falsey
56
56
  end
57
57
 
58
58
  it 'returns true if the brick has siblings' do
59
59
  item1, item2, item3 = double, double, Kuhsaft::Brick.new
60
- item1.stub(:bricks).and_return([item2, item3])
61
- item2.stub(:brick_list).and_return(item1)
62
- item3.stub(:brick_list).and_return(item1)
63
- item3.has_siblings?.should be_true
60
+ allow(item1).to receive(:bricks).and_return([item2, item3])
61
+ allow(item2).to receive(:brick_list).and_return(item1)
62
+ allow(item3).to receive(:brick_list).and_return(item1)
63
+ expect(item3.has_siblings?).to be_truthy
64
64
  end
65
65
  end
66
66
 
67
67
  describe '#to_edit_childs_partial_path' do
68
68
  it 'returns the path to the form partial' do
69
- Kuhsaft::TextBrick.new.to_edit_childs_partial_path.should == 'kuhsaft/text_bricks/text_brick/childs'
69
+ expect(Kuhsaft::TextBrick.new.to_edit_childs_partial_path).to eq('kuhsaft/text_bricks/text_brick/childs')
70
70
  end
71
71
  end
72
72
 
73
73
  describe '#bricks' do
74
74
  it 'can not have childs by default' do
75
- brick.should_not respond_to(:bricks)
75
+ expect(brick).not_to respond_to(:bricks)
76
76
  end
77
77
  end
78
78
 
79
79
  describe '#to_style_class' do
80
80
  it 'returns a css classname' do
81
- Kuhsaft::TextBrick.new.to_style_class.should == 'kuhsaft-text-brick'
81
+ expect(Kuhsaft::TextBrick.new.to_style_class).to eq('kuhsaft-text-brick')
82
82
  end
83
83
  end
84
84
 
85
85
  describe '#to_style_id' do
86
86
  it 'returns a unique DOM id' do
87
87
  brick = Kuhsaft::TextBrick.new
88
- brick.stub(:id).and_return(104)
89
- brick.to_style_id.should == 'kuhsaft-text-brick-104'
88
+ allow(brick).to receive(:id).and_return(104)
89
+ expect(brick.to_style_id).to eq('kuhsaft-text-brick-104')
90
90
  end
91
91
  end
92
92
 
93
93
  describe '#backend_label' do
94
94
  it 'returns the name of the brick' do
95
95
  brick = Kuhsaft::TextBrick.new
96
- brick.backend_label.should == 'Text'
96
+ expect(brick.backend_label).to eq('Text')
97
97
  end
98
98
 
99
99
  context 'with the parenthesis option given' do
@@ -104,7 +104,7 @@ describe Kuhsaft::Brick do
104
104
 
105
105
  describe '#uploader?' do
106
106
  it 'returns false' do
107
- brick.uploader?.should be_false
107
+ expect(brick.uploader?).to be_falsey
108
108
  end
109
109
  end
110
110
 
@@ -124,8 +124,8 @@ describe Kuhsaft::Brick do
124
124
  end
125
125
 
126
126
  it 'updates fulltext on bricklist after saving a single brick' do
127
- brick.brick_list.should_receive(:update_fulltext)
128
- brick.brick_list.should_receive(:save!)
127
+ expect(brick.brick_list).to receive(:update_fulltext)
128
+ expect(brick.brick_list).to receive(:save!)
129
129
  brick.text = 'foobar'
130
130
  brick.save
131
131
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::BrickTypeFilter do
3
+ describe Kuhsaft::BrickTypeFilter, type: :model do
4
4
  let :brick_list do
5
5
  Kuhsaft::Page.new
6
6
  end
@@ -12,21 +12,21 @@ describe Kuhsaft::BrickTypeFilter do
12
12
  describe '#empty?' do
13
13
  context 'when the user cant add childs' do
14
14
  before do
15
- brick_list.stub(:user_can_add_childs?).and_return(false)
15
+ allow(brick_list).to receive(:user_can_add_childs?).and_return(false)
16
16
  end
17
17
 
18
18
  it 'returns true' do
19
- brick_type_filter.empty?.should be_true
19
+ expect(brick_type_filter.empty?).to be_truthy
20
20
  end
21
21
  end
22
22
 
23
23
  context 'when there are no bricks to be added' do
24
24
  before do
25
- brick_type_filter.stub(:allowed).and_return([])
25
+ allow(brick_type_filter).to receive(:allowed).and_return([])
26
26
  end
27
27
 
28
28
  it 'returns true' do
29
- brick_type_filter.empty?.should be_true
29
+ expect(brick_type_filter.empty?).to be_truthy
30
30
  end
31
31
  end
32
32
  end
@@ -34,28 +34,28 @@ describe Kuhsaft::BrickTypeFilter do
34
34
  describe '#allowed' do
35
35
  context 'when no brick types are registered' do
36
36
  it 'returns an empty array' do
37
- Kuhsaft::BrickType.stub_chain(:count, :zero?).and_return(true)
38
- brick_type_filter.allowed.should be_empty
37
+ allow(Kuhsaft::BrickType).to receive_message_chain(:count, :zero?).and_return(true)
38
+ expect(brick_type_filter.allowed).to be_empty
39
39
  end
40
40
  end
41
41
 
42
42
  context 'when brick types are registered' do
43
43
  before do
44
- Kuhsaft::BrickType.stub_chain(:enabled, :count, :zero?).and_return(false)
44
+ allow(Kuhsaft::BrickType).to receive_message_chain(:enabled, :count, :zero?).and_return(false)
45
45
  end
46
46
 
47
47
  context 'when there are no constraints' do
48
48
  it 'returns all enabled brick types' do
49
- brick_list.stub(:allowed_brick_types).and_return([])
50
- Kuhsaft::BrickType.should_receive(:enabled)
49
+ allow(brick_list).to receive(:allowed_brick_types).and_return([])
50
+ expect(Kuhsaft::BrickType).to receive(:enabled)
51
51
  brick_type_filter.allowed
52
52
  end
53
53
  end
54
54
 
55
55
  context 'when there are constraints' do
56
56
  it 'constrains the enabled types' do
57
- brick_list.stub(:allowed_brick_types).and_return(['Kuhsaft::TextBrick'])
58
- Kuhsaft::BrickType.enabled.should_receive(:constrained).with(['Kuhsaft::TextBrick'])
57
+ allow(brick_list).to receive(:allowed_brick_types).and_return(['Kuhsaft::TextBrick'])
58
+ expect(Kuhsaft::BrickType.enabled).to receive(:constrained).with(['Kuhsaft::TextBrick'])
59
59
  brick_type_filter.allowed
60
60
  end
61
61
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::ColumnBrick do
3
+ describe Kuhsaft::ColumnBrick, type: :model do
4
4
 
5
5
  let :column_brick do
6
6
  Kuhsaft::ColumnBrick.new
@@ -8,25 +8,25 @@ describe Kuhsaft::ColumnBrick do
8
8
 
9
9
  describe '#user_can_delete?' do
10
10
  it 'returns false' do
11
- column_brick.user_can_delete?.should be_false
11
+ expect(column_brick.user_can_delete?).to be_falsey
12
12
  end
13
13
  end
14
14
 
15
15
  describe '#user_can_save' do
16
16
  it 'returns false' do
17
- column_brick.user_can_save?.should be_false
17
+ expect(column_brick.user_can_save?).to be_falsey
18
18
  end
19
19
  end
20
20
 
21
21
  describe '#renders_own_childs?' do
22
22
  it 'returns false' do
23
- column_brick.renders_own_childs?.should be_false
23
+ expect(column_brick.renders_own_childs?).to be_falsey
24
24
  end
25
25
  end
26
26
 
27
27
  describe '#bricks' do
28
28
  it 'can have childs' do
29
- column_brick.should respond_to(:bricks)
29
+ expect(column_brick).to respond_to(:bricks)
30
30
  end
31
31
  end
32
32
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::ImageBrick do
3
+ describe Kuhsaft::ImageBrick, type: :model do
4
4
 
5
5
  let :image_brick do
6
6
  Kuhsaft::ImageBrick.new
@@ -13,7 +13,7 @@ describe Kuhsaft::ImageBrick do
13
13
 
14
14
  context 'without an #image' do
15
15
  it 'has en error' do
16
- image_brick.should have(1).error_on(:image)
16
+ expect(image_brick.errors[:image].size).to eq(1)
17
17
  end
18
18
  end
19
19
  end
@@ -21,9 +21,9 @@ describe Kuhsaft::ImageBrick do
21
21
  describe '#save' do
22
22
  context 'when changing the image size' do
23
23
  it 'regenerates the image version' do
24
- image_brick.stub(:image_size_changed?).and_return(true)
25
- image_brick.stub(:image_present?).and_return(true)
26
- image_brick.image.should_receive(:recreate_versions!)
24
+ allow(image_brick).to receive(:image_size_changed?).and_return(true)
25
+ allow(image_brick).to receive(:image_present?).and_return(true)
26
+ expect(image_brick.image).to receive(:recreate_versions!)
27
27
  image_brick.resize_image_if_size_changed
28
28
  end
29
29
  end
@@ -31,19 +31,19 @@ describe Kuhsaft::ImageBrick do
31
31
 
32
32
  describe '#bricks' do
33
33
  it 'can not have childs' do
34
- image_brick.should_not respond_to(:bricks)
34
+ expect(image_brick).not_to respond_to(:bricks)
35
35
  end
36
36
  end
37
37
 
38
38
  describe '#user_can_add_childs?' do
39
39
  it 'returns false' do
40
- image_brick.user_can_add_childs?.should be_false
40
+ expect(image_brick.user_can_add_childs?).to be_falsey
41
41
  end
42
42
  end
43
43
 
44
44
  describe '#uploader?' do
45
45
  it 'returns true' do
46
- image_brick.uploader?.should be_true
46
+ expect(image_brick.uploader?).to be_truthy
47
47
  end
48
48
  end
49
49
  end
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::ImageSize do
3
+ describe Kuhsaft::ImageSize, type: :model do
4
4
  before do
5
5
  Kuhsaft::ImageSize.build_defaults!
6
6
  end
7
7
 
8
8
  describe '.build_defaults!' do
9
9
  it 'sets the default sizes' do
10
- Kuhsaft::ImageSize.all.should == [Kuhsaft::ImageSize.gallery_size,
11
- Kuhsaft::ImageSize.teaser_size]
10
+ expect(Kuhsaft::ImageSize.all).to eq([Kuhsaft::ImageSize.gallery_size,
11
+ Kuhsaft::ImageSize.teaser_size])
12
12
  end
13
13
  end
14
14
 
@@ -18,7 +18,7 @@ describe Kuhsaft::ImageSize do
18
18
  end
19
19
 
20
20
  it 'empties the list' do
21
- Kuhsaft::ImageSize.all.should be_empty
21
+ expect(Kuhsaft::ImageSize.all).to be_empty
22
22
  end
23
23
  end
24
24
 
@@ -30,7 +30,7 @@ describe Kuhsaft::ImageSize do
30
30
 
31
31
  describe '.find_by_name' do
32
32
  it 'returns the size' do
33
- Kuhsaft::ImageSize.find_by_name('gallery').should == Kuhsaft::ImageSize.gallery_size
33
+ expect(Kuhsaft::ImageSize.find_by_name('gallery')).to eq(Kuhsaft::ImageSize.gallery_size)
34
34
  end
35
35
  end
36
36
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::LinkBrick do
3
+ describe Kuhsaft::LinkBrick, type: :model do
4
4
 
5
5
  let :link_brick do
6
6
  Kuhsaft::LinkBrick.new
@@ -13,39 +13,39 @@ describe Kuhsaft::LinkBrick do
13
13
 
14
14
  context 'without a #href' do
15
15
  it 'has en error' do
16
- link_brick.should have(1).error_on(:href)
16
+ expect(link_brick.errors[:href].count).to eq(1)
17
17
  end
18
18
  end
19
19
 
20
20
  context 'without a #caption' do
21
21
  it 'has an error' do
22
- link_brick.should have(1).error_on(:caption)
22
+ expect(link_brick.errors[:caption].count).to eq(1)
23
23
  end
24
24
  end
25
25
  end
26
26
 
27
27
  describe '#bricks' do
28
28
  it 'can not have childs' do
29
- link_brick.should_not respond_to(:bricks)
29
+ expect(link_brick).not_to respond_to(:bricks)
30
30
  end
31
31
  end
32
32
 
33
33
  describe '.styles' do
34
34
  it 'returns the available link styles' do
35
- Kuhsaft::LinkBrick.styles.should == %w(pdf word excel button external)
35
+ expect(Kuhsaft::LinkBrick.styles).to eq(%w(pdf word excel button external))
36
36
  end
37
37
  end
38
38
 
39
39
  describe '#to_style_class' do
40
40
  it 'includes the link style' do
41
- link_brick.stub(:link_style).and_return('pdf')
42
- link_brick.to_style_class.should == 'kuhsaft-link-brick pdf'
41
+ allow(link_brick).to receive(:link_style).and_return('pdf')
42
+ expect(link_brick.to_style_class).to eq('kuhsaft-link-brick pdf')
43
43
  end
44
44
  end
45
45
 
46
46
  describe '#user_can_add_childs?' do
47
47
  it 'returns false' do
48
- link_brick.user_can_add_childs?.should be_false
48
+ expect(link_brick.user_can_add_childs?).to be_falsey
49
49
  end
50
50
  end
51
51
  end