qbrick 2.5.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +423 -0
- data/Rakefile +82 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/LICENSE.txt +674 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/README.md +62 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/dialogs/anchor.js.coffee +81 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/dialogs/link.js.coffee +1353 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/images/anchor.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/images/hidpi/anchor.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/lang/de.js +68 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/lang/en.js +68 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/plugin.js.coffee +282 -0
- data/app/assets/javascripts/kuhsaft/application.js.coffee +7 -0
- data/app/assets/javascripts/kuhsaft/cms/application.js.coffee.erb +136 -0
- data/app/assets/javascripts/kuhsaft/views/read_more_view.js.coffee +17 -0
- data/app/assets/stylesheets/kuhsaft/application.css.sass +1 -0
- data/app/assets/stylesheets/kuhsaft/cms/application.css.sass +204 -0
- data/app/assets/stylesheets/kuhsaft/modules/_text_brick.css.sass +16 -0
- data/app/controllers/kuhsaft/api/pages_controller.rb +14 -0
- data/app/controllers/kuhsaft/cms/admin_controller.rb +18 -0
- data/app/controllers/kuhsaft/cms/assets_controller.rb +38 -0
- data/app/controllers/kuhsaft/cms/bricks_controller.rb +61 -0
- data/app/controllers/kuhsaft/cms/ckimages_controller.rb +26 -0
- data/app/controllers/kuhsaft/cms/pages_controller.rb +71 -0
- data/app/controllers/kuhsaft/pages_controller.rb +38 -0
- data/app/controllers/kuhsaft/sitemaps_controller.rb +12 -0
- data/app/helpers/cms_helper.rb +27 -0
- data/app/helpers/kuhsaft/admin_helper.rb +20 -0
- data/app/helpers/kuhsaft/cms/admin_helper.rb +21 -0
- data/app/helpers/kuhsaft/cms/pages_helper.rb +17 -0
- data/app/helpers/pages_helper.rb +49 -0
- data/app/helpers/sitemaps_helper.rb +12 -0
- data/app/models/kuhsaft/accordion_brick.rb +15 -0
- data/app/models/kuhsaft/accordion_item_brick.rb +21 -0
- data/app/models/kuhsaft/anchor_brick.rb +17 -0
- data/app/models/kuhsaft/asset.rb +29 -0
- data/app/models/kuhsaft/asset_brick.rb +26 -0
- data/app/models/kuhsaft/brick.rb +137 -0
- data/app/models/kuhsaft/brick_type.rb +7 -0
- data/app/models/kuhsaft/brick_type_filter.rb +18 -0
- data/app/models/kuhsaft/ckimage.rb +5 -0
- data/app/models/kuhsaft/cms.rb +7 -0
- data/app/models/kuhsaft/column_brick.rb +22 -0
- data/app/models/kuhsaft/image_brick.rb +16 -0
- data/app/models/kuhsaft/image_size.rb +51 -0
- data/app/models/kuhsaft/link_brick.rb +21 -0
- data/app/models/kuhsaft/page.rb +160 -0
- data/app/models/kuhsaft/page_type.rb +11 -0
- data/app/models/kuhsaft/partition.rb +18 -0
- data/app/models/kuhsaft/placeholder_brick.rb +23 -0
- data/app/models/kuhsaft/publish_state.rb +24 -0
- data/app/models/kuhsaft/slider_brick.rb +18 -0
- data/app/models/kuhsaft/text_brick.rb +23 -0
- data/app/models/kuhsaft/two_column_brick.rb +46 -0
- data/app/models/kuhsaft/video_brick.rb +22 -0
- data/app/uploaders/kuhsaft/asset_brick_asset_uploader.rb +43 -0
- data/app/uploaders/kuhsaft/asset_uploader.rb +50 -0
- data/app/uploaders/kuhsaft/ckimage_uploader.rb +16 -0
- data/app/uploaders/kuhsaft/image_brick_image_uploader.rb +35 -0
- data/app/views/kuhsaft/accordion_bricks/_accordion_brick.html.haml +3 -0
- data/app/views/kuhsaft/accordion_bricks/accordion_brick/_edit.html.haml +0 -0
- data/app/views/kuhsaft/accordion_item_bricks/_accordion_item_brick.html.haml +8 -0
- data/app/views/kuhsaft/accordion_item_bricks/accordion_item_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/anchor_bricks/_anchor_brick.html.haml +1 -0
- data/app/views/kuhsaft/anchor_bricks/anchor_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/asset_bricks/_asset_brick.html.haml +2 -0
- data/app/views/kuhsaft/asset_bricks/asset_brick/_edit.html.haml +8 -0
- data/app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml +14 -0
- data/app/views/kuhsaft/cms/admin/_content_language_switch.html.haml +7 -0
- data/app/views/kuhsaft/cms/admin/_empty_state.html.haml +5 -0
- data/app/views/kuhsaft/cms/admin/_flash.html.haml +7 -0
- data/app/views/kuhsaft/cms/admin/_main_navigation.html.haml +6 -0
- data/app/views/kuhsaft/cms/assets/_form.html.haml +15 -0
- data/app/views/kuhsaft/cms/assets/_list.html.haml +11 -0
- data/app/views/kuhsaft/cms/assets/edit.html.haml +2 -0
- data/app/views/kuhsaft/cms/assets/index.html.haml +3 -0
- data/app/views/kuhsaft/cms/assets/new.html.haml +2 -0
- data/app/views/kuhsaft/cms/bricks/_brick_header.html.haml +43 -0
- data/app/views/kuhsaft/cms/bricks/_brick_item.html.haml +25 -0
- data/app/views/kuhsaft/cms/bricks/_brick_list.html.haml +4 -0
- data/app/views/kuhsaft/cms/bricks/_new.html.haml +41 -0
- data/app/views/kuhsaft/cms/bricks/_sort_form.html.haml +3 -0
- data/app/views/kuhsaft/cms/bricks/create.js.erb +11 -0
- data/app/views/kuhsaft/cms/bricks/destroy.js.erb +10 -0
- data/app/views/kuhsaft/cms/bricks/new.js.erb +14 -0
- data/app/views/kuhsaft/cms/bricks/update.js.erb +8 -0
- data/app/views/kuhsaft/cms/ckimages/create.html.haml +11 -0
- data/app/views/kuhsaft/cms/ckimages/destroy.js.erb +2 -0
- data/app/views/kuhsaft/cms/ckimages/index.html.haml +13 -0
- data/app/views/kuhsaft/cms/pages/_branch.html.haml +19 -0
- data/app/views/kuhsaft/cms/pages/_form.html.haml +45 -0
- data/app/views/kuhsaft/cms/pages/edit.html.haml +16 -0
- data/app/views/kuhsaft/cms/pages/index.html.haml +14 -0
- data/app/views/kuhsaft/cms/pages/new.html.haml +1 -0
- data/app/views/kuhsaft/cms/pages/show.html.haml +0 -0
- data/app/views/kuhsaft/cms/pages/sort.js.erb +0 -0
- data/app/views/kuhsaft/column_bricks/_column_brick.html.haml +3 -0
- data/app/views/kuhsaft/column_bricks/column_brick/_edit.html.haml +0 -0
- data/app/views/kuhsaft/image_bricks/_image_brick.html.haml +11 -0
- data/app/views/kuhsaft/image_bricks/image_brick/_edit.html.haml +13 -0
- data/app/views/kuhsaft/link_bricks/_link_brick.html.haml +2 -0
- data/app/views/kuhsaft/link_bricks/link_brick/_edit.html.haml +4 -0
- data/app/views/kuhsaft/pages/index.html.haml +7 -0
- data/app/views/kuhsaft/pages/show.html.haml +11 -0
- data/app/views/kuhsaft/placeholder_bricks/_placeholder_brick.html.haml +2 -0
- data/app/views/kuhsaft/placeholder_bricks/placeholder_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/search/_form.html.haml +2 -0
- data/app/views/kuhsaft/search/_results.html.haml +8 -0
- data/app/views/kuhsaft/search/_results_entry.html.haml +13 -0
- data/app/views/kuhsaft/sitemaps/index.xml.haml +9 -0
- data/app/views/kuhsaft/slider_bricks/_slider_brick.html.haml +10 -0
- data/app/views/kuhsaft/slider_bricks/slider_brick/_edit.html.haml +0 -0
- data/app/views/kuhsaft/text_bricks/_text_brick.html.haml +11 -0
- data/app/views/kuhsaft/text_bricks/text_brick/_edit.html.haml +2 -0
- data/app/views/kuhsaft/two_column_bricks/_two_column_brick.html.haml +3 -0
- data/app/views/kuhsaft/two_column_bricks/two_column_brick/_childs.html.haml +5 -0
- data/app/views/kuhsaft/two_column_bricks/two_column_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/video_bricks/_video_brick.html.haml +9 -0
- data/app/views/kuhsaft/video_bricks/video_brick/_edit.html.haml +8 -0
- data/app/views/layouts/kuhsaft/cms/application.html.haml +25 -0
- data/app/views/layouts/kuhsaft/cms/ckimages.html.haml +18 -0
- data/config/initializers/simple_form.rb +142 -0
- data/config/initializers/simple_form_bootstrap.rb +45 -0
- data/config/locales/de.yml +207 -0
- data/config/locales/en.yml +211 -0
- data/config/locales/models/kuhsaft/accordion_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/accordion_brick/en.yml +4 -0
- data/config/locales/models/kuhsaft/accordion_item_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/accordion_item_brick/en.yml +7 -0
- data/config/locales/models/kuhsaft/anchor_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/anchor_brick/en.yml +7 -0
- data/config/locales/models/kuhsaft/asset_brick/de.yml +9 -0
- data/config/locales/models/kuhsaft/asset_brick/en.yml +9 -0
- data/config/locales/models/kuhsaft/brick/de.yml +5 -0
- data/config/locales/models/kuhsaft/brick/en.yml +5 -0
- data/config/locales/models/kuhsaft/column_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/column_brick/en.yml +4 -0
- data/config/locales/models/kuhsaft/image_brick/de.yml +11 -0
- data/config/locales/models/kuhsaft/image_brick/en.yml +11 -0
- data/config/locales/models/kuhsaft/image_size/de.yml +13 -0
- data/config/locales/models/kuhsaft/image_size/en.yml +13 -0
- data/config/locales/models/kuhsaft/link_brick/de.yml +10 -0
- data/config/locales/models/kuhsaft/link_brick/en.yml +10 -0
- data/config/locales/models/kuhsaft/page/de.yml +19 -0
- data/config/locales/models/kuhsaft/page/en.yml +19 -0
- data/config/locales/models/kuhsaft/placeholder_brick/de.yml +8 -0
- data/config/locales/models/kuhsaft/placeholder_brick/en.yml +8 -0
- data/config/locales/models/kuhsaft/slider_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/slider_brick/en.yml +4 -0
- data/config/locales/models/kuhsaft/text_brick/de.yml +11 -0
- data/config/locales/models/kuhsaft/text_brick/en.yml +11 -0
- data/config/locales/models/kuhsaft/two_column_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/two_column_brick/en.yml +7 -0
- data/config/locales/models/kuhsaft/video_brick/de.yml +9 -0
- data/config/locales/models/kuhsaft/video_brick/en.yml +9 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/views/kuhsaft/cms/admin/de.yml +13 -0
- data/config/locales/views/kuhsaft/cms/admin/en.yml +12 -0
- data/config/locales/views/kuhsaft/cms/bricks/de.yml +18 -0
- data/config/locales/views/kuhsaft/cms/bricks/en.yml +18 -0
- data/config/locales/views/kuhsaft/cms/pages/de.yml +31 -0
- data/config/locales/views/kuhsaft/cms/pages/en.yml +31 -0
- data/config/locales/views/kuhsaft/image_brick/de.yml +6 -0
- data/config/locales/views/kuhsaft/image_brick/en.yml +6 -0
- data/config/locales/views/kuhsaft/search/de.yml +12 -0
- data/config/locales/views/kuhsaft/search/en.yml +12 -0
- data/config/locales/views/kuhsaft/text_brick/de.yml +6 -0
- data/config/locales/views/kuhsaft/text_brick/en.yml +6 -0
- data/config/locales/views/kuhsaft/video_brick/de.yml +7 -0
- data/config/locales/views/kuhsaft/video_brick/en.yml +7 -0
- data/config/routes.rb +30 -0
- data/db/migrate/01_create_kuhsaft_pages.rb +31 -0
- data/db/migrate/02_create_kuhsaft_bricks.rb +23 -0
- data/db/migrate/03_create_kuhsaft_brick_types.rb +12 -0
- data/db/migrate/04_create_kuhsaft_assets.rb +10 -0
- data/db/migrate/05_remove_cms_admin.rb +9 -0
- data/db/migrate/06_add_template_name_to_kuhsaft_bricks.rb +7 -0
- data/db/migrate/07_add_default_value_to_brick_type_enabled.rb +6 -0
- data/db/migrate/08_add_display_styles_to_bricks.rb +5 -0
- data/db/migrate/09_add_additional_fields_to_kuhsaft_bricks.rb +6 -0
- data/db/migrate/10_add_redirect_url_to_kuhsaft_pages.rb +7 -0
- data/db/migrate/11_update_url_and_redirect_url_value.rb +45 -0
- data/db/migrate/12_regenerate_fulltext.rb +12 -0
- data/db/migrate/13_add_page_title_to_pages.rb +7 -0
- data/db/migrate/14_move_kuhsaft_assets.rb +22 -0
- data/db/migrate/15_add_alt_text_to_bricks.rb +5 -0
- data/db/migrate/16_update_default_value_for_page_type.rb +9 -0
- data/db/migrate/17_set_page_type_to_content_for_empty_fields.rb +7 -0
- data/db/migrate/18_add_identifier_to_kuhsaft_pages.rb +6 -0
- data/db/migrate/19_add_col_count_to_bricks.rb +5 -0
- data/db/migrate/20_create_kuhsaft_ckimages.rb +9 -0
- data/db/seeds.rb +20 -0
- data/lib/generators/kuhsaft/assets/install_generator.rb +25 -0
- data/lib/generators/kuhsaft/translations/add_generator.rb +41 -0
- data/lib/kuhsaft.rb +22 -0
- data/lib/kuhsaft/brick_list.rb +87 -0
- data/lib/kuhsaft/engine.rb +27 -0
- data/lib/kuhsaft/gridded.rb +20 -0
- data/lib/kuhsaft/image_uploader_mounting.rb +22 -0
- data/lib/kuhsaft/orderable.rb +71 -0
- data/lib/kuhsaft/page_tree.rb +14 -0
- data/lib/kuhsaft/partial_extractor.rb +21 -0
- data/lib/kuhsaft/searchable.rb +69 -0
- data/lib/kuhsaft/touch_placeholders.rb +31 -0
- data/lib/kuhsaft/translatable.rb +54 -0
- data/lib/kuhsaft/version.rb +3 -0
- data/lib/tasks/kuhsaft_tasks.rake +22 -0
- data/lib/templates/kuhsaft/assets/ck-config.js.coffee +48 -0
- data/lib/templates/kuhsaft/assets/customizations.css.sass +0 -0
- data/lib/templates/kuhsaft/assets/customizations.js.coffee +0 -0
- data/lib/templates/kuhsaft/translations/add_translation.erb +8 -0
- data/spec/controllers/kuhsaft/api/pages_controller_spec.rb +70 -0
- data/spec/controllers/kuhsaft/pages_controller_spec.rb +90 -0
- data/spec/controllers/kuhsaft/sitemaps_controller_spec.rb +13 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/images/spec-image.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/javascripts/kuhsaft/cms/ck-config.js.coffee +48 -0
- data/spec/dummy/app/assets/javascripts/kuhsaft/cms/customizations.js.coffee +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/kuhsaft/cms/customizations.css.sass +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +26 -0
- data/spec/dummy/config/boot.rb +3 -0
- data/spec/dummy/config/database.yml +19 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +81 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/kuhsaft.rb +5 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/.gitkeep +0 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories.rb +26 -0
- data/spec/features/cms_pages_spec.rb +76 -0
- data/spec/features/search_spec.rb +78 -0
- data/spec/helpers/kuhsaft/cms/admin_helper_spec.rb +25 -0
- data/spec/helpers/kuhsaft/cms/pages_helper_spec.rb +46 -0
- data/spec/helpers/kuhsaft/pages_helper_spec.rb +21 -0
- data/spec/kuhsaft_spec.rb +7 -0
- data/spec/lib/brick_list_spec.rb +50 -0
- data/spec/lib/engine_spec.rb +25 -0
- data/spec/lib/gridded_spec.rb +24 -0
- data/spec/lib/image_uploader_mounting_spec.rb +14 -0
- data/spec/lib/page_tree_spec.rb +38 -0
- data/spec/lib/searchable_spec.rb +30 -0
- data/spec/lib/touch_placeholders_spec.rb +44 -0
- data/spec/lib/translatable_spec.rb +155 -0
- data/spec/models/accordion_brick_spec.rb +38 -0
- data/spec/models/accordion_item_brick_spec.rb +50 -0
- data/spec/models/anchor_brick_spec.rb +26 -0
- data/spec/models/asset_brick_spec.rb +45 -0
- data/spec/models/asset_spec.rb +41 -0
- data/spec/models/brick_spec.rb +134 -0
- data/spec/models/brick_type_filter_spec.rb +64 -0
- data/spec/models/column_brick_spec.rb +32 -0
- data/spec/models/image_brick_spec.rb +49 -0
- data/spec/models/image_size_spec.rb +36 -0
- data/spec/models/link_brick_spec.rb +51 -0
- data/spec/models/page_spec.rb +472 -0
- data/spec/models/placeholder_brick_spec.rb +46 -0
- data/spec/models/publish_state_spec.rb +33 -0
- data/spec/models/slider_brick_spec.rb +26 -0
- data/spec/models/text_brick_spec.rb +30 -0
- data/spec/models/two_column_brick_spec.rb +82 -0
- data/spec/models/video_brick_spec.rb +32 -0
- data/spec/spec_helper.rb +81 -0
- data/spec/support/kuhsaft_spec_helper.rb +8 -0
- data/spec/support/write_expectation.rb +57 -0
- data/spec/views/kuhsaft/sitemaps/index.xml.haml_spec.rb +67 -0
- data/vendor/assets/javascripts/bootstrap-modal-v2.js +376 -0
- data/vendor/assets/javascripts/bootstrap-modalmanager.js +423 -0
- data/vendor/assets/javascripts/jquery.nestable.js +485 -0
- data/vendor/assets/stylesheets/bootstrap_modal.css +214 -0
- data/vendor/assets/stylesheets/nestable.css +84 -0
- metadata +870 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kuhsaft::BrickTypeFilter do
|
4
|
+
let :brick_list do
|
5
|
+
Kuhsaft::Page.new
|
6
|
+
end
|
7
|
+
|
8
|
+
let :brick_type_filter do
|
9
|
+
Kuhsaft::BrickTypeFilter.new(brick_list)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#empty?' do
|
13
|
+
context 'when the user cant add childs' do
|
14
|
+
before do
|
15
|
+
brick_list.stub(:user_can_add_childs?).and_return(false)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns true' do
|
19
|
+
brick_type_filter.empty?.should be_true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when there are no bricks to be added' do
|
24
|
+
before do
|
25
|
+
brick_type_filter.stub(:allowed).and_return([])
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns true' do
|
29
|
+
brick_type_filter.empty?.should be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#allowed' do
|
35
|
+
context 'when no brick types are registered' do
|
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
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when brick types are registered' do
|
43
|
+
before do
|
44
|
+
Kuhsaft::BrickType.stub_chain(:enabled, :count, :zero?).and_return(false)
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when there are no constraints' do
|
48
|
+
it 'returns all enabled brick types' do
|
49
|
+
brick_list.stub(:allowed_brick_types).and_return([])
|
50
|
+
Kuhsaft::BrickType.should_receive(:enabled)
|
51
|
+
brick_type_filter.allowed
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when there are constraints' do
|
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'])
|
59
|
+
brick_type_filter.allowed
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kuhsaft::ColumnBrick do
|
4
|
+
|
5
|
+
let :column_brick do
|
6
|
+
Kuhsaft::ColumnBrick.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#user_can_delete?' do
|
10
|
+
it 'returns false' do
|
11
|
+
column_brick.user_can_delete?.should be_false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#user_can_save' do
|
16
|
+
it 'returns false' do
|
17
|
+
column_brick.user_can_save?.should be_false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#renders_own_childs?' do
|
22
|
+
it 'returns false' do
|
23
|
+
column_brick.renders_own_childs?.should be_false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#bricks' do
|
28
|
+
it 'can have childs' do
|
29
|
+
column_brick.should respond_to(:bricks)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kuhsaft::ImageBrick do
|
4
|
+
|
5
|
+
let :image_brick do
|
6
|
+
Kuhsaft::ImageBrick.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#valid' do
|
10
|
+
before do
|
11
|
+
image_brick.valid?
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'without an #image' do
|
15
|
+
it 'has en error' do
|
16
|
+
image_brick.should have(1).error_on(:image)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#save' do
|
22
|
+
context 'when changing the image size' do
|
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!)
|
27
|
+
image_brick.resize_image_if_size_changed
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#bricks' do
|
33
|
+
it 'can not have childs' do
|
34
|
+
image_brick.should_not respond_to(:bricks)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#user_can_add_childs?' do
|
39
|
+
it 'returns false' do
|
40
|
+
image_brick.user_can_add_childs?.should be_false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#uploader?' do
|
45
|
+
it 'returns true' do
|
46
|
+
image_brick.uploader?.should be_true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kuhsaft::ImageSize do
|
4
|
+
before do
|
5
|
+
Kuhsaft::ImageSize.build_defaults!
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '.build_defaults!' do
|
9
|
+
it 'sets the default sizes' do
|
10
|
+
Kuhsaft::ImageSize.all.should == [Kuhsaft::ImageSize.gallery_size,
|
11
|
+
Kuhsaft::ImageSize.teaser_size]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.clear!' do
|
16
|
+
before do
|
17
|
+
Kuhsaft::ImageSize.clear!
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'empties the list' do
|
21
|
+
Kuhsaft::ImageSize.all.should be_empty
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.add' do
|
26
|
+
it 'adds a new image size' do
|
27
|
+
expect { Kuhsaft::ImageSize.add(:stuff, 200, 100) }.to change(Kuhsaft::ImageSize.all, :count).by(1)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '.find_by_name' do
|
32
|
+
it 'returns the size' do
|
33
|
+
Kuhsaft::ImageSize.find_by_name('gallery').should == Kuhsaft::ImageSize.gallery_size
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kuhsaft::LinkBrick do
|
4
|
+
|
5
|
+
let :link_brick do
|
6
|
+
Kuhsaft::LinkBrick.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#valid' do
|
10
|
+
before do
|
11
|
+
link_brick.valid?
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'without a #href' do
|
15
|
+
it 'has en error' do
|
16
|
+
link_brick.should have(1).error_on(:href)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'without a #caption' do
|
21
|
+
it 'has an error' do
|
22
|
+
link_brick.should have(1).error_on(:caption)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#bricks' do
|
28
|
+
it 'can not have childs' do
|
29
|
+
link_brick.should_not respond_to(:bricks)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.styles' do
|
34
|
+
it 'returns the available link styles' do
|
35
|
+
Kuhsaft::LinkBrick.styles.should == %w(pdf word excel button external)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#to_style_class' do
|
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'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#user_can_add_childs?' do
|
47
|
+
it 'returns false' do
|
48
|
+
link_brick.user_can_add_childs?.should be_false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,472 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kuhsaft::Page do
|
4
|
+
# subject { described_class }
|
5
|
+
|
6
|
+
describe '.search' do
|
7
|
+
before do
|
8
|
+
3.times { create :page }
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should find any containing the search term' do
|
12
|
+
Kuhsaft::Page.search('lorem').should have_at_least(0).items
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should find with "English Title"' do
|
16
|
+
Kuhsaft::Page.search('English Title').should have_at_least(1).item
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should only find published results' do
|
20
|
+
Kuhsaft::Page.search('English Title').should be_all { |p| p.published? == true }
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should find by using the old api' do
|
24
|
+
Kuhsaft::Page.search('English').should == Kuhsaft::Page.search('English')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.position_of' do
|
29
|
+
it 'should find the position of a page' do
|
30
|
+
page = create(:page)
|
31
|
+
Kuhsaft::Page.position_of(page.id).should == page.position
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '.find_by_url' do
|
36
|
+
it 'should find its translated content by url' do
|
37
|
+
page = create(:page)
|
38
|
+
Kuhsaft::Page.find_by_url(page.url).should eq(page)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.flat_tree' do
|
43
|
+
it 'should create an ordered, flat list of the page tree' do
|
44
|
+
tree = create_page_tree
|
45
|
+
Kuhsaft::Page.flat_tree.should eq(tree)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#initialize' do
|
50
|
+
context 'without values' do
|
51
|
+
let :page do
|
52
|
+
Kuhsaft::Page.new
|
53
|
+
end
|
54
|
+
|
55
|
+
before do
|
56
|
+
page.valid?
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'has a mandatory title' do
|
60
|
+
page.should have(1).error_on(:title)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'has a mandatory slug' do
|
64
|
+
page.should have(1).error_on(:slug)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#published' do
|
70
|
+
it 'returns only published pages' do
|
71
|
+
_p1, p2, _p3 = 3.times.map { create(:page) }
|
72
|
+
p2.update_attribute :published, Kuhsaft::PublishState::UNPUBLISHED
|
73
|
+
Kuhsaft::Page.published.should be_all { |p| p.published?.should be_true }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#content_page' do
|
78
|
+
it 'returns only content pages' do
|
79
|
+
p1, p2, p3 = 3.times.map { create(:page) }
|
80
|
+
p2.update_attribute :page_type, Kuhsaft::PageType::REDIRECT
|
81
|
+
Kuhsaft::Page.content_page.should == [p1, p3]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#state_class' do
|
86
|
+
|
87
|
+
let(:page) { Kuhsaft::Page.new }
|
88
|
+
|
89
|
+
it 'returns publsihed as string when page is published' do
|
90
|
+
page.published = Kuhsaft::PublishState::PUBLISHED
|
91
|
+
expect(page.state_class).to eq 'published'
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'returns unpublsihed as string when page is unpublished' do
|
95
|
+
page.published = Kuhsaft::PublishState::UNPUBLISHED
|
96
|
+
expect(page.state_class).to eq 'unpublished'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#without_self' do
|
101
|
+
it 'returns pages but not itself' do
|
102
|
+
2.times { create(:page) }
|
103
|
+
page = Kuhsaft::Page.first
|
104
|
+
page.without_self.should_not include(page)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#nesting_name' do
|
109
|
+
let :page do
|
110
|
+
create(:page)
|
111
|
+
end
|
112
|
+
|
113
|
+
let :child_page do
|
114
|
+
create(:page, parent: page)
|
115
|
+
end
|
116
|
+
|
117
|
+
let :child_child_page do
|
118
|
+
create(:page, parent: child_page)
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'on the topmost level' do
|
122
|
+
it 'has a label representing it\'s nesting depth without a leading dash' do
|
123
|
+
page.nesting_name.should eq(page.title)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context 'on the first level' do
|
128
|
+
it 'should have a label with one dash' do
|
129
|
+
child_page.nesting_name.should eq("- #{child_page.title}")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'on the second level' do
|
134
|
+
it 'should have a label with two dashes' do
|
135
|
+
child_child_page.nesting_name.should eq("-- #{child_child_page.title}")
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe '#parent_pages' do
|
141
|
+
let :page do
|
142
|
+
create(:page)
|
143
|
+
end
|
144
|
+
|
145
|
+
let :child_page do
|
146
|
+
create(:page, parent: page)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'has a list of parent pages' do
|
150
|
+
child_page.parent_pages.should == [page]
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'is ordered from top to bottom' do
|
154
|
+
child_page.parent_pages.last.should == page
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe '#link' do
|
159
|
+
context 'when it has no content' do
|
160
|
+
it 'should return the link of it\'s first child' do
|
161
|
+
page = create(:page)
|
162
|
+
child = create(:page, parent: page)
|
163
|
+
page.body = nil
|
164
|
+
page.save
|
165
|
+
page.link.should == child.link
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe '#increment_position' do
|
171
|
+
it 'increments the position by 1' do
|
172
|
+
page = create :page
|
173
|
+
position = page.position
|
174
|
+
page.increment_position
|
175
|
+
page.position.should == (position + 1)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe '#decrement_position' do
|
180
|
+
it 'decrements the position by 1' do
|
181
|
+
page = create :page
|
182
|
+
position = page.position
|
183
|
+
page.decrement_position
|
184
|
+
page.position.should == (position - 1)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe '#preceding_sibling' do
|
189
|
+
it 'finds the predecing sibling' do
|
190
|
+
_page1 = create :page
|
191
|
+
page2 = create :page
|
192
|
+
page3 = create :page
|
193
|
+
page3.preceding_sibling.id.should == page2.id
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
describe '#succeeding_sibling' do
|
198
|
+
it 'finds the succeeding sibling' do
|
199
|
+
_page1 = create :page
|
200
|
+
page2 = create :page
|
201
|
+
page3 = create :page
|
202
|
+
page2.succeeding_sibling.id.should == page3.id
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
describe '#reposition' do
|
207
|
+
it 'repositions before a page, specified by id' do
|
208
|
+
page1 = create :page
|
209
|
+
_page2 = create :page
|
210
|
+
page3 = create :page
|
211
|
+
page3.reposition page1.id
|
212
|
+
page3.preceding_sibling.id.should == page1.id
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'repositions before all siblings, specified by nil' do
|
216
|
+
_page1 = create :page
|
217
|
+
page2 = create :page
|
218
|
+
page2.reposition nil
|
219
|
+
page2.position.should == 1
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe '#slug' do
|
224
|
+
let :page do
|
225
|
+
build(:page)
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'has a slug by default' do
|
229
|
+
page.save
|
230
|
+
page.slug.should eq(page.title.parameterize)
|
231
|
+
end
|
232
|
+
|
233
|
+
context 'when it is empty' do
|
234
|
+
it 'generates the slug' do
|
235
|
+
page.should_receive(:create_slug)
|
236
|
+
page.save
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
context 'when it is not empty' do
|
241
|
+
it 'takes the slug provided by the user' do
|
242
|
+
page.slug = 'my-slug'
|
243
|
+
page.save
|
244
|
+
page.slug.should == 'my-slug'
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
describe '#url' do
|
250
|
+
context 'when it is a normal page' do
|
251
|
+
it 'returns the concatenated slug of the whole child/parent tree' do
|
252
|
+
page = create(:page, slug: 'parent-slug')
|
253
|
+
child = create(:page, slug: 'child-slug', parent: page)
|
254
|
+
child.url.should == 'en/parent-slug/child-slug'
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
context 'when it is a navigation? page' do
|
259
|
+
it 'returns without the parent page slug' do
|
260
|
+
page = create(:page, slug: 'parent-slug', page_type: Kuhsaft::PageType::NAVIGATION)
|
261
|
+
child = create(:page, slug: 'child-slug', parent: page)
|
262
|
+
child.url.should == 'en/child-slug'
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
context 'when it is a redirect? page' do
|
267
|
+
it 'returns the absolute url' do
|
268
|
+
page = create(:page, page_type: Kuhsaft::PageType::REDIRECT, redirect_url: 'en/references', slug: 'news')
|
269
|
+
page.link.should eq('/en/news')
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
context 'when url part is empty' do
|
274
|
+
it 'strips the trailing slash' do
|
275
|
+
page = create(:page, page_type: Kuhsaft::PageType::NAVIGATION)
|
276
|
+
page.link.should eq('/en')
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
describe '#navigation?' do
|
282
|
+
context 'when the page_type is navigation' do
|
283
|
+
it 'returns true if the page_type is PageType::NAVIGATION' do
|
284
|
+
Kuhsaft::Page.new(page_type: Kuhsaft::PageType::NAVIGATION).navigation?.should be_true
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
context 'when the page_type is anything else' do
|
289
|
+
it 'returns false' do
|
290
|
+
Kuhsaft::Page.new(page_type: Kuhsaft::PageType::REDIRECT).navigation?.should be_false
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
describe '#redirect?' do
|
296
|
+
context 'when the page_type is a redirect' do
|
297
|
+
it 'returns true' do
|
298
|
+
Kuhsaft::Page.new(page_type: Kuhsaft::PageType::REDIRECT).redirect?.should be_true
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
context 'when the page type is anything else' do
|
303
|
+
it 'returns false' do
|
304
|
+
Kuhsaft::Page.new(page_type: Kuhsaft::PageType::NAVIGATION).redirect?.should be_false
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
describe 'page types' do
|
310
|
+
it 'returns content by default' do
|
311
|
+
expect(Kuhsaft::Page.new.page_type).to eq('content')
|
312
|
+
end
|
313
|
+
|
314
|
+
it 'returns navigation if set' do
|
315
|
+
expect(Kuhsaft::Page.new(page_type: Kuhsaft::PageType::NAVIGATION).page_type).to eq('navigation')
|
316
|
+
end
|
317
|
+
|
318
|
+
it 'returns redirect if set' do
|
319
|
+
expect(Kuhsaft::Page.new(page_type: Kuhsaft::PageType::REDIRECT).page_type).to eq('redirect')
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
describe '#translated?' do
|
324
|
+
it 'returns true when page is translated' do
|
325
|
+
@page = create(:page, title: 'Page 1', slug: 'page1')
|
326
|
+
expect(@page.translated?).to be_true
|
327
|
+
end
|
328
|
+
|
329
|
+
it 'returns false when page has no translation' do
|
330
|
+
@page = create(:page, title: 'Page 1', slug: 'page1')
|
331
|
+
I18n.with_locale :de do
|
332
|
+
expect(@page.translated?).to be_false
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
describe '#fulltext' do
|
338
|
+
let :page do
|
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
|
+
end
|
344
|
+
|
345
|
+
context 'when saved' do
|
346
|
+
it 'it collects and assigns the fulltext' do
|
347
|
+
page.should_receive(:collect_fulltext)
|
348
|
+
page.save
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'contains the page part content' do
|
352
|
+
page.fulltext.should include('oh la la')
|
353
|
+
end
|
354
|
+
|
355
|
+
it 'converts all data to strings' do
|
356
|
+
expect { page.collect_fulltext }.to_not raise_error
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
describe '#before_validation' do
|
362
|
+
it 'generates url automatically' do
|
363
|
+
page = Kuhsaft::Page.new slug: 'slug'
|
364
|
+
page.url.should be_nil
|
365
|
+
page.valid?
|
366
|
+
page.url.should be_present
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
describe '#after_save' do
|
371
|
+
context 'when updating a parents page type' do
|
372
|
+
it 'updates the child pages url if parent is changed to navigation' do
|
373
|
+
@parent_page = FactoryGirl.create(:page, slug: 'le_parent')
|
374
|
+
@child_page = FactoryGirl.create(:page, slug: 'le_child', parent: @parent_page)
|
375
|
+
|
376
|
+
@parent_page.update_attributes(page_type: Kuhsaft::PageType::NAVIGATION)
|
377
|
+
@child_page.reload.url.should eq("#{I18n.locale}/le_child")
|
378
|
+
end
|
379
|
+
|
380
|
+
it 'updates the child pages url if parent is changed to content' do
|
381
|
+
@parent_page = FactoryGirl.create(:page, slug: 'le_parent', page_type: Kuhsaft::PageType::NAVIGATION)
|
382
|
+
@child_page = FactoryGirl.create(:page, slug: 'le_child', parent: @parent_page)
|
383
|
+
|
384
|
+
@parent_page.update_attributes(page_type: Kuhsaft::PageType::CONTENT)
|
385
|
+
@child_page.reload.url.should eq("#{I18n.locale}/le_parent/le_child")
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
describe '#url_without_locale' do
|
391
|
+
let :page do
|
392
|
+
create(:page, slug: 'page')
|
393
|
+
end
|
394
|
+
|
395
|
+
context 'without parent' do
|
396
|
+
it 'returns url without leading /' do
|
397
|
+
page.url_without_locale.should_not start_with '/'
|
398
|
+
end
|
399
|
+
|
400
|
+
it 'returns a single slug' do
|
401
|
+
page.url_without_locale.should == 'page'
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
context 'when parent is navigation' do
|
406
|
+
let :parent do
|
407
|
+
create(:page, page_type: Kuhsaft::PageType::NAVIGATION)
|
408
|
+
end
|
409
|
+
|
410
|
+
let :child do
|
411
|
+
create(:page, slug: 'child', parent: parent)
|
412
|
+
end
|
413
|
+
|
414
|
+
it 'returns url without leading /' do
|
415
|
+
child.url_without_locale.should_not start_with '/'
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'does not concatenate the parent slug' do
|
419
|
+
child.url_without_locale.should == 'child'
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
context 'when parent is normal page' do
|
424
|
+
let :parent do
|
425
|
+
create(:page, slug: 'parent')
|
426
|
+
end
|
427
|
+
|
428
|
+
let :child do
|
429
|
+
create(:page, slug: 'child', parent: parent)
|
430
|
+
end
|
431
|
+
|
432
|
+
it 'returns url without leading /' do
|
433
|
+
child.url_without_locale.should_not start_with '/'
|
434
|
+
end
|
435
|
+
|
436
|
+
it 'does not concatenate the parent slug' do
|
437
|
+
child.url_without_locale.should == 'parent/child'
|
438
|
+
end
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
describe '#translated' do
|
443
|
+
before :each do
|
444
|
+
@page_1 = create(:page, title: 'Page 1', slug: 'page1')
|
445
|
+
@page_2 = create(:page, title: 'Page 2', slug: 'page1')
|
446
|
+
@page_3 = create(:page, title: 'Page 3', slug: 'page1')
|
447
|
+
end
|
448
|
+
|
449
|
+
it 'returns all pages that have a translation' do
|
450
|
+
expect(Kuhsaft::Page.translated).to eq [@page_1, @page_2, @page_3]
|
451
|
+
end
|
452
|
+
|
453
|
+
it 'does not return untranslated pages' do
|
454
|
+
I18n.with_locale :de do
|
455
|
+
@page_1.update(title: 'Page 1 fr', slug: 'page_1_fr')
|
456
|
+
expect(Kuhsaft::Page.translated).to eq [@page_1]
|
457
|
+
end
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
describe '#identifier' do
|
462
|
+
let(:cat_page) { create :page, identifier: 'cat_content' }
|
463
|
+
|
464
|
+
it 'should check for uniqueness' do
|
465
|
+
expect(build(:page, identifier: cat_page.identifier)).to be_invalid
|
466
|
+
end
|
467
|
+
|
468
|
+
it 'should be findable via scope' do
|
469
|
+
expect(Kuhsaft::Page.by_identifier(cat_page.identifier)).to eq(cat_page)
|
470
|
+
end
|
471
|
+
end
|
472
|
+
end
|