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.
- checksums.yaml +4 -4
- data/README.md +207 -130
- data/app/assets/javascripts/kuhsaft/cms/application.js.coffee.erb +14 -12
- data/app/controllers/kuhsaft/cms/admin_controller.rb +1 -1
- data/app/controllers/kuhsaft/pages_controller.rb +1 -0
- data/app/helpers/kuhsaft/cms/admin_helper.rb +51 -0
- data/app/helpers/kuhsaft/cms/pages_helper.rb +1 -1
- data/app/helpers/pages_helper.rb +4 -0
- data/app/models/kuhsaft/page.rb +6 -1
- data/app/models/kuhsaft/page_type.rb +2 -1
- data/app/views/shoestrap/base/_form.html.haml +9 -0
- data/config/routes.rb +1 -1
- data/lib/kuhsaft/version.rb +1 -1
- data/spec/controllers/kuhsaft/api/pages_controller_spec.rb +1 -1
- data/spec/controllers/kuhsaft/pages_controller_spec.rb +4 -4
- data/spec/controllers/kuhsaft/sitemaps_controller_spec.rb +1 -1
- data/spec/features/cms_pages_spec.rb +5 -5
- data/spec/features/search_spec.rb +10 -10
- data/spec/helpers/kuhsaft/cms/admin_helper_spec.rb +5 -5
- data/spec/helpers/kuhsaft/cms/pages_helper_spec.rb +4 -4
- data/spec/helpers/kuhsaft/pages_helper_spec.rb +4 -4
- data/spec/kuhsaft_spec.rb +1 -1
- data/spec/lib/brick_list_spec.rb +9 -7
- data/spec/lib/engine_spec.rb +2 -2
- data/spec/lib/gridded_spec.rb +2 -2
- data/spec/lib/image_uploader_mounting_spec.rb +1 -1
- data/spec/lib/page_tree_spec.rb +2 -2
- data/spec/lib/searchable_spec.rb +1 -1
- data/spec/lib/translatable_spec.rb +16 -16
- data/spec/models/accordion_brick_spec.rb +6 -6
- data/spec/models/accordion_item_brick_spec.rb +7 -7
- data/spec/models/anchor_brick_spec.rb +4 -4
- data/spec/models/asset_brick_spec.rb +7 -7
- data/spec/models/asset_spec.rb +6 -6
- data/spec/models/brick_spec.rb +22 -22
- data/spec/models/brick_type_filter_spec.rb +12 -12
- data/spec/models/column_brick_spec.rb +5 -5
- data/spec/models/image_brick_spec.rb +8 -8
- data/spec/models/image_size_spec.rb +5 -5
- data/spec/models/link_brick_spec.rb +8 -8
- data/spec/models/page_spec.rb +50 -50
- data/spec/models/placeholder_brick_spec.rb +6 -6
- data/spec/models/publish_state_spec.rb +4 -4
- data/spec/models/slider_brick_spec.rb +4 -4
- data/spec/models/text_brick_spec.rb +4 -4
- data/spec/models/two_column_brick_spec.rb +13 -13
- data/spec/models/video_brick_spec.rb +4 -4
- data/spec/support/write_expectation.rb +2 -2
- data/spec/views/kuhsaft/sitemaps/index.xml.haml_spec.rb +3 -3
- metadata +13 -26
data/app/models/kuhsaft/page.rb
CHANGED
@@ -54,6 +54,11 @@ module Kuhsaft
|
|
54
54
|
def by_identifier(identifier)
|
55
55
|
where(identifier: identifier).first
|
56
56
|
end
|
57
|
+
|
58
|
+
def all_urls
|
59
|
+
url_columns = column_names.select { |col| col.start_with? 'url_' }
|
60
|
+
pluck(url_columns).flatten.compact.sort.uniq.map { |r| "/#{r}" }
|
61
|
+
end
|
57
62
|
end
|
58
63
|
|
59
64
|
def without_self
|
@@ -69,7 +74,7 @@ module Kuhsaft
|
|
69
74
|
end
|
70
75
|
|
71
76
|
def redirect?
|
72
|
-
page_type == Kuhsaft::PageType::REDIRECT
|
77
|
+
page_type == Kuhsaft::PageType::REDIRECT || page_type == Kuhsaft::PageType::CUSTOM
|
73
78
|
end
|
74
79
|
|
75
80
|
def navigation?
|
data/config/routes.rb
CHANGED
data/lib/kuhsaft/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::PagesController do
|
3
|
+
describe Kuhsaft::PagesController, type: :controller do
|
4
4
|
subject { described_class }
|
5
5
|
|
6
6
|
describe '#index' do
|
@@ -16,7 +16,7 @@ describe Kuhsaft::PagesController do
|
|
16
16
|
I18n.with_locale :de do
|
17
17
|
get(:index, use_route: :kuhsaft, search: 'foobar')
|
18
18
|
end
|
19
|
-
assigns(:pages).
|
19
|
+
expect(assigns(:pages)).to eq([@pages.first])
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -33,7 +33,7 @@ describe Kuhsaft::PagesController do
|
|
33
33
|
I18n.with_locale(:de) do
|
34
34
|
get(:show, use_route: :kuhsaft)
|
35
35
|
end
|
36
|
-
assigns(:page).
|
36
|
+
expect(assigns(:page)).to eq(@page)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -59,7 +59,7 @@ describe Kuhsaft::PagesController do
|
|
59
59
|
page = FactoryGirl.create(:page, slug: 'dumdidum',
|
60
60
|
url: 'de/dumdidum')
|
61
61
|
get :show, url: page.slug, use_route: :kuhsaft
|
62
|
-
assigns(:page).
|
62
|
+
expect(assigns(:page)).to eq(page)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe 'Cms/Pages' do
|
5
|
+
describe 'Cms/Pages', type: :feature do
|
6
6
|
|
7
7
|
context '#new' do
|
8
8
|
before do
|
@@ -19,7 +19,7 @@ describe 'Cms/Pages' do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'is not possible to change the value in url' do
|
22
|
-
page.find('#page_url')['disabled'].
|
22
|
+
expect(page.find('#page_url')['disabled']).to be_truthy
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -32,7 +32,7 @@ describe 'Cms/Pages' do
|
|
32
32
|
within '.nav-pills' do
|
33
33
|
click_on 'EN'
|
34
34
|
end
|
35
|
-
page.
|
35
|
+
expect(page).to have_content(@page.title_en)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -52,7 +52,7 @@ describe 'Cms/Pages' do
|
|
52
52
|
|
53
53
|
it 'is invalid when no value is in redirect_page' do
|
54
54
|
click_on 'Update Page'
|
55
|
-
page.
|
55
|
+
expect(page).to have_css('.error', count: 1)
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'does not change the value in url' do
|
@@ -70,7 +70,7 @@ describe 'Cms/Pages' do
|
|
70
70
|
invalid_brick.save(validate: false)
|
71
71
|
|
72
72
|
visit kuhsaft.edit_cms_page_path(@page)
|
73
|
-
page.
|
73
|
+
expect(page).to have_css('.error', count: 1)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'pages#index' do
|
3
|
+
describe 'pages#index', type: :feature do
|
4
4
|
context 'with search parameter' do
|
5
5
|
let! :page1 do
|
6
6
|
p = create :page,
|
@@ -31,12 +31,12 @@ describe 'pages#index' do
|
|
31
31
|
|
32
32
|
it 'highlights search term in preview' do
|
33
33
|
within('ul.search-results.success') do
|
34
|
-
page.
|
34
|
+
expect(page).to have_content('Chromodorididae')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'truncates the text' do
|
39
|
-
find('.summary .excerpt').text.length.
|
39
|
+
expect(find('.summary .excerpt').text.length).to eq(110)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -46,21 +46,21 @@ describe 'pages#index' do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'renders match count' do
|
49
|
-
page.
|
49
|
+
expect(page).to have_content('2 results')
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'renders the search results list' do
|
53
53
|
within('ul.search-results.success') do
|
54
|
-
page.
|
55
|
-
page.
|
56
|
-
page.
|
54
|
+
expect(page).to have_content('Chromodorididae Ardeadoris')
|
55
|
+
expect(page).to have_content('Chromodorididae Berlanguella')
|
56
|
+
expect(page).not_to have_content('Gastropoda')
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'renders links to the pages' do
|
61
61
|
within('ul.search-results.success') do
|
62
|
-
page.
|
63
|
-
page.
|
62
|
+
expect(page).to have_link('Chromodorididae Ardeadoris', href: page1.link)
|
63
|
+
expect(page).to have_link('Chromodorididae Berlanguella', href: page2.link)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -71,7 +71,7 @@ describe 'pages#index' do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'renders match count' do
|
74
|
-
page.
|
74
|
+
expect(page).to have_content('No results')
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::Cms::AdminHelper do
|
3
|
+
describe Kuhsaft::Cms::AdminHelper, type: :helper do
|
4
4
|
describe '#render_language_switch?' do
|
5
5
|
context 'when there is one language' do
|
6
6
|
before do
|
7
|
-
I18n.
|
7
|
+
allow(I18n).to receive(:available_locales).and_return([:de])
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'returns false' do
|
11
|
-
helper.render_language_switch
|
11
|
+
expect(helper.render_language_switch?).to be_falsey
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'when there are multiple languages' do
|
16
16
|
before do
|
17
|
-
I18n.
|
17
|
+
allow(I18n).to receive(:available_locales).and_return([:de, :en])
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'returns true' do
|
21
|
-
helper.render_language_switch
|
21
|
+
expect(helper.render_language_switch?).to be_truthy
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::Cms::PagesHelper do
|
3
|
+
describe Kuhsaft::Cms::PagesHelper, type: :helper do
|
4
4
|
describe '#content_tab_active' do
|
5
5
|
it 'returns active when page has a title and no errors' do
|
6
6
|
@page = create(:page, title: 'Page 1', slug: 'page1')
|
@@ -28,19 +28,19 @@ describe Kuhsaft::Cms::PagesHelper do
|
|
28
28
|
it 'has a page without translations' do
|
29
29
|
@page = create(:page, title: 'Page 1', slug: 'page1')
|
30
30
|
I18n.with_locale :de do
|
31
|
-
expect(helper.hide_content_tab?(@page)).to
|
31
|
+
expect(helper.hide_content_tab?(@page)).to be_truthy
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'has a redirect page' do
|
36
36
|
@page = create(:page, title: 'Page 1', slug: 'page1',
|
37
37
|
page_type: Kuhsaft::PageType::REDIRECT, redirect_url: 'en/references')
|
38
|
-
expect(helper.hide_content_tab?(@page)).to
|
38
|
+
expect(helper.hide_content_tab?(@page)).to be_truthy
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'has a not saved page' do
|
42
42
|
@page = Kuhsaft::Page.new
|
43
|
-
expect(helper.hide_content_tab?(@page)).to
|
43
|
+
expect(helper.hide_content_tab?(@page)).to be_truthy
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe PagesHelper do
|
3
|
+
describe PagesHelper, type: :helper do
|
4
4
|
describe '#search_page_form' do
|
5
5
|
|
6
6
|
context 'without block' do
|
7
7
|
it 'renders the default search form' do
|
8
8
|
form = search_page_form
|
9
|
-
form.
|
10
|
-
form.
|
11
|
-
form.
|
9
|
+
expect(form).to have_css('form.form-inline')
|
10
|
+
expect(form).to have_css('input[type=text]')
|
11
|
+
expect(form).to have_css('input[type=submit]')
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
data/spec/kuhsaft_spec.rb
CHANGED
data/spec/lib/brick_list_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'rspec/active_model/mocks'
|
2
3
|
|
3
4
|
describe Kuhsaft::BrickList do
|
4
5
|
|
@@ -13,21 +14,22 @@ describe Kuhsaft::BrickList do
|
|
13
14
|
describe '#collect_fulltext' do
|
14
15
|
context 'with bricks' do
|
15
16
|
it 'collects its childs fulltext' do
|
16
|
-
|
17
|
-
brick.
|
17
|
+
result = [mock_model(Kuhsaft::Brick, collect_fulltext: 'hallo')]
|
18
|
+
allow(brick).to receive_message_chain(:bricks, :localized).and_return(result)
|
19
|
+
expect(brick.collect_fulltext).to eq('hallo')
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
23
|
context 'with bricks without content' do
|
22
24
|
it 'returns a string' do
|
23
|
-
brick.
|
24
|
-
brick.collect_fulltext.
|
25
|
+
allow(brick).to receive_message_chain(:bricks, :localized).and_return([])
|
26
|
+
expect(brick.collect_fulltext).to eq('')
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
context 'without bricks' do
|
29
31
|
it 'returns a string' do
|
30
|
-
brick.collect_fulltext.
|
32
|
+
expect(brick.collect_fulltext).to eq('')
|
31
33
|
end
|
32
34
|
|
33
35
|
it 'does not fail' do
|
@@ -38,13 +40,13 @@ describe Kuhsaft::BrickList do
|
|
38
40
|
|
39
41
|
describe '#allowed_brick_types' do
|
40
42
|
it 'returns an array of possible classes as strings' do
|
41
|
-
brick.allowed_brick_types.
|
43
|
+
expect(brick.allowed_brick_types).to be_a(Array)
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
47
|
describe '#brick_types' do
|
46
48
|
it 'returns a Kuhsaft::BrickTypeFilter' do
|
47
|
-
brick.brick_types.
|
49
|
+
expect(brick.brick_types).to be_a(Kuhsaft::BrickTypeFilter)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
data/spec/lib/engine_spec.rb
CHANGED
@@ -6,14 +6,14 @@ describe Kuhsaft::Engine do
|
|
6
6
|
|
7
7
|
describe '.image_sizes' do
|
8
8
|
it 'delegates .clear to ImageSize' do
|
9
|
-
Kuhsaft::ImageSize.
|
9
|
+
expect(Kuhsaft::ImageSize).to receive(:clear!)
|
10
10
|
Kuhsaft::Engine.configure do
|
11
11
|
config.image_sizes.clear!
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'delegates .add to ImageSize' do
|
16
|
-
Kuhsaft::ImageSize.
|
16
|
+
expect(Kuhsaft::ImageSize).to receive(:add).with(:something, 100, 200)
|
17
17
|
Kuhsaft::Engine.configure do
|
18
18
|
config.image_sizes.add(:something, 100, 200)
|
19
19
|
end
|
data/spec/lib/gridded_spec.rb
CHANGED
@@ -13,12 +13,12 @@ describe Kuhsaft::Gridded do
|
|
13
13
|
|
14
14
|
it 'returns false on gridded? if no col count is set' do
|
15
15
|
expect_any_instance_of(GridClass).to receive(:col_count).at_least(:once).and_return(0)
|
16
|
-
expect(GridClass.new.gridded?).to
|
16
|
+
expect(GridClass.new.gridded?).to be_falsey
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'returns true on gridded? if a col count is set' do
|
20
20
|
expect_any_instance_of(GridClass).to receive(:col_count).at_least(:once).and_return(10)
|
21
|
-
expect(GridClass.new.gridded?).to
|
21
|
+
expect(GridClass.new.gridded?).to be_truthy
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -8,7 +8,7 @@ describe Kuhsaft::ImageUploaderMounting do
|
|
8
8
|
|
9
9
|
describe '#uploader_mounting' do
|
10
10
|
it 'has a uploader mounted' do
|
11
|
-
brick.class.ancestors.include?(CarrierWave::Mount::Extension).
|
11
|
+
expect(brick.class.ancestors.include?(CarrierWave::Mount::Extension)).to be_truthy
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/spec/lib/page_tree_spec.rb
CHANGED
@@ -29,9 +29,9 @@ module Kuhsaft
|
|
29
29
|
|
30
30
|
it 'sets the correct parent attribute for the nodes' do
|
31
31
|
PageTree.update(page_tree)
|
32
|
-
@page1.reload.parent_id.
|
32
|
+
expect(@page1.reload.parent_id).to be_nil
|
33
33
|
expect(@page2.reload.parent_id).to eq(1)
|
34
|
-
@page3.reload.parent_id.
|
34
|
+
expect(@page3.reload.parent_id).to be nil
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/spec/lib/searchable_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe Kuhsaft::Searchable do
|
|
20
20
|
context 'without postgresql' do
|
21
21
|
it 'initializes scope' do
|
22
22
|
expect(ActiveRecord::Base.connection.instance_values).not_to eq('postgresql')
|
23
|
-
SearchableDemo.
|
23
|
+
expect(SearchableDemo).to receive :scope
|
24
24
|
SearchableDemo.class_eval do
|
25
25
|
include Kuhsaft::Searchable
|
26
26
|
end
|
@@ -40,23 +40,23 @@ describe Kuhsaft::Translatable do
|
|
40
40
|
|
41
41
|
describe 'translated attributes' do
|
42
42
|
it 'delegates the getter to the suffixed attribute' do
|
43
|
-
model.
|
44
|
-
model.name.
|
43
|
+
expect(model).to receive(:name_en).and_return('John')
|
44
|
+
expect(model.name).to eq('John')
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'delegates the setter to the suffixed attribute' do
|
48
|
-
model.
|
48
|
+
expect(model).to receive(:name_en=).with('Johnny')
|
49
49
|
model.name = 'Johnny'
|
50
50
|
end
|
51
51
|
|
52
52
|
context 'dynamic methods' do
|
53
53
|
it 'delegates boolean accessors' do
|
54
|
-
model.
|
54
|
+
expect(model).to receive(:name_en?)
|
55
55
|
model.name?
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'delegates simple dynamic finders' do
|
59
|
-
Demo.
|
59
|
+
expect(Demo).to receive(:find_by_name_en).with('Max')
|
60
60
|
Demo.find_by_name('Max')
|
61
61
|
end
|
62
62
|
end
|
@@ -67,12 +67,12 @@ describe Kuhsaft::Translatable do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'delegates the getter to current locale' do
|
70
|
-
model.
|
71
|
-
model.name.
|
70
|
+
expect(model).to receive(:name_de).and_return('Johannes')
|
71
|
+
expect(model.name).to eq('Johannes')
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'delegates the getter to current locale' do
|
75
|
-
model.
|
75
|
+
expect(model).to receive(:name_de=).with('Johannes')
|
76
76
|
model.name = 'Johannes'
|
77
77
|
end
|
78
78
|
end
|
@@ -114,23 +114,23 @@ describe Kuhsaft::Translatable do
|
|
114
114
|
|
115
115
|
describe 'translated attributes' do
|
116
116
|
it 'delegates the getter to the suffixed attribute' do
|
117
|
-
model.
|
118
|
-
model.name.
|
117
|
+
expect(model).to receive(:name_de_ch).and_return('John')
|
118
|
+
expect(model.name).to eq('John')
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'delegates the setter to the suffixed attribute' do
|
122
|
-
model.
|
122
|
+
expect(model).to receive(:name_de_ch=).with('Johnny')
|
123
123
|
model.name = 'Johnny'
|
124
124
|
end
|
125
125
|
|
126
126
|
context 'dynamic methods' do
|
127
127
|
it 'delegates boolean accessors' do
|
128
|
-
model.
|
128
|
+
expect(model).to receive(:name_de_ch?)
|
129
129
|
model.name?
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'delegates simple dynamic finders' do
|
133
|
-
Demo.
|
133
|
+
expect(Demo).to receive(:find_by_name_de_ch).with('Max')
|
134
134
|
Demo.find_by_name('Max')
|
135
135
|
end
|
136
136
|
end
|
@@ -141,12 +141,12 @@ describe Kuhsaft::Translatable do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'delegates the getter to current locale' do
|
144
|
-
model.
|
145
|
-
model.name.
|
144
|
+
expect(model).to receive(:name_de).and_return('Johannes')
|
145
|
+
expect(model.name).to eq('Johannes')
|
146
146
|
end
|
147
147
|
|
148
148
|
it 'delegates the getter to current locale' do
|
149
|
-
model.
|
149
|
+
expect(model).to receive(:name_de=).with('Johannes')
|
150
150
|
model.name = 'Johannes'
|
151
151
|
end
|
152
152
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::AccordionBrick do
|
3
|
+
describe Kuhsaft::AccordionBrick, type: :model do
|
4
4
|
|
5
5
|
let :accordion_brick do
|
6
6
|
Kuhsaft::AccordionBrick.new
|
@@ -8,31 +8,31 @@ describe Kuhsaft::AccordionBrick do
|
|
8
8
|
|
9
9
|
describe '#user_can_delete?' do
|
10
10
|
it 'returns true' do
|
11
|
-
accordion_brick.user_can_delete
|
11
|
+
expect(accordion_brick.user_can_delete?).to be_truthy
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#renders_own_childs?' do
|
16
16
|
it 'returns false' do
|
17
|
-
accordion_brick.renders_own_childs
|
17
|
+
expect(accordion_brick.renders_own_childs?).to be_falsey
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#bricks' do
|
22
22
|
it 'can have childs' do
|
23
|
-
accordion_brick.
|
23
|
+
expect(accordion_brick).to respond_to(:bricks)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#to_style_class' do
|
28
28
|
it 'includes the bootstrap classname' do
|
29
|
-
accordion_brick.to_style_class.
|
29
|
+
expect(accordion_brick.to_style_class).to eq('kuhsaft-accordion-brick accordion')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe '#allowed_brick_types' do
|
34
34
|
it 'only allows AccordionItems' do
|
35
|
-
accordion_brick.allowed_brick_types.
|
35
|
+
expect(accordion_brick.allowed_brick_types).to eq(%w(Kuhsaft::AccordionItemBrick))
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::AccordionItemBrick do
|
3
|
+
describe Kuhsaft::AccordionItemBrick, type: :model do
|
4
4
|
|
5
5
|
let :accordion_item_brick do
|
6
6
|
Kuhsaft::AccordionItemBrick.new
|
@@ -13,38 +13,38 @@ describe Kuhsaft::AccordionItemBrick do
|
|
13
13
|
|
14
14
|
context 'without a #caption' do
|
15
15
|
it 'has en error' do
|
16
|
-
accordion_item_brick.
|
16
|
+
expect(accordion_item_brick.errors[:caption].count).to eq(1)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#user_can_delete?' do
|
22
22
|
it 'returns true' do
|
23
|
-
accordion_item_brick.user_can_delete
|
23
|
+
expect(accordion_item_brick.user_can_delete?).to be_truthy
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#user_can_save' do
|
28
28
|
it 'returns true' do
|
29
|
-
accordion_item_brick.user_can_save
|
29
|
+
expect(accordion_item_brick.user_can_save?).to eq(true)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe '#renders_own_childs?' do
|
34
34
|
it 'returns false' do
|
35
|
-
accordion_item_brick.renders_own_childs
|
35
|
+
expect(accordion_item_brick.renders_own_childs?).to be_falsey
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '#bricks' do
|
40
40
|
it 'can have childs' do
|
41
|
-
accordion_item_brick.
|
41
|
+
expect(accordion_item_brick).to respond_to(:bricks)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe '#to_style_class' do
|
46
46
|
it 'includes the bootstrap classname' do
|
47
|
-
accordion_item_brick.to_style_class.
|
47
|
+
expect(accordion_item_brick.to_style_class).to eq('kuhsaft-accordion-item-brick accordion-group')
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::AnchorBrick do
|
3
|
+
describe Kuhsaft::AnchorBrick, type: :model do
|
4
4
|
|
5
5
|
let :anchor_brick do
|
6
6
|
Kuhsaft::AnchorBrick.new(caption: 'test-anchor')
|
@@ -8,19 +8,19 @@ describe Kuhsaft::AnchorBrick do
|
|
8
8
|
|
9
9
|
describe '#bricks' do
|
10
10
|
it 'can not have childs' do
|
11
|
-
anchor_brick.
|
11
|
+
expect(anchor_brick).not_to respond_to(:bricks)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#user_can_add_childs?' do
|
16
16
|
it 'returns false' do
|
17
|
-
anchor_brick.user_can_add_childs
|
17
|
+
expect(anchor_brick.user_can_add_childs?).to be_falsey
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#to_id' do
|
22
22
|
it 'returns a parameterized id' do
|
23
|
-
anchor_brick.to_id.
|
23
|
+
expect(anchor_brick.to_id).to eq('anchor-test-anchor')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|