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/spec/models/page_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::Page do
|
3
|
+
describe Kuhsaft::Page, type: :model do
|
4
4
|
# subject { described_class }
|
5
5
|
|
6
6
|
describe '.search' do
|
@@ -9,40 +9,40 @@ describe Kuhsaft::Page do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should find any containing the search term' do
|
12
|
-
Kuhsaft::Page.search('lorem').
|
12
|
+
expect(Kuhsaft::Page.search('lorem').size).to be >= 0
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should find with "English Title"' do
|
16
|
-
Kuhsaft::Page.search('English Title').
|
16
|
+
expect(Kuhsaft::Page.search('English Title').size).to be >= 1
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should only find published results' do
|
20
|
-
Kuhsaft::Page.search('English Title').
|
20
|
+
expect(Kuhsaft::Page.search('English Title')).to be_all { |p| p.published? == true }
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should find by using the old api' do
|
24
|
-
Kuhsaft::Page.search('English').
|
24
|
+
expect(Kuhsaft::Page.search('English')).to eq(Kuhsaft::Page.search('English'))
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe '.position_of' do
|
29
29
|
it 'should find the position of a page' do
|
30
30
|
page = create(:page)
|
31
|
-
Kuhsaft::Page.position_of(page.id).
|
31
|
+
expect(Kuhsaft::Page.position_of(page.id)).to eq(page.position)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
describe '.find_by_url' do
|
36
36
|
it 'should find its translated content by url' do
|
37
37
|
page = create(:page)
|
38
|
-
Kuhsaft::Page.find_by_url(page.url).
|
38
|
+
expect(Kuhsaft::Page.find_by_url(page.url)).to eq(page)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
describe '.flat_tree' do
|
43
43
|
it 'should create an ordered, flat list of the page tree' do
|
44
44
|
tree = create_page_tree
|
45
|
-
Kuhsaft::Page.flat_tree.
|
45
|
+
expect(Kuhsaft::Page.flat_tree).to eq(tree)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -57,11 +57,11 @@ describe Kuhsaft::Page do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'has a mandatory title' do
|
60
|
-
page.
|
60
|
+
expect(page.errors[:title].count).to eq(1)
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'has a mandatory slug' do
|
64
|
-
page.
|
64
|
+
expect(page.errors[:slug].count).to eq(1)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -70,7 +70,7 @@ describe Kuhsaft::Page do
|
|
70
70
|
it 'returns only published pages' do
|
71
71
|
_p1, p2, _p3 = 3.times.map { create(:page) }
|
72
72
|
p2.update_attribute :published, Kuhsaft::PublishState::UNPUBLISHED
|
73
|
-
Kuhsaft::Page.published.
|
73
|
+
expect(Kuhsaft::Page.published).to be_all { |p| expect(p.published?).to be_truthy }
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -78,7 +78,7 @@ describe Kuhsaft::Page do
|
|
78
78
|
it 'returns only content pages' do
|
79
79
|
p1, p2, p3 = 3.times.map { create(:page) }
|
80
80
|
p2.update_attribute :page_type, Kuhsaft::PageType::REDIRECT
|
81
|
-
Kuhsaft::Page.content_page.
|
81
|
+
expect(Kuhsaft::Page.content_page).to eq([p1, p3])
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -101,7 +101,7 @@ describe Kuhsaft::Page do
|
|
101
101
|
it 'returns pages but not itself' do
|
102
102
|
2.times { create(:page) }
|
103
103
|
page = Kuhsaft::Page.first
|
104
|
-
page.without_self.
|
104
|
+
expect(page.without_self).not_to include(page)
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -120,19 +120,19 @@ describe Kuhsaft::Page do
|
|
120
120
|
|
121
121
|
context 'on the topmost level' do
|
122
122
|
it 'has a label representing it\'s nesting depth without a leading dash' do
|
123
|
-
page.nesting_name.
|
123
|
+
expect(page.nesting_name).to eq(page.title)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
context 'on the first level' do
|
128
128
|
it 'should have a label with one dash' do
|
129
|
-
child_page.nesting_name.
|
129
|
+
expect(child_page.nesting_name).to eq("- #{child_page.title}")
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
133
|
context 'on the second level' do
|
134
134
|
it 'should have a label with two dashes' do
|
135
|
-
child_child_page.nesting_name.
|
135
|
+
expect(child_child_page.nesting_name).to eq("-- #{child_child_page.title}")
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
@@ -147,11 +147,11 @@ describe Kuhsaft::Page do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'has a list of parent pages' do
|
150
|
-
child_page.parent_pages.
|
150
|
+
expect(child_page.parent_pages).to eq([page])
|
151
151
|
end
|
152
152
|
|
153
153
|
it 'is ordered from top to bottom' do
|
154
|
-
child_page.parent_pages.last.
|
154
|
+
expect(child_page.parent_pages.last).to eq(page)
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
@@ -162,7 +162,7 @@ describe Kuhsaft::Page do
|
|
162
162
|
child = create(:page, parent: page)
|
163
163
|
page.body = nil
|
164
164
|
page.save
|
165
|
-
page.link.
|
165
|
+
expect(page.link).to eq(child.link)
|
166
166
|
end
|
167
167
|
end
|
168
168
|
end
|
@@ -172,7 +172,7 @@ describe Kuhsaft::Page do
|
|
172
172
|
page = create :page
|
173
173
|
position = page.position
|
174
174
|
page.increment_position
|
175
|
-
page.position.
|
175
|
+
expect(page.position).to eq(position + 1)
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
@@ -181,7 +181,7 @@ describe Kuhsaft::Page do
|
|
181
181
|
page = create :page
|
182
182
|
position = page.position
|
183
183
|
page.decrement_position
|
184
|
-
page.position.
|
184
|
+
expect(page.position).to eq(position - 1)
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
@@ -190,7 +190,7 @@ describe Kuhsaft::Page do
|
|
190
190
|
_page1 = create :page
|
191
191
|
page2 = create :page
|
192
192
|
page3 = create :page
|
193
|
-
page3.preceding_sibling.id.
|
193
|
+
expect(page3.preceding_sibling.id).to eq(page2.id)
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
@@ -199,7 +199,7 @@ describe Kuhsaft::Page do
|
|
199
199
|
_page1 = create :page
|
200
200
|
page2 = create :page
|
201
201
|
page3 = create :page
|
202
|
-
page2.succeeding_sibling.id.
|
202
|
+
expect(page2.succeeding_sibling.id).to eq(page3.id)
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
@@ -209,14 +209,14 @@ describe Kuhsaft::Page do
|
|
209
209
|
_page2 = create :page
|
210
210
|
page3 = create :page
|
211
211
|
page3.reposition page1.id
|
212
|
-
page3.preceding_sibling.id.
|
212
|
+
expect(page3.preceding_sibling.id).to eq(page1.id)
|
213
213
|
end
|
214
214
|
|
215
215
|
it 'repositions before all siblings, specified by nil' do
|
216
216
|
_page1 = create :page
|
217
217
|
page2 = create :page
|
218
218
|
page2.reposition nil
|
219
|
-
page2.position.
|
219
|
+
expect(page2.position).to eq(1)
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
@@ -227,12 +227,12 @@ describe Kuhsaft::Page do
|
|
227
227
|
|
228
228
|
it 'has a slug by default' do
|
229
229
|
page.save
|
230
|
-
page.slug.
|
230
|
+
expect(page.slug).to eq(page.title.parameterize)
|
231
231
|
end
|
232
232
|
|
233
233
|
context 'when it is empty' do
|
234
234
|
it 'generates the slug' do
|
235
|
-
page.
|
235
|
+
expect(page).to receive(:create_slug)
|
236
236
|
page.save
|
237
237
|
end
|
238
238
|
end
|
@@ -241,7 +241,7 @@ describe Kuhsaft::Page do
|
|
241
241
|
it 'takes the slug provided by the user' do
|
242
242
|
page.slug = 'my-slug'
|
243
243
|
page.save
|
244
|
-
page.slug.
|
244
|
+
expect(page.slug).to eq('my-slug')
|
245
245
|
end
|
246
246
|
end
|
247
247
|
end
|
@@ -251,7 +251,7 @@ describe Kuhsaft::Page do
|
|
251
251
|
it 'returns the concatenated slug of the whole child/parent tree' do
|
252
252
|
page = create(:page, slug: 'parent-slug')
|
253
253
|
child = create(:page, slug: 'child-slug', parent: page)
|
254
|
-
child.url.
|
254
|
+
expect(child.url).to eq('en/parent-slug/child-slug')
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
@@ -259,21 +259,21 @@ describe Kuhsaft::Page do
|
|
259
259
|
it 'returns without the parent page slug' do
|
260
260
|
page = create(:page, slug: 'parent-slug', page_type: Kuhsaft::PageType::NAVIGATION)
|
261
261
|
child = create(:page, slug: 'child-slug', parent: page)
|
262
|
-
child.url.
|
262
|
+
expect(child.url).to eq('en/child-slug')
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
266
|
context 'when it is a redirect? page' do
|
267
267
|
it 'returns the absolute url' do
|
268
268
|
page = create(:page, page_type: Kuhsaft::PageType::REDIRECT, redirect_url: 'en/references', slug: 'news')
|
269
|
-
page.link.
|
269
|
+
expect(page.link).to eq('/en/news')
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
273
|
context 'when url part is empty' do
|
274
274
|
it 'strips the trailing slash' do
|
275
275
|
page = create(:page, page_type: Kuhsaft::PageType::NAVIGATION)
|
276
|
-
page.link.
|
276
|
+
expect(page.link).to eq('/en')
|
277
277
|
end
|
278
278
|
end
|
279
279
|
end
|
@@ -281,13 +281,13 @@ describe Kuhsaft::Page do
|
|
281
281
|
describe '#navigation?' do
|
282
282
|
context 'when the page_type is navigation' do
|
283
283
|
it 'returns true if the page_type is PageType::NAVIGATION' do
|
284
|
-
Kuhsaft::Page.new(page_type: Kuhsaft::PageType::NAVIGATION).navigation
|
284
|
+
expect(Kuhsaft::Page.new(page_type: Kuhsaft::PageType::NAVIGATION).navigation?).to be_truthy
|
285
285
|
end
|
286
286
|
end
|
287
287
|
|
288
288
|
context 'when the page_type is anything else' do
|
289
289
|
it 'returns false' do
|
290
|
-
Kuhsaft::Page.new(page_type: Kuhsaft::PageType::REDIRECT).navigation
|
290
|
+
expect(Kuhsaft::Page.new(page_type: Kuhsaft::PageType::REDIRECT).navigation?).to be_falsey
|
291
291
|
end
|
292
292
|
end
|
293
293
|
end
|
@@ -295,13 +295,13 @@ describe Kuhsaft::Page do
|
|
295
295
|
describe '#redirect?' do
|
296
296
|
context 'when the page_type is a redirect' do
|
297
297
|
it 'returns true' do
|
298
|
-
Kuhsaft::Page.new(page_type: Kuhsaft::PageType::REDIRECT).redirect
|
298
|
+
expect(Kuhsaft::Page.new(page_type: Kuhsaft::PageType::REDIRECT).redirect?).to be_truthy
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
302
302
|
context 'when the page type is anything else' do
|
303
303
|
it 'returns false' do
|
304
|
-
Kuhsaft::Page.new(page_type: Kuhsaft::PageType::NAVIGATION).redirect
|
304
|
+
expect(Kuhsaft::Page.new(page_type: Kuhsaft::PageType::NAVIGATION).redirect?).to be_falsey
|
305
305
|
end
|
306
306
|
end
|
307
307
|
end
|
@@ -323,13 +323,13 @@ describe Kuhsaft::Page do
|
|
323
323
|
describe '#translated?' do
|
324
324
|
it 'returns true when page is translated' do
|
325
325
|
@page = create(:page, title: 'Page 1', slug: 'page1')
|
326
|
-
expect(@page.translated?).to
|
326
|
+
expect(@page.translated?).to be_truthy
|
327
327
|
end
|
328
328
|
|
329
329
|
it 'returns false when page has no translation' do
|
330
330
|
@page = create(:page, title: 'Page 1', slug: 'page1')
|
331
331
|
I18n.with_locale :de do
|
332
|
-
expect(@page.translated?).to
|
332
|
+
expect(@page.translated?).to be_falsey
|
333
333
|
end
|
334
334
|
end
|
335
335
|
end
|
@@ -344,12 +344,12 @@ describe Kuhsaft::Page do
|
|
344
344
|
|
345
345
|
context 'when saved' do
|
346
346
|
it 'it collects and assigns the fulltext' do
|
347
|
-
page.
|
347
|
+
expect(page).to receive(:collect_fulltext)
|
348
348
|
page.save
|
349
349
|
end
|
350
350
|
|
351
351
|
it 'contains the page part content' do
|
352
|
-
page.fulltext.
|
352
|
+
expect(page.fulltext).to include('oh la la')
|
353
353
|
end
|
354
354
|
|
355
355
|
it 'converts all data to strings' do
|
@@ -361,9 +361,9 @@ describe Kuhsaft::Page do
|
|
361
361
|
describe '#before_validation' do
|
362
362
|
it 'generates url automatically' do
|
363
363
|
page = Kuhsaft::Page.new slug: 'slug'
|
364
|
-
page.url.
|
364
|
+
expect(page.url).to be_nil
|
365
365
|
page.valid?
|
366
|
-
page.url.
|
366
|
+
expect(page.url).to be_present
|
367
367
|
end
|
368
368
|
end
|
369
369
|
|
@@ -374,7 +374,7 @@ describe Kuhsaft::Page do
|
|
374
374
|
@child_page = FactoryGirl.create(:page, slug: 'le_child', parent: @parent_page)
|
375
375
|
|
376
376
|
@parent_page.update_attributes(page_type: Kuhsaft::PageType::NAVIGATION)
|
377
|
-
@child_page.reload.url.
|
377
|
+
expect(@child_page.reload.url).to eq("#{I18n.locale}/le_child")
|
378
378
|
end
|
379
379
|
|
380
380
|
it 'updates the child pages url if parent is changed to content' do
|
@@ -382,7 +382,7 @@ describe Kuhsaft::Page do
|
|
382
382
|
@child_page = FactoryGirl.create(:page, slug: 'le_child', parent: @parent_page)
|
383
383
|
|
384
384
|
@parent_page.update_attributes(page_type: Kuhsaft::PageType::CONTENT)
|
385
|
-
@child_page.reload.url.
|
385
|
+
expect(@child_page.reload.url).to eq("#{I18n.locale}/le_parent/le_child")
|
386
386
|
end
|
387
387
|
end
|
388
388
|
end
|
@@ -394,11 +394,11 @@ describe Kuhsaft::Page do
|
|
394
394
|
|
395
395
|
context 'without parent' do
|
396
396
|
it 'returns url without leading /' do
|
397
|
-
page.url_without_locale.
|
397
|
+
expect(page.url_without_locale).not_to start_with '/'
|
398
398
|
end
|
399
399
|
|
400
400
|
it 'returns a single slug' do
|
401
|
-
page.url_without_locale.
|
401
|
+
expect(page.url_without_locale).to eq('page')
|
402
402
|
end
|
403
403
|
end
|
404
404
|
|
@@ -412,11 +412,11 @@ describe Kuhsaft::Page do
|
|
412
412
|
end
|
413
413
|
|
414
414
|
it 'returns url without leading /' do
|
415
|
-
child.url_without_locale.
|
415
|
+
expect(child.url_without_locale).not_to start_with '/'
|
416
416
|
end
|
417
417
|
|
418
418
|
it 'does not concatenate the parent slug' do
|
419
|
-
child.url_without_locale.
|
419
|
+
expect(child.url_without_locale).to eq('child')
|
420
420
|
end
|
421
421
|
end
|
422
422
|
|
@@ -430,11 +430,11 @@ describe Kuhsaft::Page do
|
|
430
430
|
end
|
431
431
|
|
432
432
|
it 'returns url without leading /' do
|
433
|
-
child.url_without_locale.
|
433
|
+
expect(child.url_without_locale).not_to start_with '/'
|
434
434
|
end
|
435
435
|
|
436
436
|
it 'does not concatenate the parent slug' do
|
437
|
-
child.url_without_locale.
|
437
|
+
expect(child.url_without_locale).to eq('parent/child')
|
438
438
|
end
|
439
439
|
end
|
440
440
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
|
-
describe Kuhsaft::PlaceholderBrick do
|
4
|
+
describe Kuhsaft::PlaceholderBrick, type: :model do
|
5
5
|
|
6
6
|
let :placeholder_brick do
|
7
7
|
Kuhsaft::PlaceholderBrick.new
|
@@ -20,27 +20,27 @@ describe Kuhsaft::PlaceholderBrick do
|
|
20
20
|
|
21
21
|
describe 'available partials' do
|
22
22
|
it 'returns haml files' do
|
23
|
-
Kuhsaft::PlaceholderBrick.available_partials.flatten.
|
23
|
+
expect(Kuhsaft::PlaceholderBrick.available_partials.flatten).to include('valid_partial')
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'returns only partials' do
|
27
|
-
Kuhsaft::PlaceholderBrick.available_partials.flatten.
|
27
|
+
expect(Kuhsaft::PlaceholderBrick.available_partials.flatten).not_to include('not_a_partial')
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'does not return other files' do
|
31
|
-
Kuhsaft::PlaceholderBrick.available_partials.flatten.
|
31
|
+
expect(Kuhsaft::PlaceholderBrick.available_partials.flatten).not_to include('not_a_haml_file')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
describe '#bricks' do
|
36
36
|
it 'can not have childs' do
|
37
|
-
placeholder_brick.
|
37
|
+
expect(placeholder_brick).not_to respond_to(:bricks)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
describe '#user_can_add_childs?' do
|
42
42
|
it 'returns false' do
|
43
|
-
placeholder_brick.user_can_add_childs
|
43
|
+
expect(placeholder_brick.user_can_add_childs?).to be_falsey
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::PublishState do
|
3
|
+
describe Kuhsaft::PublishState, type: :model do
|
4
4
|
context 'unpublished' do
|
5
5
|
before do
|
6
6
|
@publish_state = Kuhsaft::PublishState.new(name: 'unpublished', value: Kuhsaft::PublishState::UNPUBLISHED)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should be UNPUBLISHED' do
|
10
|
-
@publish_state.value.
|
10
|
+
expect(@publish_state.value).to be(Kuhsaft::PublishState::UNPUBLISHED)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -17,7 +17,7 @@ describe Kuhsaft::PublishState do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should be PUBLISHED' do
|
20
|
-
@publish_state.value.
|
20
|
+
expect(@publish_state.value).to be(Kuhsaft::PublishState::PUBLISHED)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -27,7 +27,7 @@ describe Kuhsaft::PublishState do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should be PUBLISHED_AT' do
|
30
|
-
@publish_state.value.
|
30
|
+
expect(@publish_state.value).to be(Kuhsaft::PublishState::PUBLISHED_AT)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::SliderBrick do
|
3
|
+
describe Kuhsaft::SliderBrick, type: :model do
|
4
4
|
|
5
5
|
let :slider_brick do
|
6
6
|
Kuhsaft::SliderBrick.new
|
@@ -8,19 +8,19 @@ describe Kuhsaft::SliderBrick do
|
|
8
8
|
|
9
9
|
describe '#bricks' do
|
10
10
|
it 'can have childs' do
|
11
|
-
slider_brick.
|
11
|
+
expect(slider_brick).to respond_to(:bricks)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#to_style_class' do
|
16
16
|
it 'includes the bootstrap styles' do
|
17
|
-
slider_brick.to_style_class.
|
17
|
+
expect(slider_brick.to_style_class).to eq('kuhsaft-slider-brick carousel slide')
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#allowed_brick_types' do
|
22
22
|
it 'only allows ImageBricks and VideoBricks' do
|
23
|
-
slider_brick.allowed_brick_types.
|
23
|
+
expect(slider_brick.allowed_brick_types).to eq(%w(Kuhsaft::ImageBrick Kuhsaft::VideoBrick))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::TextBrick do
|
3
|
+
describe Kuhsaft::TextBrick, type: :model do
|
4
4
|
let :text_brick do
|
5
5
|
Kuhsaft::TextBrick.new
|
6
6
|
end
|
7
7
|
|
8
8
|
describe '#bricks' do
|
9
9
|
it 'can not have childs' do
|
10
|
-
text_brick.
|
10
|
+
expect(text_brick).not_to respond_to(:bricks)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#user_can_add_childs?' do
|
15
15
|
it 'returns false' do
|
16
|
-
text_brick.user_can_add_childs
|
16
|
+
expect(text_brick.user_can_add_childs?).to be_falsey
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -24,7 +24,7 @@ describe Kuhsaft::TextBrick do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'sanitizes text and read_more_text' do
|
27
|
-
text_brick.collect_fulltext.
|
27
|
+
expect(text_brick.collect_fulltext).to eq('foo bar foobar')
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::TwoColumnBrick do
|
3
|
+
describe Kuhsaft::TwoColumnBrick, type: :model do
|
4
4
|
|
5
5
|
let :two_column_brick do
|
6
6
|
Kuhsaft::TwoColumnBrick.new
|
@@ -8,75 +8,75 @@ describe Kuhsaft::TwoColumnBrick do
|
|
8
8
|
|
9
9
|
describe '#user_can_add_childs?' do
|
10
10
|
it 'returns false' do
|
11
|
-
two_column_brick.user_can_add_childs
|
11
|
+
expect(two_column_brick.user_can_add_childs?).to be_falsey
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#user_can_delete?' do
|
16
16
|
it 'returns true' do
|
17
|
-
two_column_brick.user_can_delete
|
17
|
+
expect(two_column_brick.user_can_delete?).to be_truthy
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#user_can_save?' do
|
22
22
|
it 'returns true' do
|
23
|
-
two_column_brick.user_can_save
|
23
|
+
expect(two_column_brick.user_can_save?).to be_truthy
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#renders_own_childs?' do
|
28
28
|
it 'returns true' do
|
29
|
-
two_column_brick.renders_own_childs
|
29
|
+
expect(two_column_brick.renders_own_childs?).to be_truthy
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe '#partitioning' do
|
34
34
|
context 'when no partition is set' do
|
35
35
|
it 'returns 0 (50/50)' do
|
36
|
-
two_column_brick.partitioning.
|
36
|
+
expect(two_column_brick.partitioning).to be(0)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
context 'when the partition is set' do
|
41
41
|
it 'returns the value' do
|
42
42
|
two_column_brick.partitioning = 1
|
43
|
-
two_column_brick.partitioning.
|
43
|
+
expect(two_column_brick.partitioning).to be(1)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
describe '.partitionings' do
|
49
49
|
it 'returns the 3 default partitions' do
|
50
|
-
Kuhsaft::TwoColumnBrick.partitionings.
|
50
|
+
expect(Kuhsaft::TwoColumnBrick.partitionings.size).to eq(3)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
describe '#create' do
|
55
55
|
it 'creates two single columns as childs' do
|
56
56
|
two_column_brick.save
|
57
|
-
two_column_brick.bricks.
|
57
|
+
expect(two_column_brick.bricks).to be_all { |brick| expect(brick).to be_a(Kuhsaft::ColumnBrick) }
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
describe '#bricks' do
|
62
62
|
it 'can have childs' do
|
63
|
-
two_column_brick.
|
63
|
+
expect(two_column_brick).to respond_to(:bricks)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe '#to_style_class' do
|
68
68
|
it 'adds the row class to the default styles' do
|
69
|
-
Kuhsaft::TwoColumnBrick.new.to_style_class.
|
69
|
+
expect(Kuhsaft::TwoColumnBrick.new.to_style_class).to eq('kuhsaft-two-column-brick row-fluid')
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
describe '#add_columns' do
|
74
74
|
it 'sets the position of the first column brick to 1' do
|
75
|
-
Kuhsaft::TwoColumnBrick.new.send(:add_columns).to_a.first.position.
|
75
|
+
expect(Kuhsaft::TwoColumnBrick.new.send(:add_columns).to_a.first.position).to eq(1)
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'sets the position of the second column brick to 2' do
|
79
|
-
Kuhsaft::TwoColumnBrick.new.send(:add_columns).to_a.second.position.
|
79
|
+
expect(Kuhsaft::TwoColumnBrick.new.send(:add_columns).to_a.second.position).to eq(2)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Kuhsaft::VideoBrick do
|
3
|
+
describe Kuhsaft::VideoBrick, type: :model do
|
4
4
|
|
5
5
|
let :video_brick do
|
6
6
|
Kuhsaft::VideoBrick.new
|
@@ -13,20 +13,20 @@ describe Kuhsaft::VideoBrick do
|
|
13
13
|
|
14
14
|
context 'without any video source' do
|
15
15
|
it 'has en error' do
|
16
|
-
video_brick.
|
16
|
+
expect(video_brick.errors[:any_source].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
|
-
video_brick.
|
23
|
+
expect(video_brick).not_to respond_to(:bricks)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#user_can_add_childs?' do
|
28
28
|
it 'returns false' do
|
29
|
-
video_brick.user_can_add_childs
|
29
|
+
expect(video_brick.user_can_add_childs?).to be_falsey
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -17,11 +17,11 @@ RSpec::Matchers.define :write do |message|
|
|
17
17
|
"write \"#{message}\" #{io_name}"
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
failure_message do
|
21
21
|
"expected to #{description}"
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
failure_message_when_negated do
|
25
25
|
"expected to not #{description}"
|
26
26
|
end
|
27
27
|
|