qbrick 2.5.0.pre → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (341) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +69 -379
  3. data/Rakefile +4 -4
  4. data/app/assets/images/logo.png +0 -0
  5. data/app/assets/javascripts/{kuhsaft → qbrick}/application.js.coffee +1 -1
  6. data/app/assets/javascripts/{kuhsaft → qbrick}/cms/application.js.coffee.erb +40 -17
  7. data/app/assets/javascripts/{kuhsaft → qbrick}/views/read_more_view.js.coffee +0 -0
  8. data/app/assets/stylesheets/{kuhsaft → qbrick}/application.css.sass +0 -0
  9. data/app/assets/stylesheets/{kuhsaft → qbrick}/cms/application.css.sass +38 -1
  10. data/app/assets/stylesheets/{kuhsaft → qbrick}/modules/_text_brick.css.sass +1 -1
  11. data/app/controllers/{kuhsaft → qbrick}/api/pages_controller.rb +2 -2
  12. data/app/controllers/qbrick/cms/accounts_controller.rb +28 -0
  13. data/app/controllers/qbrick/cms/admins_controller.rb +79 -0
  14. data/app/controllers/{kuhsaft → qbrick}/cms/assets_controller.rb +9 -9
  15. data/app/controllers/qbrick/cms/backend_controller.rb +25 -0
  16. data/app/controllers/{kuhsaft → qbrick}/cms/bricks_controller.rb +16 -13
  17. data/app/controllers/{kuhsaft → qbrick}/cms/ckimages_controller.rb +6 -6
  18. data/app/controllers/qbrick/cms/pages_controller.rb +87 -0
  19. data/app/controllers/qbrick/cms/settings_collections_controller.rb +26 -0
  20. data/app/controllers/{kuhsaft → qbrick}/pages_controller.rb +10 -5
  21. data/app/controllers/{kuhsaft → qbrick}/sitemaps_controller.rb +3 -3
  22. data/app/helpers/cms_helper.rb +4 -4
  23. data/app/helpers/pages_helper.rb +18 -10
  24. data/app/helpers/{kuhsaft → qbrick}/admin_helper.rb +2 -2
  25. data/app/helpers/qbrick/cms/admin_helper.rb +73 -0
  26. data/app/helpers/{kuhsaft → qbrick}/cms/pages_helper.rb +2 -2
  27. data/app/models/{kuhsaft → qbrick}/accordion_brick.rb +2 -2
  28. data/app/models/{kuhsaft → qbrick}/accordion_item_brick.rb +1 -1
  29. data/app/models/qbrick/admin.rb +8 -0
  30. data/app/models/{kuhsaft → qbrick}/anchor_brick.rb +1 -1
  31. data/app/models/{kuhsaft → qbrick}/asset.rb +2 -2
  32. data/app/models/{kuhsaft → qbrick}/asset_brick.rb +2 -2
  33. data/app/models/{kuhsaft → qbrick}/brick.rb +11 -8
  34. data/app/models/{kuhsaft → qbrick}/brick_type.rb +1 -1
  35. data/app/models/{kuhsaft → qbrick}/brick_type_filter.rb +4 -4
  36. data/app/models/{kuhsaft → qbrick}/ckimage.rb +1 -1
  37. data/app/models/{kuhsaft → qbrick}/cms.rb +2 -2
  38. data/app/models/qbrick/cms_model.rb +25 -0
  39. data/app/models/{kuhsaft → qbrick}/column_brick.rb +2 -2
  40. data/app/models/{kuhsaft → qbrick}/image_brick.rb +2 -2
  41. data/app/models/{kuhsaft → qbrick}/image_size.rb +3 -3
  42. data/app/models/{kuhsaft → qbrick}/link_brick.rb +1 -1
  43. data/app/models/{kuhsaft → qbrick}/page.rb +78 -17
  44. data/app/models/{kuhsaft → qbrick}/page_type.rb +3 -2
  45. data/app/models/{kuhsaft → qbrick}/partition.rb +1 -1
  46. data/app/models/{kuhsaft → qbrick}/placeholder_brick.rb +4 -4
  47. data/app/models/{kuhsaft → qbrick}/publish_state.rb +1 -1
  48. data/app/models/qbrick/setting.rb +13 -0
  49. data/app/models/qbrick/settings_collection.rb +10 -0
  50. data/app/models/{kuhsaft → qbrick}/slider_brick.rb +3 -3
  51. data/app/models/{kuhsaft → qbrick}/text_brick.rb +1 -1
  52. data/app/models/{kuhsaft → qbrick}/two_column_brick.rb +2 -2
  53. data/app/models/{kuhsaft → qbrick}/video_brick.rb +1 -1
  54. data/app/uploaders/qbrick/asset_brick_asset_uploader.rb +26 -0
  55. data/app/uploaders/{kuhsaft → qbrick}/asset_uploader.rb +3 -2
  56. data/app/uploaders/{kuhsaft → qbrick}/ckimage_uploader.rb +1 -1
  57. data/app/uploaders/{kuhsaft → qbrick}/image_brick_image_uploader.rb +4 -4
  58. data/app/views/devise/confirmations/new.html.haml +10 -0
  59. data/app/views/devise/mailer/confirmation_instructions.html.haml +4 -0
  60. data/app/views/devise/mailer/reset_password_instructions.html.haml +6 -0
  61. data/app/views/devise/mailer/unlock_instructions.html.haml +5 -0
  62. data/app/views/devise/passwords/edit.html.haml +10 -0
  63. data/app/views/devise/passwords/new.html.haml +8 -0
  64. data/app/views/devise/registrations/edit.html.haml +9 -0
  65. data/app/views/devise/registrations/new.html.haml +21 -0
  66. data/app/views/devise/sessions/new.html.haml +12 -0
  67. data/app/views/devise/shared/_links.html.haml +19 -0
  68. data/app/views/devise/unlocks/new.html.haml +10 -0
  69. data/app/views/layouts/devise.html.haml +16 -0
  70. data/app/views/layouts/{kuhsaft → qbrick}/cms/application.html.haml +4 -5
  71. data/app/views/layouts/qbrick/cms/ckimages.html.haml +18 -0
  72. data/app/views/{kuhsaft → qbrick}/accordion_bricks/_accordion_brick.html.haml +0 -0
  73. data/app/views/{kuhsaft → qbrick}/accordion_bricks/accordion_brick/_edit.html.haml +0 -0
  74. data/app/views/{kuhsaft → qbrick}/accordion_item_bricks/_accordion_item_brick.html.haml +0 -0
  75. data/app/views/{kuhsaft → qbrick}/accordion_item_bricks/accordion_item_brick/_edit.html.haml +0 -0
  76. data/app/views/{kuhsaft → qbrick}/anchor_bricks/_anchor_brick.html.haml +0 -0
  77. data/app/views/{kuhsaft → qbrick}/anchor_bricks/anchor_brick/_edit.html.haml +0 -0
  78. data/app/views/{kuhsaft → qbrick}/asset_bricks/_asset_brick.html.haml +0 -0
  79. data/app/views/{kuhsaft → qbrick}/asset_bricks/asset_brick/_edit.html.haml +1 -1
  80. data/app/views/qbrick/cms/accounts/edit.html.haml +12 -0
  81. data/app/views/qbrick/cms/admins/_form.html.haml +10 -0
  82. data/app/views/qbrick/cms/admins/edit.html.haml +5 -0
  83. data/app/views/qbrick/cms/admins/index.html.haml +26 -0
  84. data/app/views/qbrick/cms/admins/new.html.haml +5 -0
  85. data/app/views/{kuhsaft → qbrick}/cms/assets/_form.html.haml +0 -0
  86. data/app/views/{kuhsaft → qbrick}/cms/assets/_list.html.haml +0 -0
  87. data/app/views/{kuhsaft → qbrick}/cms/assets/edit.html.haml +0 -0
  88. data/app/views/qbrick/cms/assets/index.html.haml +3 -0
  89. data/app/views/{kuhsaft → qbrick}/cms/assets/new.html.haml +0 -0
  90. data/app/views/qbrick/cms/backend/_brick_clone_menu.html.haml +16 -0
  91. data/app/views/qbrick/cms/backend/_brick_type_dropdown.html.haml +15 -0
  92. data/app/views/{kuhsaft/cms/admin → qbrick/cms/backend}/_empty_state.html.haml +0 -0
  93. data/app/views/{kuhsaft/cms/admin → qbrick/cms/backend}/_flash.html.haml +0 -0
  94. data/app/views/qbrick/cms/backend/_main_navigation.html.haml +20 -0
  95. data/app/views/{kuhsaft → qbrick}/cms/bricks/_brick_header.html.haml +4 -4
  96. data/app/views/{kuhsaft → qbrick}/cms/bricks/_brick_item.html.haml +6 -5
  97. data/app/views/{kuhsaft → qbrick}/cms/bricks/_brick_list.html.haml +1 -1
  98. data/app/views/{kuhsaft → qbrick}/cms/bricks/_new.html.haml +3 -3
  99. data/app/views/{kuhsaft → qbrick}/cms/bricks/_sort_form.html.haml +0 -0
  100. data/app/views/{kuhsaft → qbrick}/cms/bricks/create.js.erb +1 -1
  101. data/app/views/{kuhsaft → qbrick}/cms/bricks/destroy.js.erb +0 -0
  102. data/app/views/{kuhsaft → qbrick}/cms/bricks/new.js.erb +1 -1
  103. data/app/views/{kuhsaft → qbrick}/cms/bricks/update.js.erb +1 -1
  104. data/app/views/{kuhsaft → qbrick}/cms/ckimages/create.html.haml +0 -0
  105. data/app/views/{kuhsaft → qbrick}/cms/ckimages/destroy.js.erb +0 -0
  106. data/app/views/{kuhsaft → qbrick}/cms/ckimages/index.html.haml +1 -1
  107. data/app/views/{kuhsaft → qbrick}/cms/pages/_branch.html.haml +4 -4
  108. data/app/views/{kuhsaft → qbrick}/cms/pages/_form.html.haml +15 -6
  109. data/app/views/qbrick/cms/pages/_mirror_modal.html.haml +52 -0
  110. data/app/views/qbrick/cms/pages/edit.html.haml +16 -0
  111. data/app/views/{kuhsaft → qbrick}/cms/pages/index.html.haml +1 -1
  112. data/app/views/qbrick/cms/pages/mirror.js.haml +5 -0
  113. data/app/views/qbrick/cms/pages/new.html.haml +1 -0
  114. data/app/views/{kuhsaft → qbrick}/cms/pages/show.html.haml +0 -0
  115. data/app/views/{kuhsaft → qbrick}/cms/pages/sort.js.erb +0 -0
  116. data/app/views/qbrick/cms/settings_collections/_form.html.haml +8 -0
  117. data/app/views/qbrick/cms/settings_collections/index.html.haml +6 -0
  118. data/app/views/{kuhsaft → qbrick}/column_bricks/_column_brick.html.haml +0 -0
  119. data/app/views/{kuhsaft → qbrick}/column_bricks/column_brick/_edit.html.haml +0 -0
  120. data/app/views/{kuhsaft → qbrick}/image_bricks/_image_brick.html.haml +0 -0
  121. data/app/views/{kuhsaft → qbrick}/image_bricks/image_brick/_edit.html.haml +1 -1
  122. data/app/views/{kuhsaft → qbrick}/link_bricks/_link_brick.html.haml +0 -0
  123. data/app/views/{kuhsaft → qbrick}/link_bricks/link_brick/_edit.html.haml +1 -1
  124. data/app/views/{kuhsaft → qbrick}/pages/index.html.haml +2 -2
  125. data/app/views/{kuhsaft → qbrick}/pages/show.html.haml +2 -0
  126. data/app/views/{kuhsaft → qbrick}/placeholder_bricks/_placeholder_brick.html.haml +0 -0
  127. data/app/views/qbrick/placeholder_bricks/placeholder_brick/_edit.html.haml +1 -0
  128. data/app/views/{kuhsaft → qbrick}/search/_form.html.haml +0 -0
  129. data/app/views/{kuhsaft → qbrick}/search/_results.html.haml +2 -2
  130. data/app/views/{kuhsaft → qbrick}/search/_results_entry.html.haml +1 -1
  131. data/app/views/{kuhsaft → qbrick}/sitemaps/index.xml.haml +0 -0
  132. data/app/views/{kuhsaft → qbrick}/slider_bricks/_slider_brick.html.haml +0 -0
  133. data/app/views/{kuhsaft → qbrick}/slider_bricks/slider_brick/_edit.html.haml +0 -0
  134. data/app/views/{kuhsaft → qbrick}/text_bricks/_text_brick.html.haml +0 -0
  135. data/app/views/{kuhsaft → qbrick}/text_bricks/text_brick/_edit.html.haml +0 -0
  136. data/app/views/{kuhsaft → qbrick}/two_column_bricks/_two_column_brick.html.haml +1 -1
  137. data/app/views/qbrick/two_column_bricks/two_column_brick/_childs.html.haml +5 -0
  138. data/app/views/qbrick/two_column_bricks/two_column_brick/_edit.html.haml +1 -0
  139. data/app/views/{kuhsaft → qbrick}/video_bricks/_video_brick.html.haml +2 -2
  140. data/app/views/{kuhsaft → qbrick}/video_bricks/video_brick/_edit.html.haml +1 -1
  141. data/config/initializers/devise.rb +259 -0
  142. data/config/locales/cms.de.yml +11 -0
  143. data/config/locales/cms.en.yml +11 -0
  144. data/config/locales/devise.en.yml +60 -0
  145. data/config/locales/models/qbrick/accordion_brick/de.yml +4 -0
  146. data/config/locales/models/qbrick/accordion_brick/en.yml +4 -0
  147. data/config/locales/models/qbrick/accordion_item_brick/de.yml +7 -0
  148. data/config/locales/models/qbrick/accordion_item_brick/en.yml +7 -0
  149. data/config/locales/models/qbrick/admin/de.yml +13 -0
  150. data/config/locales/models/qbrick/admin/en.yml +13 -0
  151. data/config/locales/models/{kuhsaft → qbrick}/anchor_brick/de.yml +2 -2
  152. data/config/locales/models/{kuhsaft → qbrick}/anchor_brick/en.yml +2 -2
  153. data/config/locales/models/{kuhsaft → qbrick}/asset_brick/de.yml +2 -2
  154. data/config/locales/models/{kuhsaft → qbrick}/asset_brick/en.yml +2 -2
  155. data/config/locales/models/{kuhsaft → qbrick}/brick/de.yml +1 -1
  156. data/config/locales/models/{kuhsaft → qbrick}/brick/en.yml +1 -1
  157. data/config/locales/models/qbrick/column_brick/de.yml +4 -0
  158. data/config/locales/models/qbrick/column_brick/en.yml +4 -0
  159. data/config/locales/models/{kuhsaft → qbrick}/image_brick/de.yml +2 -2
  160. data/config/locales/models/{kuhsaft → qbrick}/image_brick/en.yml +2 -2
  161. data/config/locales/models/{kuhsaft → qbrick}/image_size/de.yml +2 -2
  162. data/config/locales/models/{kuhsaft → qbrick}/image_size/en.yml +2 -2
  163. data/config/locales/models/{kuhsaft → qbrick}/link_brick/de.yml +2 -2
  164. data/config/locales/models/{kuhsaft → qbrick}/link_brick/en.yml +2 -2
  165. data/config/locales/models/{kuhsaft → qbrick}/page/de.yml +2 -2
  166. data/config/locales/models/{kuhsaft → qbrick}/page/en.yml +3 -2
  167. data/config/locales/models/{kuhsaft → qbrick}/placeholder_brick/de.yml +2 -2
  168. data/config/locales/models/{kuhsaft → qbrick}/placeholder_brick/en.yml +2 -2
  169. data/config/locales/models/qbrick/slider_brick/de.yml +4 -0
  170. data/config/locales/models/qbrick/slider_brick/en.yml +4 -0
  171. data/config/locales/models/{kuhsaft → qbrick}/text_brick/de.yml +2 -2
  172. data/config/locales/models/{kuhsaft → qbrick}/text_brick/en.yml +2 -2
  173. data/config/locales/models/qbrick/two_column_brick/de.yml +7 -0
  174. data/config/locales/models/qbrick/two_column_brick/en.yml +7 -0
  175. data/config/locales/models/{kuhsaft → qbrick}/video_brick/de.yml +2 -2
  176. data/config/locales/models/{kuhsaft → qbrick}/video_brick/en.yml +2 -2
  177. data/config/locales/views/qbrick/cms/admin/de.yml +36 -0
  178. data/config/locales/views/{kuhsaft → qbrick}/cms/admin/en.yml +1 -1
  179. data/config/locales/views/{kuhsaft → qbrick}/cms/bricks/de.yml +1 -1
  180. data/config/locales/views/{kuhsaft → qbrick}/cms/bricks/en.yml +1 -1
  181. data/config/locales/views/qbrick/cms/navigation.yml +8 -0
  182. data/config/locales/views/{kuhsaft → qbrick}/cms/pages/de.yml +14 -1
  183. data/config/locales/views/{kuhsaft → qbrick}/cms/pages/en.yml +1 -1
  184. data/config/locales/views/qbrick/cms/settings_collection/de.yml +14 -0
  185. data/config/locales/views/qbrick/cms/settings_collection/en.yml +14 -0
  186. data/config/locales/views/{kuhsaft → qbrick}/image_brick/de.yml +1 -1
  187. data/config/locales/views/{kuhsaft → qbrick}/image_brick/en.yml +1 -1
  188. data/config/locales/views/{kuhsaft → qbrick}/search/de.yml +1 -1
  189. data/config/locales/views/{kuhsaft → qbrick}/search/en.yml +1 -1
  190. data/config/locales/views/{kuhsaft → qbrick}/text_brick/de.yml +1 -1
  191. data/config/locales/views/{kuhsaft → qbrick}/text_brick/en.yml +1 -1
  192. data/config/locales/views/{kuhsaft → qbrick}/video_brick/de.yml +1 -1
  193. data/config/locales/views/{kuhsaft → qbrick}/video_brick/en.yml +1 -1
  194. data/config/routes.rb +14 -2
  195. data/db/migrate/{01_create_kuhsaft_pages.rb → 01_create_qbrick_pages.rb} +5 -5
  196. data/db/migrate/{02_create_kuhsaft_bricks.rb → 02_create_qbrick_bricks.rb} +3 -3
  197. data/db/migrate/03_create_qbrick_brick_types.rb +12 -0
  198. data/db/migrate/04_create_qbrick_assets.rb +10 -0
  199. data/db/migrate/05_remove_cms_admin.rb +3 -3
  200. data/db/migrate/06_add_template_name_to_qbrick_bricks.rb +7 -0
  201. data/db/migrate/07_add_default_value_to_brick_type_enabled.rb +2 -2
  202. data/db/migrate/08_add_display_styles_to_bricks.rb +1 -1
  203. data/db/migrate/09_add_additional_fields_to_qbrick_bricks.rb +6 -0
  204. data/db/migrate/10_add_redirect_url_to_qbrick_pages.rb +7 -0
  205. data/db/migrate/11_update_url_and_redirect_url_value.rb +2 -2
  206. data/db/migrate/12_regenerate_fulltext.rb +1 -1
  207. data/db/migrate/13_add_page_title_to_pages.rb +1 -1
  208. data/db/migrate/14_move_qbrick_assets.rb +22 -0
  209. data/db/migrate/15_add_alt_text_to_bricks.rb +1 -1
  210. data/db/migrate/16_update_default_value_for_page_type.rb +2 -2
  211. data/db/migrate/17_set_page_type_to_content_for_empty_fields.rb +2 -2
  212. data/db/migrate/18_add_identifier_to_qbrick_pages.rb +6 -0
  213. data/db/migrate/19_add_col_count_to_bricks.rb +1 -1
  214. data/db/migrate/20_create_qbrick_ckimages.rb +9 -0
  215. data/db/migrate/21_add_google_verification_key_to_qbrick_pages.rb +5 -0
  216. data/db/migrate/22_create_settings.rb +15 -0
  217. data/db/migrate/22_create_settings_collections.rb +11 -0
  218. data/db/migrate/23_add_metadata_to_asset.rb +6 -0
  219. data/db/migrate/23_devise_create_qbrick_admins.rb +42 -0
  220. data/db/seeds.rb +36 -13
  221. data/lib/generators/{kuhsaft → qbrick}/assets/install_generator.rb +5 -5
  222. data/lib/generators/qbrick/custom_model_generator.rb +117 -0
  223. data/lib/generators/{kuhsaft → qbrick}/translations/add_generator.rb +4 -4
  224. data/lib/qbrick.rb +24 -0
  225. data/lib/{kuhsaft → qbrick}/brick_list.rb +3 -3
  226. data/lib/{kuhsaft → qbrick}/engine.rb +5 -5
  227. data/lib/{kuhsaft → qbrick}/gridded.rb +1 -1
  228. data/lib/{kuhsaft → qbrick}/image_uploader_mounting.rb +2 -2
  229. data/lib/{kuhsaft → qbrick}/orderable.rb +1 -1
  230. data/lib/{kuhsaft → qbrick}/page_tree.rb +1 -1
  231. data/lib/{kuhsaft → qbrick}/partial_extractor.rb +1 -1
  232. data/lib/{kuhsaft → qbrick}/searchable.rb +5 -3
  233. data/lib/{kuhsaft → qbrick}/touch_placeholders.rb +4 -4
  234. data/lib/{kuhsaft → qbrick}/translatable.rb +1 -1
  235. data/lib/qbrick/version.rb +3 -0
  236. data/lib/tasks/{kuhsaft_tasks.rake → qbrick_tasks.rake} +5 -5
  237. data/lib/templates/{kuhsaft → qbrick}/assets/ck-config.js.coffee +0 -0
  238. data/lib/templates/{kuhsaft → qbrick}/assets/customizations.css.sass +0 -0
  239. data/lib/templates/{kuhsaft → qbrick}/assets/customizations.js.coffee +0 -0
  240. data/lib/templates/qbrick/custom_model_generator/base_controller.rb +17 -0
  241. data/lib/templates/qbrick/custom_model_generator/inherited_views/base/_form.html.haml +12 -0
  242. data/lib/templates/qbrick/custom_model_generator/inherited_views/base/edit.html.haml +5 -0
  243. data/lib/templates/qbrick/custom_model_generator/inherited_views/base/index.html.haml +28 -0
  244. data/lib/templates/qbrick/custom_model_generator/inherited_views/base/new.html.haml +5 -0
  245. data/lib/templates/qbrick/custom_model_generator/translations/qbrick_base.yml +11 -0
  246. data/lib/templates/qbrick/custom_model_generator/translations/resource.yml.erb +14 -0
  247. data/lib/templates/qbrick/translations/add_translation.erb +8 -0
  248. data/spec/command_wrapper_helper.rb +21 -0
  249. data/spec/controllers/{kuhsaft → qbrick}/api/pages_controller_spec.rb +5 -5
  250. data/spec/controllers/qbrick/cms/pages_controller_spec.rb +61 -0
  251. data/spec/controllers/{kuhsaft → qbrick}/pages_controller_spec.rb +11 -13
  252. data/spec/controllers/{kuhsaft → qbrick}/sitemaps_controller_spec.rb +2 -2
  253. data/spec/dummy/app/assets/javascripts/{kuhsaft → qbrick}/cms/ck-config.js.coffee +0 -0
  254. data/spec/dummy/app/assets/javascripts/{kuhsaft → qbrick}/cms/customizations.js.coffee +0 -0
  255. data/spec/dummy/app/assets/stylesheets/{kuhsaft → qbrick}/cms/customizations.css.sass +0 -0
  256. data/spec/dummy/app/controllers/application_controller.rb +1 -1
  257. data/spec/dummy/config/application.rb +3 -2
  258. data/spec/dummy/config/database.yml +2 -2
  259. data/spec/dummy/config/environments/production.rb +2 -2
  260. data/spec/dummy/config/environments/test.rb +1 -1
  261. data/spec/dummy/config/initializers/{kuhsaft.rb → qbrick.rb} +1 -1
  262. data/spec/dummy/config/routes.rb +4 -1
  263. data/spec/factories.rb +24 -9
  264. data/spec/features/administrator_management_spec.rb +70 -0
  265. data/spec/features/cms_pages_spec.rb +15 -11
  266. data/spec/features/search_spec.rb +15 -15
  267. data/spec/features_helper.rb +36 -0
  268. data/spec/generators/custom_model_generator_spec.rb +83 -0
  269. data/spec/helpers/{kuhsaft → qbrick}/cms/admin_helper_spec.rb +5 -5
  270. data/spec/helpers/{kuhsaft → qbrick}/cms/pages_helper_spec.rb +6 -6
  271. data/spec/helpers/{kuhsaft → qbrick}/pages_helper_spec.rb +4 -5
  272. data/spec/lib/brick_list_spec.rb +12 -11
  273. data/spec/lib/engine_spec.rb +5 -9
  274. data/spec/lib/gridded_spec.rb +4 -5
  275. data/spec/lib/image_uploader_mounting_spec.rb +3 -4
  276. data/spec/lib/page_tree_spec.rb +5 -5
  277. data/spec/lib/searchable_spec.rb +7 -8
  278. data/spec/lib/touch_placeholders_spec.rb +4 -5
  279. data/spec/lib/translatable_spec.rb +20 -20
  280. data/spec/models/accordion_brick_spec.rb +7 -8
  281. data/spec/models/accordion_item_brick_spec.rb +8 -9
  282. data/spec/models/anchor_brick_spec.rb +5 -6
  283. data/spec/models/asset_brick_spec.rb +8 -9
  284. data/spec/models/asset_spec.rb +9 -11
  285. data/spec/models/brick_spec.rb +34 -34
  286. data/spec/models/brick_type_filter_spec.rb +14 -14
  287. data/spec/models/column_brick_spec.rb +6 -7
  288. data/spec/models/image_brick_spec.rb +9 -10
  289. data/spec/models/image_size_spec.rb +8 -8
  290. data/spec/models/link_brick_spec.rb +9 -10
  291. data/spec/models/page_spec.rb +113 -73
  292. data/spec/models/placeholder_brick_spec.rb +12 -13
  293. data/spec/models/publish_state_spec.rb +7 -7
  294. data/spec/models/setting_spec.rb +28 -0
  295. data/spec/models/slider_brick_spec.rb +5 -6
  296. data/spec/models/text_brick_spec.rb +5 -5
  297. data/spec/models/two_column_brick_spec.rb +14 -15
  298. data/spec/models/video_brick_spec.rb +5 -6
  299. data/spec/postgres_helper.rb +66 -0
  300. data/spec/{kuhsaft_spec.rb → qbrick_spec.rb} +2 -2
  301. data/spec/spec_helper.rb +23 -10
  302. data/spec/support/{kuhsaft_spec_helper.rb → qbrick_spec_helper.rb} +1 -1
  303. data/spec/support/write_expectation.rb +2 -2
  304. data/spec/views/{kuhsaft → qbrick}/sitemaps/index.xml.haml_spec.rb +3 -3
  305. metadata +451 -330
  306. data/app/controllers/kuhsaft/cms/admin_controller.rb +0 -18
  307. data/app/controllers/kuhsaft/cms/pages_controller.rb +0 -71
  308. data/app/helpers/kuhsaft/cms/admin_helper.rb +0 -21
  309. data/app/uploaders/kuhsaft/asset_brick_asset_uploader.rb +0 -43
  310. data/app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml +0 -14
  311. data/app/views/kuhsaft/cms/admin/_content_language_switch.html.haml +0 -7
  312. data/app/views/kuhsaft/cms/admin/_main_navigation.html.haml +0 -6
  313. data/app/views/kuhsaft/cms/assets/index.html.haml +0 -3
  314. data/app/views/kuhsaft/cms/pages/edit.html.haml +0 -16
  315. data/app/views/kuhsaft/cms/pages/new.html.haml +0 -1
  316. data/app/views/kuhsaft/placeholder_bricks/placeholder_brick/_edit.html.haml +0 -1
  317. data/app/views/kuhsaft/two_column_bricks/two_column_brick/_childs.html.haml +0 -5
  318. data/app/views/kuhsaft/two_column_bricks/two_column_brick/_edit.html.haml +0 -1
  319. data/app/views/layouts/kuhsaft/cms/ckimages.html.haml +0 -18
  320. data/config/locales/models/kuhsaft/accordion_brick/de.yml +0 -4
  321. data/config/locales/models/kuhsaft/accordion_brick/en.yml +0 -4
  322. data/config/locales/models/kuhsaft/accordion_item_brick/de.yml +0 -7
  323. data/config/locales/models/kuhsaft/accordion_item_brick/en.yml +0 -7
  324. data/config/locales/models/kuhsaft/column_brick/de.yml +0 -4
  325. data/config/locales/models/kuhsaft/column_brick/en.yml +0 -4
  326. data/config/locales/models/kuhsaft/slider_brick/de.yml +0 -4
  327. data/config/locales/models/kuhsaft/slider_brick/en.yml +0 -4
  328. data/config/locales/models/kuhsaft/two_column_brick/de.yml +0 -7
  329. data/config/locales/models/kuhsaft/two_column_brick/en.yml +0 -7
  330. data/config/locales/views/kuhsaft/cms/admin/de.yml +0 -13
  331. data/db/migrate/03_create_kuhsaft_brick_types.rb +0 -12
  332. data/db/migrate/04_create_kuhsaft_assets.rb +0 -10
  333. data/db/migrate/06_add_template_name_to_kuhsaft_bricks.rb +0 -7
  334. data/db/migrate/09_add_additional_fields_to_kuhsaft_bricks.rb +0 -6
  335. data/db/migrate/10_add_redirect_url_to_kuhsaft_pages.rb +0 -7
  336. data/db/migrate/14_move_kuhsaft_assets.rb +0 -22
  337. data/db/migrate/18_add_identifier_to_kuhsaft_pages.rb +0 -6
  338. data/db/migrate/20_create_kuhsaft_ckimages.rb +0 -9
  339. data/lib/kuhsaft.rb +0 -22
  340. data/lib/kuhsaft/version.rb +0 -3
  341. data/lib/templates/kuhsaft/translations/add_translation.erb +0 -8
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::Brick do
3
+ describe Qbrick::Brick, type: :model do
4
4
  let :brick do
5
- Kuhsaft::Brick.new
5
+ Qbrick::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
 
@@ -29,90 +29,90 @@ describe Kuhsaft::Brick do
29
29
  end
30
30
 
31
31
  describe '#brick_list_type' do
32
- it 'returns Kuhsaft::Brick' do
33
- brick.brick_list_type.should == 'Kuhsaft::Brick'
32
+ it 'returns Qbrick::Brick' do
33
+ expect(brick.brick_list_type).to eq('Qbrick::Brick')
34
34
  end
35
35
  end
36
36
 
37
37
  describe '#parents' do
38
38
  it 'returns the chain of parents' do
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]
39
+ item1, item2, item3 = double, double, Qbrick::Brick.new
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(Qbrick::TextBrick.new.to_edit_partial_path).to eq('qbrick/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
- brick = Kuhsaft::Brick.new
55
- brick.has_siblings?.should be_false
54
+ brick = Qbrick::Brick.new
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
- 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
59
+ item1, item2, item3 = double, double, Qbrick::Brick.new
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(Qbrick::TextBrick.new.to_edit_childs_partial_path).to eq('qbrick/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(Qbrick::TextBrick.new.to_style_class).to eq('qbrick-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
- brick = Kuhsaft::TextBrick.new
88
- brick.stub(:id).and_return(104)
89
- brick.to_style_id.should == 'kuhsaft-text-brick-104'
87
+ brick = Qbrick::TextBrick.new
88
+ allow(brick).to receive(:id).and_return(104)
89
+ expect(brick.to_style_id).to eq('qbrick-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
- brick = Kuhsaft::TextBrick.new
96
- brick.backend_label.should == 'Text'
95
+ brick = Qbrick::TextBrick.new
96
+ expect(brick.backend_label).to eq('Text')
97
97
  end
98
98
 
99
- context 'with the parenthesis option given' do
100
- brick = Kuhsaft::TextBrick.new
101
- brick.backend_label(parenthesis: true).should == '(Text)'
99
+ it 'with the parenthesis option given' do
100
+ brick = Qbrick::TextBrick.new
101
+ expect(brick.backend_label(parenthesis: true)).to eq '(Text)'
102
102
  end
103
103
  end
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
 
111
111
  describe '#after_save' do
112
112
  describe 'update_fulltext' do
113
113
  let! :brick do
114
- Kuhsaft::Brick.new.tap do |b|
115
- b.type = Kuhsaft::BrickType.new
114
+ Qbrick::Brick.new.tap do |b|
115
+ b.type = 'Qbrick::TextBrick'
116
116
  end
117
117
  end
118
118
 
@@ -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,32 +1,32 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::BrickTypeFilter do
3
+ describe Qbrick::BrickTypeFilter, type: :model do
4
4
  let :brick_list do
5
- Kuhsaft::Page.new
5
+ Qbrick::Page.new
6
6
  end
7
7
 
8
8
  let :brick_type_filter do
9
- Kuhsaft::BrickTypeFilter.new(brick_list)
9
+ Qbrick::BrickTypeFilter.new(brick_list)
10
10
  end
11
11
 
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(Qbrick::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(Qbrick::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(Qbrick::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(['Qbrick::TextBrick'])
58
+ expect(Qbrick::BrickType.enabled).to receive(:constrained).with(['Qbrick::TextBrick'])
59
59
  brick_type_filter.allowed
60
60
  end
61
61
  end
@@ -1,32 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::ColumnBrick do
4
-
3
+ describe Qbrick::ColumnBrick, type: :model do
5
4
  let :column_brick do
6
- Kuhsaft::ColumnBrick.new
5
+ Qbrick::ColumnBrick.new
7
6
  end
8
7
 
9
8
  describe '#user_can_delete?' do
10
9
  it 'returns false' do
11
- column_brick.user_can_delete?.should be_false
10
+ expect(column_brick.user_can_delete?).to be_falsey
12
11
  end
13
12
  end
14
13
 
15
14
  describe '#user_can_save' do
16
15
  it 'returns false' do
17
- column_brick.user_can_save?.should be_false
16
+ expect(column_brick.user_can_save?).to be_falsey
18
17
  end
19
18
  end
20
19
 
21
20
  describe '#renders_own_childs?' do
22
21
  it 'returns false' do
23
- column_brick.renders_own_childs?.should be_false
22
+ expect(column_brick.renders_own_childs?).to be_falsey
24
23
  end
25
24
  end
26
25
 
27
26
  describe '#bricks' do
28
27
  it 'can have childs' do
29
- column_brick.should respond_to(:bricks)
28
+ expect(column_brick).to respond_to(:bricks)
30
29
  end
31
30
  end
32
31
  end
@@ -1,9 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::ImageBrick do
4
-
3
+ describe Qbrick::ImageBrick, type: :model do
5
4
  let :image_brick do
6
- Kuhsaft::ImageBrick.new
5
+ Qbrick::ImageBrick.new
7
6
  end
8
7
 
9
8
  describe '#valid' do
@@ -13,7 +12,7 @@ describe Kuhsaft::ImageBrick do
13
12
 
14
13
  context 'without an #image' do
15
14
  it 'has en error' do
16
- image_brick.should have(1).error_on(:image)
15
+ expect(image_brick.errors[:image].size).to eq(1)
17
16
  end
18
17
  end
19
18
  end
@@ -21,9 +20,9 @@ describe Kuhsaft::ImageBrick do
21
20
  describe '#save' do
22
21
  context 'when changing the image size' do
23
22
  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!)
23
+ allow(image_brick).to receive(:image_size_changed?).and_return(true)
24
+ allow(image_brick).to receive(:image_present?).and_return(true)
25
+ expect(image_brick.image).to receive(:recreate_versions!)
27
26
  image_brick.resize_image_if_size_changed
28
27
  end
29
28
  end
@@ -31,19 +30,19 @@ describe Kuhsaft::ImageBrick do
31
30
 
32
31
  describe '#bricks' do
33
32
  it 'can not have childs' do
34
- image_brick.should_not respond_to(:bricks)
33
+ expect(image_brick).not_to respond_to(:bricks)
35
34
  end
36
35
  end
37
36
 
38
37
  describe '#user_can_add_childs?' do
39
38
  it 'returns false' do
40
- image_brick.user_can_add_childs?.should be_false
39
+ expect(image_brick.user_can_add_childs?).to be_falsey
41
40
  end
42
41
  end
43
42
 
44
43
  describe '#uploader?' do
45
44
  it 'returns true' do
46
- image_brick.uploader?.should be_true
45
+ expect(image_brick.uploader?).to be_truthy
47
46
  end
48
47
  end
49
48
  end
@@ -1,36 +1,36 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::ImageSize do
3
+ describe Qbrick::ImageSize, type: :model do
4
4
  before do
5
- Kuhsaft::ImageSize.build_defaults!
5
+ Qbrick::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(Qbrick::ImageSize.all).to eq([Qbrick::ImageSize.gallery_size,
11
+ Qbrick::ImageSize.teaser_size])
12
12
  end
13
13
  end
14
14
 
15
15
  describe '.clear!' do
16
16
  before do
17
- Kuhsaft::ImageSize.clear!
17
+ Qbrick::ImageSize.clear!
18
18
  end
19
19
 
20
20
  it 'empties the list' do
21
- Kuhsaft::ImageSize.all.should be_empty
21
+ expect(Qbrick::ImageSize.all).to be_empty
22
22
  end
23
23
  end
24
24
 
25
25
  describe '.add' do
26
26
  it 'adds a new image size' do
27
- expect { Kuhsaft::ImageSize.add(:stuff, 200, 100) }.to change(Kuhsaft::ImageSize.all, :count).by(1)
27
+ expect { Qbrick::ImageSize.add(:stuff, 200, 100) }.to change(Qbrick::ImageSize.all, :count).by(1)
28
28
  end
29
29
  end
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(Qbrick::ImageSize.find_by_name('gallery')).to eq(Qbrick::ImageSize.gallery_size)
34
34
  end
35
35
  end
36
36
  end
@@ -1,9 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::LinkBrick do
4
-
3
+ describe Qbrick::LinkBrick, type: :model do
5
4
  let :link_brick do
6
- Kuhsaft::LinkBrick.new
5
+ Qbrick::LinkBrick.new
7
6
  end
8
7
 
9
8
  describe '#valid' do
@@ -13,39 +12,39 @@ describe Kuhsaft::LinkBrick do
13
12
 
14
13
  context 'without a #href' do
15
14
  it 'has en error' do
16
- link_brick.should have(1).error_on(:href)
15
+ expect(link_brick.errors[:href].count).to eq(1)
17
16
  end
18
17
  end
19
18
 
20
19
  context 'without a #caption' do
21
20
  it 'has an error' do
22
- link_brick.should have(1).error_on(:caption)
21
+ expect(link_brick.errors[:caption].count).to eq(1)
23
22
  end
24
23
  end
25
24
  end
26
25
 
27
26
  describe '#bricks' do
28
27
  it 'can not have childs' do
29
- link_brick.should_not respond_to(:bricks)
28
+ expect(link_brick).not_to respond_to(:bricks)
30
29
  end
31
30
  end
32
31
 
33
32
  describe '.styles' do
34
33
  it 'returns the available link styles' do
35
- Kuhsaft::LinkBrick.styles.should == %w(pdf word excel button external)
34
+ expect(Qbrick::LinkBrick.styles).to eq(%w(pdf word excel button external))
36
35
  end
37
36
  end
38
37
 
39
38
  describe '#to_style_class' do
40
39
  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'
40
+ allow(link_brick).to receive(:link_style).and_return('pdf')
41
+ expect(link_brick.to_style_class).to eq('qbrick-link-brick pdf')
43
42
  end
44
43
  end
45
44
 
46
45
  describe '#user_can_add_childs?' do
47
46
  it 'returns false' do
48
- link_brick.user_can_add_childs?.should be_false
47
+ expect(link_brick.user_can_add_childs?).to be_falsey
49
48
  end
50
49
  end
51
50
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kuhsaft::Page do
3
+ describe Qbrick::Page, type: :model do
4
4
  # subject { described_class }
5
5
 
6
6
  describe '.search' do
@@ -9,47 +9,47 @@ 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').should have_at_least(0).items
12
+ expect(Qbrick::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').should have_at_least(1).item
16
+ expect(Qbrick::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').should be_all { |p| p.published? == true }
20
+ expect(Qbrick::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').should == Kuhsaft::Page.search('English')
24
+ expect(Qbrick::Page.search('English')).to eq(Qbrick::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).should == page.position
31
+ expect(Qbrick::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).should eq(page)
38
+ expect(Qbrick::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.should eq(tree)
45
+ expect(Qbrick::Page.flat_tree).to eq(tree)
46
46
  end
47
47
  end
48
48
 
49
49
  describe '#initialize' do
50
50
  context 'without values' do
51
51
  let :page do
52
- Kuhsaft::Page.new
52
+ Qbrick::Page.new
53
53
  end
54
54
 
55
55
  before do
@@ -57,11 +57,11 @@ describe Kuhsaft::Page do
57
57
  end
58
58
 
59
59
  it 'has a mandatory title' do
60
- page.should have(1).error_on(:title)
60
+ expect(page.errors[:title].count).to eq(1)
61
61
  end
62
62
 
63
63
  it 'has a mandatory slug' do
64
- page.should have(1).error_on(:slug)
64
+ expect(page.errors[:slug].count).to eq(1)
65
65
  end
66
66
  end
67
67
  end
@@ -69,30 +69,29 @@ describe Kuhsaft::Page do
69
69
  describe '#published' do
70
70
  it 'returns only published pages' do
71
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 }
72
+ p2.update_attribute :published, Qbrick::PublishState::UNPUBLISHED
73
+ expect(Qbrick::Page.published).to be_all { |p| expect(p.published?).to be_truthy }
74
74
  end
75
75
  end
76
76
 
77
77
  describe '#content_page' do
78
78
  it 'returns only content pages' do
79
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]
80
+ p2.update_attribute :page_type, Qbrick::PageType::REDIRECT
81
+ expect(Qbrick::Page.content_page).to eq([p1, p3])
82
82
  end
83
83
  end
84
84
 
85
85
  describe '#state_class' do
86
-
87
- let(:page) { Kuhsaft::Page.new }
86
+ let(:page) { Qbrick::Page.new }
88
87
 
89
88
  it 'returns publsihed as string when page is published' do
90
- page.published = Kuhsaft::PublishState::PUBLISHED
89
+ page.published = Qbrick::PublishState::PUBLISHED
91
90
  expect(page.state_class).to eq 'published'
92
91
  end
93
92
 
94
93
  it 'returns unpublsihed as string when page is unpublished' do
95
- page.published = Kuhsaft::PublishState::UNPUBLISHED
94
+ page.published = Qbrick::PublishState::UNPUBLISHED
96
95
  expect(page.state_class).to eq 'unpublished'
97
96
  end
98
97
  end
@@ -100,8 +99,8 @@ describe Kuhsaft::Page do
100
99
  describe '#without_self' do
101
100
  it 'returns pages but not itself' do
102
101
  2.times { create(:page) }
103
- page = Kuhsaft::Page.first
104
- page.without_self.should_not include(page)
102
+ page = Qbrick::Page.first
103
+ expect(page.without_self).not_to include(page)
105
104
  end
106
105
  end
107
106
 
@@ -120,19 +119,19 @@ describe Kuhsaft::Page do
120
119
 
121
120
  context 'on the topmost level' do
122
121
  it 'has a label representing it\'s nesting depth without a leading dash' do
123
- page.nesting_name.should eq(page.title)
122
+ expect(page.nesting_name).to eq(page.title)
124
123
  end
125
124
  end
126
125
 
127
126
  context 'on the first level' do
128
127
  it 'should have a label with one dash' do
129
- child_page.nesting_name.should eq("- #{child_page.title}")
128
+ expect(child_page.nesting_name).to eq("- #{child_page.title}")
130
129
  end
131
130
  end
132
131
 
133
132
  context 'on the second level' do
134
133
  it 'should have a label with two dashes' do
135
- child_child_page.nesting_name.should eq("-- #{child_child_page.title}")
134
+ expect(child_child_page.nesting_name).to eq("-- #{child_child_page.title}")
136
135
  end
137
136
  end
138
137
  end
@@ -147,11 +146,11 @@ describe Kuhsaft::Page do
147
146
  end
148
147
 
149
148
  it 'has a list of parent pages' do
150
- child_page.parent_pages.should == [page]
149
+ expect(child_page.parent_pages).to eq([page])
151
150
  end
152
151
 
153
152
  it 'is ordered from top to bottom' do
154
- child_page.parent_pages.last.should == page
153
+ expect(child_page.parent_pages.last).to eq(page)
155
154
  end
156
155
  end
157
156
 
@@ -162,7 +161,7 @@ describe Kuhsaft::Page do
162
161
  child = create(:page, parent: page)
163
162
  page.body = nil
164
163
  page.save
165
- page.link.should == child.link
164
+ expect(page.link).to eq(child.link)
166
165
  end
167
166
  end
168
167
  end
@@ -172,7 +171,7 @@ describe Kuhsaft::Page do
172
171
  page = create :page
173
172
  position = page.position
174
173
  page.increment_position
175
- page.position.should == (position + 1)
174
+ expect(page.position).to eq(position + 1)
176
175
  end
177
176
  end
178
177
 
@@ -181,7 +180,7 @@ describe Kuhsaft::Page do
181
180
  page = create :page
182
181
  position = page.position
183
182
  page.decrement_position
184
- page.position.should == (position - 1)
183
+ expect(page.position).to eq(position - 1)
185
184
  end
186
185
  end
187
186
 
@@ -190,7 +189,7 @@ describe Kuhsaft::Page do
190
189
  _page1 = create :page
191
190
  page2 = create :page
192
191
  page3 = create :page
193
- page3.preceding_sibling.id.should == page2.id
192
+ expect(page3.preceding_sibling.id).to eq(page2.id)
194
193
  end
195
194
  end
196
195
 
@@ -199,7 +198,7 @@ describe Kuhsaft::Page do
199
198
  _page1 = create :page
200
199
  page2 = create :page
201
200
  page3 = create :page
202
- page2.succeeding_sibling.id.should == page3.id
201
+ expect(page2.succeeding_sibling.id).to eq(page3.id)
203
202
  end
204
203
  end
205
204
 
@@ -209,14 +208,14 @@ describe Kuhsaft::Page do
209
208
  _page2 = create :page
210
209
  page3 = create :page
211
210
  page3.reposition page1.id
212
- page3.preceding_sibling.id.should == page1.id
211
+ expect(page3.preceding_sibling.id).to eq(page1.id)
213
212
  end
214
213
 
215
214
  it 'repositions before all siblings, specified by nil' do
216
215
  _page1 = create :page
217
216
  page2 = create :page
218
217
  page2.reposition nil
219
- page2.position.should == 1
218
+ expect(page2.position).to eq(1)
220
219
  end
221
220
  end
222
221
 
@@ -227,12 +226,12 @@ describe Kuhsaft::Page do
227
226
 
228
227
  it 'has a slug by default' do
229
228
  page.save
230
- page.slug.should eq(page.title.parameterize)
229
+ expect(page.slug).to eq(page.title.parameterize)
231
230
  end
232
231
 
233
232
  context 'when it is empty' do
234
233
  it 'generates the slug' do
235
- page.should_receive(:create_slug)
234
+ expect(page).to receive(:create_slug)
236
235
  page.save
237
236
  end
238
237
  end
@@ -241,7 +240,7 @@ describe Kuhsaft::Page do
241
240
  it 'takes the slug provided by the user' do
242
241
  page.slug = 'my-slug'
243
242
  page.save
244
- page.slug.should == 'my-slug'
243
+ expect(page.slug).to eq('my-slug')
245
244
  end
246
245
  end
247
246
  end
@@ -251,29 +250,29 @@ describe Kuhsaft::Page do
251
250
  it 'returns the concatenated slug of the whole child/parent tree' do
252
251
  page = create(:page, slug: 'parent-slug')
253
252
  child = create(:page, slug: 'child-slug', parent: page)
254
- child.url.should == 'en/parent-slug/child-slug'
253
+ expect(child.url).to eq('en/parent-slug/child-slug')
255
254
  end
256
255
  end
257
256
 
258
257
  context 'when it is a navigation? page' do
259
258
  it 'returns without the parent page slug' do
260
- page = create(:page, slug: 'parent-slug', page_type: Kuhsaft::PageType::NAVIGATION)
259
+ page = create(:page, slug: 'parent-slug', page_type: Qbrick::PageType::NAVIGATION)
261
260
  child = create(:page, slug: 'child-slug', parent: page)
262
- child.url.should == 'en/child-slug'
261
+ expect(child.url).to eq('en/child-slug')
263
262
  end
264
263
  end
265
264
 
266
265
  context 'when it is a redirect? page' do
267
266
  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')
267
+ page = create(:page, page_type: Qbrick::PageType::REDIRECT, redirect_url: 'en/references', slug: 'news')
268
+ expect(page.link).to eq('/en/news')
270
269
  end
271
270
  end
272
271
 
273
272
  context 'when url part is empty' do
274
273
  it 'strips the trailing slash' do
275
- page = create(:page, page_type: Kuhsaft::PageType::NAVIGATION)
276
- page.link.should eq('/en')
274
+ page = create(:page, page_type: Qbrick::PageType::NAVIGATION)
275
+ expect(page.link).to eq('/en')
277
276
  end
278
277
  end
279
278
  end
@@ -281,13 +280,13 @@ describe Kuhsaft::Page do
281
280
  describe '#navigation?' do
282
281
  context 'when the page_type is navigation' do
283
282
  it 'returns true if the page_type is PageType::NAVIGATION' do
284
- Kuhsaft::Page.new(page_type: Kuhsaft::PageType::NAVIGATION).navigation?.should be_true
283
+ expect(Qbrick::Page.new(page_type: Qbrick::PageType::NAVIGATION).navigation?).to be_truthy
285
284
  end
286
285
  end
287
286
 
288
287
  context 'when the page_type is anything else' do
289
288
  it 'returns false' do
290
- Kuhsaft::Page.new(page_type: Kuhsaft::PageType::REDIRECT).navigation?.should be_false
289
+ expect(Qbrick::Page.new(page_type: Qbrick::PageType::REDIRECT).navigation?).to be_falsey
291
290
  end
292
291
  end
293
292
  end
@@ -295,41 +294,41 @@ describe Kuhsaft::Page do
295
294
  describe '#redirect?' do
296
295
  context 'when the page_type is a redirect' do
297
296
  it 'returns true' do
298
- Kuhsaft::Page.new(page_type: Kuhsaft::PageType::REDIRECT).redirect?.should be_true
297
+ expect(Qbrick::Page.new(page_type: Qbrick::PageType::REDIRECT).redirect?).to be_truthy
299
298
  end
300
299
  end
301
300
 
302
301
  context 'when the page type is anything else' do
303
302
  it 'returns false' do
304
- Kuhsaft::Page.new(page_type: Kuhsaft::PageType::NAVIGATION).redirect?.should be_false
303
+ expect(Qbrick::Page.new(page_type: Qbrick::PageType::NAVIGATION).redirect?).to be_falsey
305
304
  end
306
305
  end
307
306
  end
308
307
 
309
308
  describe 'page types' do
310
309
  it 'returns content by default' do
311
- expect(Kuhsaft::Page.new.page_type).to eq('content')
310
+ expect(Qbrick::Page.new.page_type).to eq('content')
312
311
  end
313
312
 
314
313
  it 'returns navigation if set' do
315
- expect(Kuhsaft::Page.new(page_type: Kuhsaft::PageType::NAVIGATION).page_type).to eq('navigation')
314
+ expect(Qbrick::Page.new(page_type: Qbrick::PageType::NAVIGATION).page_type).to eq('navigation')
316
315
  end
317
316
 
318
317
  it 'returns redirect if set' do
319
- expect(Kuhsaft::Page.new(page_type: Kuhsaft::PageType::REDIRECT).page_type).to eq('redirect')
318
+ expect(Qbrick::Page.new(page_type: Qbrick::PageType::REDIRECT).page_type).to eq('redirect')
320
319
  end
321
320
  end
322
321
 
323
322
  describe '#translated?' do
324
323
  it 'returns true when page is translated' do
325
324
  @page = create(:page, title: 'Page 1', slug: 'page1')
326
- expect(@page.translated?).to be_true
325
+ expect(@page.translated?).to be_truthy
327
326
  end
328
327
 
329
328
  it 'returns false when page has no translation' do
330
329
  @page = create(:page, title: 'Page 1', slug: 'page1')
331
330
  I18n.with_locale :de do
332
- expect(@page.translated?).to be_false
331
+ expect(@page.translated?).to be_falsey
333
332
  end
334
333
  end
335
334
  end
@@ -337,19 +336,19 @@ describe Kuhsaft::Page do
337
336
  describe '#fulltext' do
338
337
  let :page do
339
338
  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')
339
+ p.bricks << Qbrick::TextBrick.new(locale: I18n.locale, text: 'oh la la')
341
340
  p.save
342
341
  end
343
342
  end
344
343
 
345
344
  context 'when saved' do
346
345
  it 'it collects and assigns the fulltext' do
347
- page.should_receive(:collect_fulltext)
346
+ expect(page).to receive(:collect_fulltext)
348
347
  page.save
349
348
  end
350
349
 
351
350
  it 'contains the page part content' do
352
- page.fulltext.should include('oh la la')
351
+ expect(page.fulltext).to include('oh la la')
353
352
  end
354
353
 
355
354
  it 'converts all data to strings' do
@@ -360,10 +359,10 @@ describe Kuhsaft::Page do
360
359
 
361
360
  describe '#before_validation' do
362
361
  it 'generates url automatically' do
363
- page = Kuhsaft::Page.new slug: 'slug'
364
- page.url.should be_nil
362
+ page = Qbrick::Page.new slug: 'slug'
363
+ expect(page.url).to be_nil
365
364
  page.valid?
366
- page.url.should be_present
365
+ expect(page.url).to be_present
367
366
  end
368
367
  end
369
368
 
@@ -373,16 +372,16 @@ describe Kuhsaft::Page do
373
372
  @parent_page = FactoryGirl.create(:page, slug: 'le_parent')
374
373
  @child_page = FactoryGirl.create(:page, slug: 'le_child', parent: @parent_page)
375
374
 
376
- @parent_page.update_attributes(page_type: Kuhsaft::PageType::NAVIGATION)
377
- @child_page.reload.url.should eq("#{I18n.locale}/le_child")
375
+ @parent_page.update_attributes(page_type: Qbrick::PageType::NAVIGATION)
376
+ expect(@child_page.reload.url).to eq("#{I18n.locale}/le_child")
378
377
  end
379
378
 
380
379
  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)
380
+ @parent_page = FactoryGirl.create(:page, slug: 'le_parent', page_type: Qbrick::PageType::NAVIGATION)
382
381
  @child_page = FactoryGirl.create(:page, slug: 'le_child', parent: @parent_page)
383
382
 
384
- @parent_page.update_attributes(page_type: Kuhsaft::PageType::CONTENT)
385
- @child_page.reload.url.should eq("#{I18n.locale}/le_parent/le_child")
383
+ @parent_page.update_attributes(page_type: Qbrick::PageType::CONTENT)
384
+ expect(@child_page.reload.url).to eq("#{I18n.locale}/le_parent/le_child")
386
385
  end
387
386
  end
388
387
  end
@@ -394,17 +393,17 @@ describe Kuhsaft::Page do
394
393
 
395
394
  context 'without parent' do
396
395
  it 'returns url without leading /' do
397
- page.url_without_locale.should_not start_with '/'
396
+ expect(page.url_without_locale).not_to start_with '/'
398
397
  end
399
398
 
400
399
  it 'returns a single slug' do
401
- page.url_without_locale.should == 'page'
400
+ expect(page.url_without_locale).to eq('page')
402
401
  end
403
402
  end
404
403
 
405
404
  context 'when parent is navigation' do
406
405
  let :parent do
407
- create(:page, page_type: Kuhsaft::PageType::NAVIGATION)
406
+ create(:page, page_type: Qbrick::PageType::NAVIGATION)
408
407
  end
409
408
 
410
409
  let :child do
@@ -412,11 +411,11 @@ describe Kuhsaft::Page do
412
411
  end
413
412
 
414
413
  it 'returns url without leading /' do
415
- child.url_without_locale.should_not start_with '/'
414
+ expect(child.url_without_locale).not_to start_with '/'
416
415
  end
417
416
 
418
417
  it 'does not concatenate the parent slug' do
419
- child.url_without_locale.should == 'child'
418
+ expect(child.url_without_locale).to eq('child')
420
419
  end
421
420
  end
422
421
 
@@ -430,11 +429,11 @@ describe Kuhsaft::Page do
430
429
  end
431
430
 
432
431
  it 'returns url without leading /' do
433
- child.url_without_locale.should_not start_with '/'
432
+ expect(child.url_without_locale).not_to start_with '/'
434
433
  end
435
434
 
436
435
  it 'does not concatenate the parent slug' do
437
- child.url_without_locale.should == 'parent/child'
436
+ expect(child.url_without_locale).to eq('parent/child')
438
437
  end
439
438
  end
440
439
  end
@@ -447,13 +446,13 @@ describe Kuhsaft::Page do
447
446
  end
448
447
 
449
448
  it 'returns all pages that have a translation' do
450
- expect(Kuhsaft::Page.translated).to eq [@page_1, @page_2, @page_3]
449
+ expect(Qbrick::Page.translated).to eq [@page_1, @page_2, @page_3]
451
450
  end
452
451
 
453
452
  it 'does not return untranslated pages' do
454
453
  I18n.with_locale :de do
455
454
  @page_1.update(title: 'Page 1 fr', slug: 'page_1_fr')
456
- expect(Kuhsaft::Page.translated).to eq [@page_1]
455
+ expect(Qbrick::Page.translated).to eq [@page_1]
457
456
  end
458
457
  end
459
458
  end
@@ -466,7 +465,48 @@ describe Kuhsaft::Page do
466
465
  end
467
466
 
468
467
  it 'should be findable via scope' do
469
- expect(Kuhsaft::Page.by_identifier(cat_page.identifier)).to eq(cat_page)
468
+ expect(Qbrick::Page.by_identifier(cat_page.identifier)).to eq(cat_page)
469
+ end
470
+ end
471
+
472
+ describe '#cloning' do
473
+ around(:each) do |example|
474
+ I18n.with_locale :de do
475
+ example.run
476
+ end
477
+ end
478
+
479
+ before do
480
+ @page = create(:page)
481
+ end
482
+
483
+ context 'clearing bricks in target locale' do
484
+ it 'does not affect pages other than the target page' do
485
+ another_page = create(:page)
486
+ FactoryGirl.create(:image_brick, brick_list_type: 'Qbrick::Page', brick_list_id: another_page.id)
487
+ expect { @page.clear_bricks_for_locale(:de) }.to_not change { another_page.bricks.count }
488
+ end
489
+ end
490
+
491
+ it 'should copy the asset to the cloned brick' do
492
+ FactoryGirl.create(:image_brick, brick_list_type: 'Qbrick::Page', brick_list_id: @page.id)
493
+
494
+ @page.clone_bricks_to(:en)
495
+ expect(@page.bricks.unscoped.where(locale: :en).first).to be_valid
496
+ end
497
+
498
+ it 'should copy all child bricks' do
499
+ accordion = Qbrick::Brick.create(type: 'Qbrick::AccordionBrick',
500
+ brick_list_type: 'Qbrick::Page',
501
+ brick_list_id: @page.id)
502
+ section = Qbrick::Brick.create(type: 'Qbrick::AccordionItemBrick',
503
+ caption: 'section',
504
+ brick_list_type: 'Qbrick::Brick',
505
+ brick_list_id: accordion.id)
506
+ FactoryGirl.create(:text_brick, brick_list_type: 'Qbrick::Brick', brick_list_id: section.id)
507
+
508
+ @page.clone_bricks_to(:en)
509
+ expect(@page.bricks.unscoped.where(locale: :en).count).to eq(3)
470
510
  end
471
511
  end
472
512
  end