alchemy_cms 2.5.3.1 → 2.6.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (331) hide show
  1. data/.gitignore +1 -1
  2. data/.travis.yml +5 -13
  3. data/Gemfile +6 -3
  4. data/README.md +3 -2
  5. data/alchemy_cms.gemspec +22 -22
  6. data/app/assets/fonts/alchemy-icons.eot +0 -0
  7. data/app/assets/fonts/alchemy-icons.svg +54 -0
  8. data/app/assets/fonts/alchemy-icons.ttf +0 -0
  9. data/app/assets/fonts/alchemy-icons.woff +0 -0
  10. data/app/assets/images/alchemy/icons.png +0 -0
  11. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +151 -0
  12. data/app/assets/javascripts/alchemy/alchemy.buttons.js.coffee +3 -2
  13. data/app/assets/javascripts/alchemy/alchemy.datepicker.js.coffee +31 -0
  14. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +1 -1
  15. data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +98 -0
  16. data/app/assets/javascripts/alchemy/alchemy.elements_window.js.coffee +23 -24
  17. data/app/assets/javascripts/alchemy/alchemy.growler.js.coffee +27 -0
  18. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +11 -8
  19. data/app/assets/javascripts/alchemy/alchemy.hotkeys.js.coffee +32 -0
  20. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee +46 -0
  21. data/app/assets/javascripts/alchemy/alchemy.js +8 -2
  22. data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +5 -4
  23. data/app/assets/javascripts/alchemy/alchemy.list_filter.js.coffee +49 -0
  24. data/app/assets/javascripts/alchemy/alchemy.onload.js.coffee +3 -0
  25. data/app/assets/javascripts/alchemy/alchemy.preview_window.js.coffee +71 -0
  26. data/app/assets/javascripts/alchemy/alchemy.sitemap.js.coffee +61 -0
  27. data/app/assets/javascripts/alchemy/alchemy.spinner.js.coffee +35 -0
  28. data/app/assets/javascripts/alchemy/alchemy.string_extension.js.coffee +11 -0
  29. data/app/assets/javascripts/alchemy/alchemy.windows.js.coffee +278 -0
  30. data/app/assets/stylesheets/alchemy/admin.css.scss +2 -0
  31. data/app/assets/stylesheets/alchemy/archive.scss +109 -65
  32. data/app/assets/stylesheets/alchemy/base.scss +16 -188
  33. data/app/assets/stylesheets/alchemy/dashboard.scss +2 -2
  34. data/app/assets/stylesheets/alchemy/defaults.scss +2 -1
  35. data/app/assets/stylesheets/alchemy/elements.scss +58 -94
  36. data/app/assets/stylesheets/alchemy/errors.scss +2 -2
  37. data/app/assets/stylesheets/alchemy/{mixins.scss → extends.scss} +104 -80
  38. data/app/assets/stylesheets/alchemy/flash.scss +4 -6
  39. data/app/assets/stylesheets/alchemy/fonts.scss +46 -0
  40. data/app/assets/stylesheets/alchemy/form_elements.scss +46 -45
  41. data/app/assets/stylesheets/alchemy/frame.scss +20 -15
  42. data/app/assets/stylesheets/alchemy/icons.scss +22 -9
  43. data/app/assets/stylesheets/alchemy/jquery-ui.scss +476 -399
  44. data/app/assets/stylesheets/alchemy/login.scss +1 -1
  45. data/app/assets/stylesheets/alchemy/menubar.css.scss +1 -1
  46. data/app/assets/stylesheets/alchemy/notices.scss +5 -5
  47. data/app/assets/stylesheets/alchemy/pagination.scss +25 -13
  48. data/app/assets/stylesheets/alchemy/search.scss +29 -17
  49. data/app/assets/stylesheets/alchemy/sitemap.scss +41 -36
  50. data/app/assets/stylesheets/alchemy/tables.scss +102 -50
  51. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +18 -16
  52. data/app/assets/stylesheets/alchemy/toolbar.scss +84 -24
  53. data/app/assets/stylesheets/alchemy/upload.scss +14 -9
  54. data/app/assets/stylesheets/alchemy/variables.scss +1 -0
  55. data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.scss +18 -21
  56. data/app/controllers/alchemy/admin/attachments_controller.rb +29 -39
  57. data/app/controllers/alchemy/admin/base_controller.rb +3 -9
  58. data/app/controllers/alchemy/admin/clipboard_controller.rb +1 -1
  59. data/app/controllers/alchemy/admin/contents_controller.rb +1 -1
  60. data/app/controllers/alchemy/admin/dashboard_controller.rb +1 -1
  61. data/app/controllers/alchemy/admin/elements_controller.rb +3 -3
  62. data/app/controllers/alchemy/admin/essence_files_controller.rb +1 -1
  63. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +5 -5
  64. data/app/controllers/alchemy/admin/languages_controller.rb +1 -1
  65. data/app/controllers/alchemy/admin/pages_controller.rb +18 -16
  66. data/app/controllers/alchemy/admin/pictures_controller.rb +11 -10
  67. data/app/controllers/alchemy/admin/resources_controller.rb +87 -14
  68. data/app/controllers/alchemy/admin/tags_controller.rb +3 -3
  69. data/app/controllers/alchemy/admin/trash_controller.rb +3 -3
  70. data/app/controllers/alchemy/admin/users_controller.rb +6 -11
  71. data/app/controllers/alchemy/attachments_controller.rb +8 -9
  72. data/app/controllers/alchemy/base_controller.rb +17 -10
  73. data/app/controllers/alchemy/pages_controller.rb +7 -19
  74. data/app/controllers/alchemy/passwords_controller.rb +15 -3
  75. data/app/controllers/alchemy/user_sessions_controller.rb +5 -4
  76. data/app/controllers/alchemy/users_controller.rb +1 -1
  77. data/app/helpers/alchemy/admin/attachments_helper.rb +2 -2
  78. data/app/helpers/alchemy/admin/base_helper.rb +62 -90
  79. data/app/helpers/alchemy/admin/elements_helper.rb +13 -5
  80. data/app/helpers/alchemy/admin/essences_helper.rb +3 -5
  81. data/app/helpers/alchemy/admin/pages_helper.rb +6 -3
  82. data/app/helpers/alchemy/admin/tags_helper.rb +60 -0
  83. data/app/helpers/alchemy/base_helper.rb +16 -20
  84. data/app/helpers/alchemy/elements_helper.rb +7 -11
  85. data/app/helpers/alchemy/essences_helper.rb +2 -2
  86. data/app/helpers/alchemy/pages_helper.rb +31 -69
  87. data/app/helpers/alchemy/url_helper.rb +11 -3
  88. data/app/models/alchemy/attachment.rb +73 -45
  89. data/app/models/alchemy/cell.rb +1 -1
  90. data/app/models/alchemy/content.rb +20 -9
  91. data/app/models/alchemy/element.rb +9 -7
  92. data/app/models/alchemy/page.rb +15 -248
  93. data/app/models/alchemy/page/cells.rb +71 -0
  94. data/app/models/alchemy/page/elements.rb +147 -0
  95. data/app/models/alchemy/page/naming.rb +90 -0
  96. data/app/models/alchemy/picture.rb +18 -13
  97. data/app/models/alchemy/tag.rb +1 -1
  98. data/app/models/alchemy/user.rb +38 -6
  99. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +14 -7
  100. data/app/views/alchemy/admin/attachments/_attachment.html.erb +17 -12
  101. data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +3 -8
  102. data/app/views/alchemy/admin/attachments/_files_list.html.erb +20 -12
  103. data/app/views/alchemy/admin/attachments/_overlay_file_list.html.erb +11 -0
  104. data/app/views/alchemy/admin/attachments/_tag_list.html.erb +31 -0
  105. data/app/views/alchemy/admin/attachments/archive_overlay.js.erb +4 -0
  106. data/app/views/alchemy/admin/attachments/edit.html.erb +8 -7
  107. data/app/views/alchemy/admin/attachments/index.html.erb +19 -12
  108. data/app/views/alchemy/admin/attachments/new.html.erb +2 -2
  109. data/app/views/alchemy/admin/attachments/show.html.erb +3 -0
  110. data/app/views/alchemy/admin/contents/_missing.html.erb +4 -4
  111. data/app/views/alchemy/admin/contents/create.js.erb +1 -1
  112. data/app/views/alchemy/admin/contents/new.html.erb +6 -3
  113. data/app/views/alchemy/admin/dashboard/_locked_pages.html.erb +1 -1
  114. data/app/views/alchemy/admin/dashboard/_users.html.erb +1 -1
  115. data/app/views/alchemy/admin/dashboard/index.html.erb +3 -3
  116. data/app/views/alchemy/admin/dashboard/info.html.erb +16 -13
  117. data/app/views/alchemy/admin/elements/_add_picture.html.erb +1 -1
  118. data/app/views/alchemy/admin/elements/_element_foot.html.erb +4 -4
  119. data/app/views/alchemy/admin/elements/_element_head.html.erb +1 -7
  120. data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -2
  121. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +4 -4
  122. data/app/views/alchemy/admin/elements/_picture_gallery_editor.html.erb +1 -1
  123. data/app/views/alchemy/admin/elements/create.js.erb +2 -2
  124. data/app/views/alchemy/admin/elements/fold.js.erb +3 -6
  125. data/app/views/alchemy/admin/elements/new.html.erb +1 -1
  126. data/app/views/alchemy/admin/elements/order.js.erb +1 -1
  127. data/app/views/alchemy/admin/elements/trash.js.erb +1 -1
  128. data/app/views/alchemy/admin/elements/update.js.erb +2 -2
  129. data/app/views/alchemy/admin/essence_files/edit.html.erb +4 -4
  130. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +17 -18
  131. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +2 -2
  132. data/app/views/alchemy/admin/essence_pictures/update.js.erb +1 -0
  133. data/app/views/alchemy/admin/languages/_form.html.erb +12 -10
  134. data/app/views/alchemy/admin/languages/_language.html.erb +2 -1
  135. data/app/views/alchemy/admin/languages/_table.html.erb +3 -3
  136. data/app/views/alchemy/admin/languages/index.html.erb +15 -15
  137. data/app/views/alchemy/admin/layoutpages/_layoutpage.html.erb +6 -6
  138. data/app/views/alchemy/admin/layoutpages/index.html.erb +41 -40
  139. data/app/views/alchemy/admin/pages/_contactform_links.html.erb +4 -4
  140. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +6 -6
  141. data/app/views/alchemy/admin/pages/_external_link.html.erb +2 -2
  142. data/app/views/alchemy/admin/pages/_file_link.html.erb +3 -3
  143. data/app/views/alchemy/admin/pages/_internal_link.html.erb +1 -1
  144. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
  145. data/app/views/alchemy/admin/pages/_page.html.erb +13 -13
  146. data/app/views/alchemy/admin/pages/_page_for_links.html.erb +2 -4
  147. data/app/views/alchemy/admin/pages/_sitemap.html.erb +5 -0
  148. data/app/views/alchemy/admin/pages/configure.html.erb +7 -7
  149. data/app/views/alchemy/admin/pages/configure_external.html.erb +4 -4
  150. data/app/views/alchemy/admin/pages/edit.html.erb +23 -30
  151. data/app/views/alchemy/admin/pages/index.html.erb +34 -23
  152. data/app/views/alchemy/admin/pages/new.html.erb +1 -1
  153. data/app/views/alchemy/admin/pages/sort.js.erb +1 -1
  154. data/app/views/alchemy/admin/partials/_flash_upload.html.erb +2 -3
  155. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +2 -2
  156. data/app/views/alchemy/admin/partials/_search_form.html.erb +3 -3
  157. data/app/views/alchemy/admin/partials/_upload_form.html.erb +2 -2
  158. data/app/views/alchemy/admin/pictures/_archive.html.erb +7 -7
  159. data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +1 -1
  160. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +6 -6
  161. data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +4 -4
  162. data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +1 -1
  163. data/app/views/alchemy/admin/pictures/_picture.html.erb +3 -8
  164. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +9 -14
  165. data/app/views/alchemy/admin/pictures/_tag_list.html.erb +27 -25
  166. data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +3 -1
  167. data/app/views/alchemy/admin/pictures/index.html.erb +49 -42
  168. data/app/views/alchemy/admin/pictures/new.html.erb +2 -2
  169. data/app/views/alchemy/admin/pictures/show.html.erb +11 -0
  170. data/app/views/alchemy/admin/resources/_boolean.html.erb +2 -2
  171. data/app/views/alchemy/admin/resources/_datetime.html.erb +2 -2
  172. data/app/views/alchemy/admin/resources/_form.html.erb +9 -8
  173. data/app/views/alchemy/admin/resources/_resource.html.erb +15 -21
  174. data/app/views/alchemy/admin/resources/_string.html.erb +2 -2
  175. data/app/views/alchemy/admin/resources/_table.html.erb +11 -13
  176. data/app/views/alchemy/admin/resources/_text.html.erb +2 -2
  177. data/app/views/alchemy/admin/resources/index.csv.erb +13 -0
  178. data/app/views/alchemy/admin/resources/index.html.erb +24 -15
  179. data/app/views/alchemy/admin/sites/index.html.erb +23 -0
  180. data/app/views/alchemy/admin/tags/_radio_tag.html.erb +1 -1
  181. data/app/views/alchemy/admin/tags/_tag.html.erb +2 -1
  182. data/app/views/alchemy/admin/tags/edit.html.erb +1 -1
  183. data/app/views/alchemy/admin/tags/index.html.erb +16 -11
  184. data/app/views/alchemy/admin/tags/new.html.erb +3 -3
  185. data/app/views/alchemy/admin/trash/clear.js.coffee +1 -1
  186. data/app/views/alchemy/admin/users/_table.html.erb +12 -5
  187. data/app/views/alchemy/admin/users/_user.html.erb +16 -16
  188. data/app/views/alchemy/admin/users/index.html.erb +28 -16
  189. data/app/views/alchemy/breadcrumb/_page.html.erb +15 -0
  190. data/app/views/alchemy/breadcrumb/_spacer.html.erb +1 -0
  191. data/app/views/alchemy/elements/_editor_not_found.html.erb +1 -1
  192. data/app/views/alchemy/essences/_essence_file_editor.html.erb +16 -16
  193. data/app/views/alchemy/essences/_essence_file_view.html.erb +8 -9
  194. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +3 -6
  195. data/app/views/alchemy/essences/_essence_picture_tools.html.erb +9 -8
  196. data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +0 -5
  197. data/app/views/alchemy/essences/_linkable_essence_tools.html.erb +2 -2
  198. data/app/views/alchemy/navigation/_link.html.erb +7 -7
  199. data/app/views/alchemy/navigation/_renderer.html.erb +29 -36
  200. data/app/views/alchemy/notifications/admin_user_created.de.text.erb +5 -1
  201. data/app/views/alchemy/notifications/admin_user_created.en.text.erb +5 -1
  202. data/app/views/alchemy/notifications/registered_user_created.de.text.erb +13 -0
  203. data/app/views/alchemy/notifications/registered_user_created.en.text.erb +13 -0
  204. data/app/views/alchemy/search/_result.html.erb +4 -6
  205. data/app/views/alchemy/search/_results.html.erb +4 -5
  206. data/app/views/alchemy/user_sessions/leave.html.erb +1 -1
  207. data/app/views/alchemy/user_sessions/new.html.erb +2 -2
  208. data/app/views/kaminari/_first_page.html.erb +11 -0
  209. data/app/views/kaminari/_gap.html.erb +1 -1
  210. data/app/views/kaminari/_last_page.html.erb +11 -0
  211. data/app/views/kaminari/_next_page.html.erb +2 -2
  212. data/app/views/kaminari/_page.html.erb +1 -1
  213. data/app/views/kaminari/_paginator.html.erb +2 -0
  214. data/app/views/kaminari/_prev_page.html.erb +2 -2
  215. data/app/views/layouts/alchemy/admin.html.erb +4 -5
  216. data/config/alchemy/config.yml +8 -12
  217. data/config/authorization_rules.rb +4 -3
  218. data/config/initializers/dragonfly.rb +20 -12
  219. data/config/locales/alchemy.de.yml +20 -15
  220. data/config/locales/alchemy.en.yml +15 -10
  221. data/config/locales/devise.de.yml +1 -0
  222. data/config/routes.rb +3 -3
  223. data/{spec/dummy/db/migrate/20121118000000_alchemy_two_point_four.rb → db/migrate/20130214233001_alchemy_two_point_five.rb} +50 -36
  224. data/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +21 -0
  225. data/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +11 -0
  226. data/lib/alchemy/capistrano.rb +10 -8
  227. data/lib/alchemy/errors.rb +7 -0
  228. data/lib/alchemy/filetypes.rb +33 -0
  229. data/lib/alchemy/i18n.rb +9 -1
  230. data/lib/alchemy/name_conversions.rb +28 -0
  231. data/lib/alchemy/page_layout.rb +5 -3
  232. data/lib/alchemy/resource.rb +132 -29
  233. data/lib/alchemy/resources_helper.rb +81 -12
  234. data/lib/alchemy/upgrader.rb +14 -276
  235. data/lib/alchemy/version.rb +1 -1
  236. data/lib/alchemy_cms.rb +17 -2
  237. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +1 -1
  238. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +1 -1
  239. data/lib/tasks/alchemy/convert.rake +39 -0
  240. data/lib/tasks/alchemy/install.rake +4 -6
  241. data/lib/tasks/alchemy/upgrade.rake +18 -1
  242. data/spec/controllers/admin/clipboard_controller_spec.rb +4 -4
  243. data/spec/controllers/admin/elements_controller_spec.rb +23 -23
  244. data/spec/controllers/admin/pages_controller_spec.rb +15 -0
  245. data/spec/controllers/admin/resources_controller_spec.rb +1 -11
  246. data/spec/controllers/admin/trash_controller_spec.rb +9 -9
  247. data/spec/controllers/attachments_controller_spec.rb +3 -3
  248. data/spec/controllers/elements_controller_spec.rb +2 -2
  249. data/spec/controllers/pages_controller_spec.rb +160 -129
  250. data/spec/controllers/pictures_controller_spec.rb +2 -2
  251. data/spec/controllers/user_sessions_controller_spec.rb +3 -3
  252. data/spec/controllers/users_controller_spec.rb +2 -2
  253. data/spec/dummy/app/models/event.rb +2 -2
  254. data/spec/dummy/app/models/location.rb +4 -0
  255. data/spec/dummy/app/views/layouts/application.html.erb +6 -42
  256. data/spec/dummy/config/routes.rb +1 -1
  257. data/spec/dummy/db/migrate/20121026104128_create_events.rb +0 -1
  258. data/{db/migrate/20121118000000_alchemy_two_point_four.rb → spec/dummy/db/migrate/20130214233001_alchemy_two_point_five.rb} +50 -36
  259. data/spec/dummy/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +21 -0
  260. data/spec/dummy/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +11 -0
  261. data/spec/dummy/db/migrate/20130328101418_create_locations.rb +9 -0
  262. data/spec/dummy/db/schema.rb +15 -6
  263. data/spec/factories.rb +4 -4
  264. data/spec/{integration → features}/admin/link_overlay_spec.rb +0 -0
  265. data/spec/{integration → features}/admin/modules_integration_spec.rb +1 -1
  266. data/spec/{integration → features}/admin/pages_controller_spec.rb +9 -4
  267. data/spec/{integration → features}/admin/picture_library_integration_spec.rb +5 -5
  268. data/spec/{integration → features}/admin/resources_integration_spec.rb +1 -1
  269. data/spec/{integration → features}/navigation_spec.rb +0 -0
  270. data/spec/{integration → features}/pages_controller_spec.rb +42 -112
  271. data/spec/{integration → features}/picture_security_spec.rb +2 -2
  272. data/spec/{integration → features}/security_spec.rb +7 -7
  273. data/spec/{integration → features}/translation_integration_spec.rb +0 -0
  274. data/spec/helpers/admin/base_helper_spec.rb +0 -50
  275. data/spec/helpers/admin/tags_helper_spec.rb +53 -0
  276. data/spec/helpers/base_helper_spec.rb +19 -3
  277. data/spec/helpers/pages_helper_spec.rb +92 -44
  278. data/spec/{url_helpers_spec.rb → helpers/picture_url_helpers_spec.rb} +7 -7
  279. data/spec/helpers/url_helper_spec.rb +92 -72
  280. data/spec/{config_spec.rb → libraries/config_spec.rb} +0 -0
  281. data/spec/libraries/resource_spec.rb +215 -76
  282. data/spec/libraries/resources_helper_spec.rb +70 -28
  283. data/spec/models/attachment_spec.rb +75 -9
  284. data/spec/models/clipboard_spec.rb +1 -1
  285. data/spec/models/element_spec.rb +7 -0
  286. data/spec/models/page_spec.rb +144 -25
  287. data/spec/models/picture_spec.rb +5 -5
  288. data/spec/models/resource_spec.rb +47 -10
  289. data/spec/models/user_spec.rb +115 -3
  290. data/spec/{routing_spec.rb → routing/routing_spec.rb} +8 -20
  291. data/spec/spec_helper.rb +5 -6
  292. data/spec/support/alchemy/specs_helpers.rb +1 -1
  293. data/spec/support/ci/install_phantomjs +1 -1
  294. data/spec/support/image with spaces.png +0 -0
  295. data/vendor/assets/javascripts/jquery_plugins/jquery.Jcrop.min.js +18 -18
  296. data/vendor/assets/javascripts/jquery_plugins/{jquery.dialogextend.1_0_1.js → jquery.dialogextend.js} +25 -17
  297. data/vendor/assets/javascripts/jquery_plugins/jquery.scrollTo.min.js +7 -0
  298. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.tabspaging.js +7 -7
  299. data/vendor/assets/javascripts/keymage.min.js +6 -0
  300. data/vendor/assets/javascripts/spin.min.js +1 -0
  301. metadata +122 -124
  302. data/app/assets/images/alchemy/ajax_loader.gif +0 -0
  303. data/app/assets/images/alchemy/gui/toggle.png +0 -0
  304. data/app/assets/images/alchemy/image_loader.gif +0 -0
  305. data/app/assets/images/alchemy/shading.png +0 -0
  306. data/app/assets/images/alchemy/tabs.gif +0 -0
  307. data/app/assets/javascripts/alchemy/alchemy.base.js +0 -172
  308. data/app/assets/javascripts/alchemy/alchemy.datepicker.js +0 -47
  309. data/app/assets/javascripts/alchemy/alchemy.element_editor_selector.js +0 -91
  310. data/app/assets/javascripts/alchemy/alchemy.growler.js +0 -46
  311. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js +0 -60
  312. data/app/assets/javascripts/alchemy/alchemy.js_extensions.js +0 -15
  313. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +0 -97
  314. data/app/assets/javascripts/alchemy/alchemy.windows.js +0 -321
  315. data/app/models/alchemy/clipboard_spec.rb +0 -0
  316. data/app/views/alchemy/admin/pictures/show_in_window.html.erb +0 -8
  317. data/app/views/alchemy/notifications/registered_user_created.text.erb +0 -11
  318. data/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb +0 -21
  319. data/db/migrate/20121205155004_create_alchemy_sites.rb +0 -14
  320. data/db/migrate/20121211163003_add_public_to_alchemy_sites.rb +0 -6
  321. data/db/migrate/20121220102223_add_aliases_to_site.rb +0 -6
  322. data/db/migrate/20130110212411_create_alchemy_legacy_page_urls.rb +0 -11
  323. data/db/migrate/20130121092645_migrate_to_devise.rb +0 -24
  324. data/spec/alchemy_spec.rb +0 -7
  325. data/spec/dummy/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb +0 -21
  326. data/spec/dummy/db/migrate/20121205155004_create_alchemy_sites.rb +0 -14
  327. data/spec/dummy/db/migrate/20121211163003_add_public_to_alchemy_sites.rb +0 -6
  328. data/spec/dummy/db/migrate/20121220102223_add_aliases_to_site.rb +0 -6
  329. data/spec/dummy/db/migrate/20130110212411_create_alchemy_legacy_page_urls.rb +0 -11
  330. data/spec/dummy/db/migrate/20130121092645_migrate_to_devise.rb +0 -24
  331. data/vendor/assets/javascripts/jquery_plugins/jquery.scrollTo-1.4.2-min.js +0 -11
@@ -1,6 +1,6 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.5.3.1"
3
+ VERSION = "2.6.0.rc5"
4
4
 
5
5
  def self.version
6
6
  VERSION
@@ -3,7 +3,6 @@ require 'rails'
3
3
  if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 2
4
4
  require 'acts_as_list'
5
5
  require 'acts-as-taggable-on'
6
- require 'attachment_magic'
7
6
  require 'devise'
8
7
  require 'devise-encryptable'
9
8
  require 'awesome_nested_set'
@@ -12,6 +11,7 @@ if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 2
12
11
  require 'jquery-rails'
13
12
  require 'jquery-ui-rails'
14
13
  require 'rails3-jquery-autocomplete'
14
+ require 'handles_sortable_columns'
15
15
  require 'kaminari'
16
16
  require 'userstamp'
17
17
  require 'yaml'
@@ -28,7 +28,22 @@ if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 2
28
28
  require 'alchemy/auth_engine'
29
29
  require 'alchemy/engine'
30
30
  require 'alchemy/picture_attributes'
31
- %w(config logger errors essence page_layout modules tinymce i18n scoped_pagination_url_helper resource resources_helper ferret_search).each do |class_name|
31
+ [
32
+ 'config',
33
+ 'logger',
34
+ 'errors',
35
+ 'essence',
36
+ 'page_layout',
37
+ 'modules',
38
+ 'tinymce',
39
+ 'i18n',
40
+ 'scoped_pagination_url_helper',
41
+ 'resource',
42
+ 'resources_helper',
43
+ 'ferret_search',
44
+ 'filetypes',
45
+ 'name_conversions'
46
+ ].each do |class_name|
32
47
  require File.join(File.dirname(__FILE__), "alchemy", class_name)
33
48
  end
34
49
  require File.join(File.dirname(__FILE__), "alchemy", "seeder")
@@ -94,7 +94,7 @@ namespace :deploy do
94
94
 
95
95
  desc 'Seeds the database'
96
96
  task :seed, :roles => :app, :except => { :no_release => true } do
97
- run "cd #{release_path} && RAILS_ENV=#{rails_env} #{rake} db:seed"
97
+ run "cd #{release_path} #{rake} && RAILS_ENV=#{rails_env} db:seed"
98
98
  end
99
99
 
100
100
  end
@@ -37,7 +37,7 @@ module Alchemy
37
37
  end
38
38
 
39
39
  def copy_alchemy_views
40
- %w(messages navigation notifications search).each do |dir|
40
+ %w(breadcrumb messages navigation notifications search).each do |dir|
41
41
  src = File.expand_path("../../../../../app/views/alchemy/#{dir}", File.dirname(__FILE__))
42
42
  dest = Rails.root.join('app/views/alchemy', dir)
43
43
  directory src, dest
@@ -0,0 +1,39 @@
1
+ namespace :alchemy do
2
+ namespace :convert do
3
+
4
+ namespace :urlnames do
5
+
6
+ desc "Converts the urlname of all pages to nested url paths."
7
+ task :to_nested => [:environment] do
8
+ unless Alchemy::Config.get(:url_nesting)
9
+ raise "\nURL nesting is disabled! Please enable url_nesting in `config/alchemy/config.yml` first.\n\n"
10
+ end
11
+ puts "Converting..."
12
+ pages = Alchemy::Page.contentpages
13
+ count = pages.count
14
+ pages.each_with_index do |page, n|
15
+ puts "Updating page #{n+1} of #{count}"
16
+ page.update_urlname!
17
+ end
18
+ puts "Done."
19
+ end
20
+
21
+ desc "Converts the urlname of all pages to contain the slug only."
22
+ task :to_slug => [:environment] do
23
+ if Alchemy::Config.get(:url_nesting)
24
+ raise "\nURL nesting is enabled! Please disable url_nesting in `config/alchemy/config.yml` first.\n\n"
25
+ end
26
+ puts "Converting..."
27
+ pages = Alchemy::Page.contentpages
28
+ count = pages.count
29
+ pages.each_with_index do |page, n|
30
+ puts "Updating page #{n+1} of #{count}"
31
+ page.update_attribute :urlname, page.slug
32
+ end
33
+ puts "Done."
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+ end
@@ -17,14 +17,12 @@ end
17
17
 
18
18
  namespace :alchemy do
19
19
 
20
+ desc "Creates, migrates and seeds the database to run Alchemy."
21
+ task :prepare => ["db:create", "alchemy:install:migrations", "db:migrate", "alchemy:db:seed"]
22
+
20
23
  desc "Installs Alchemy CMS into your app."
21
- task :install do
22
- Rake::Task["db:create"].invoke
23
- Rake::Task["alchemy:install:migrations"].invoke
24
- Rake::Task["alchemy:mount"].invoke
24
+ task :install => ["alchemy:prepare", "alchemy:mount"] do
25
25
  system("rails g alchemy:scaffold")
26
- Rake::Task["db:migrate"].invoke
27
- Rake::Task["alchemy:db:seed"].invoke
28
26
  puts <<-EOF
29
27
 
30
28
  \\o/ Successfully installed Alchemy CMS \\o/
@@ -2,9 +2,26 @@ require File.join(File.dirname(__FILE__), '../../alchemy/upgrader.rb')
2
2
 
3
3
  namespace :alchemy do
4
4
 
5
- desc "Upgrades database to Alchemy CMS v#{Alchemy::VERSION}."
5
+ desc "Upgrades database content to Alchemy CMS v#{Alchemy::VERSION} (Set UPGRADE env variable to only run a specific task)."
6
6
  task :upgrade => :environment do
7
7
  Alchemy::Upgrader.run!
8
8
  end
9
9
 
10
+ namespace :upgrade do
11
+ desc "List all available upgrade tasks."
12
+ task :list => [:environment] do
13
+ puts "\nAvailable upgrade tasks"
14
+ puts "-----------------------\n"
15
+ methods = (Alchemy::Upgrader.private_methods - Object.private_methods - Alchemy::Upgrader.superclass.private_methods)
16
+ if methods.any?
17
+ methods.each { |method| puts method }
18
+ puts "\nUsage:"
19
+ puts "------"
20
+ puts "Run one or more tasks with `bundle exec rake alchemy:upgrade UPGRADE=task_name1,task_name2`\n"
21
+ else
22
+ puts "No upgrades available."
23
+ end
24
+ end
25
+ end
26
+
10
27
  end
@@ -3,9 +3,9 @@ require 'spec_helper'
3
3
  module Alchemy
4
4
  describe Admin::ClipboardController do
5
5
 
6
- let(:page) { FactoryGirl.create(:public_page) }
7
- let(:element) { FactoryGirl.create(:element, :page => page) }
8
- let(:another_element) { FactoryGirl.create(:element, :page => page) }
6
+ let(:public_page) { FactoryGirl.create(:public_page) }
7
+ let(:element) { FactoryGirl.create(:element, :page => public_page) }
8
+ let(:another_element) { FactoryGirl.create(:element, :page => public_page) }
9
9
 
10
10
  before do
11
11
  sign_in :user, FactoryGirl.create(:admin_user)
@@ -48,7 +48,7 @@ module Alchemy
48
48
 
49
49
  context "with pages as remarkable_type" do
50
50
  it "should clear the pages clipboard" do
51
- session[:clipboard][:pages] = {:id => page.id}
51
+ session[:clipboard][:pages] = {:id => public_page.id}
52
52
  delete(:clear, {:remarkable_type => :pages, :format => :js})
53
53
  session[:clipboard].should be_empty
54
54
  end
@@ -7,9 +7,9 @@ module Alchemy
7
7
  sign_in :user, FactoryGirl.create(:admin_user)
8
8
  end
9
9
 
10
- let(:page) { FactoryGirl.create(:page, :urlname => 'lulu') }
11
- let(:element) { FactoryGirl.create(:element, :page_id => page.id) }
12
- let(:element_in_clipboard) { FactoryGirl.create(:element, :page_id => page.id) }
10
+ let(:alchemy_page) { FactoryGirl.create(:page, :urlname => 'lulu') }
11
+ let(:element) { FactoryGirl.create(:element, :page_id => alchemy_page.id) }
12
+ let(:element_in_clipboard) { FactoryGirl.create(:element, :page_id => alchemy_page.id) }
13
13
  let(:clipboard) { session[:clipboard] = Clipboard.new }
14
14
 
15
15
  describe '#create' do
@@ -17,9 +17,9 @@ module Alchemy
17
17
  before { element }
18
18
 
19
19
  it "should insert the element at bottom of list" do
20
- post :create, {:element => {:name => 'news', :page_id => page.id}, :format => :js}
21
- page.elements.count.should == 2
22
- page.elements.last.name.should == 'news'
20
+ post :create, {:element => {:name => 'news', :page_id => alchemy_page.id}, :format => :js}
21
+ alchemy_page.elements.count.should == 2
22
+ alchemy_page.elements.last.name.should == 'news'
23
23
  end
24
24
 
25
25
  context "on a page with a setting for insert_elements_at of top" do
@@ -33,9 +33,9 @@ module Alchemy
33
33
  end
34
34
 
35
35
  it "should insert the element at top of list" do
36
- post :create, {:element => {:name => 'news', :page_id => page.id}, :format => :js}
37
- page.elements.count.should == 2
38
- page.elements.first.name.should == 'news'
36
+ post :create, {:element => {:name => 'news', :page_id => alchemy_page.id}, :format => :js}
37
+ alchemy_page.elements.count.should == 2
38
+ alchemy_page.elements.first.name.should == 'news'
39
39
  end
40
40
  end
41
41
  end
@@ -44,7 +44,7 @@ module Alchemy
44
44
 
45
45
  before do
46
46
  Cell.stub!(:definition_for).and_return({'name' => 'header', 'elements' => ['header']})
47
- controller.instance_variable_set(:@page, page)
47
+ controller.instance_variable_set(:@page, alchemy_page)
48
48
  end
49
49
 
50
50
  context "with element name and cell name in the params" do
@@ -59,18 +59,18 @@ module Alchemy
59
59
  it "should create the cell" do
60
60
  expect {
61
61
  controller.send(:find_or_create_cell)
62
- }.to change(page.cells, :count).from(0).to(1)
62
+ }.to change(alchemy_page.cells, :count).from(0).to(1)
63
63
  end
64
64
  end
65
65
 
66
66
  context "with the cell already present" do
67
67
 
68
- before { FactoryGirl.create(:cell, :page => page, :name => 'header') }
68
+ before { FactoryGirl.create(:cell, :page => alchemy_page, :name => 'header') }
69
69
 
70
70
  it "should load the cell" do
71
71
  expect {
72
72
  controller.send(:find_or_create_cell)
73
- }.to_not change(page.cells, :count)
73
+ }.to_not change(alchemy_page.cells, :count)
74
74
  end
75
75
 
76
76
  end
@@ -98,9 +98,9 @@ module Alchemy
98
98
  render_views
99
99
 
100
100
  it "should return a select tag with elements" do
101
- Alchemy::Page.should_receive(:find_by_urlname_and_language_id).and_return(page)
101
+ Alchemy::Page.should_receive(:find_by_urlname_and_language_id).and_return(alchemy_page)
102
102
  Alchemy::Element.stub_chain([:published, :find_all_by_page_id]).and_return([element])
103
- get :list, {:page_urlname => page.urlname, :format => :js}
103
+ get :list, {:page_urlname => alchemy_page.urlname, :format => :js}
104
104
  response.body.should match(/select(.*)elements_from_page_selector(.*)option/)
105
105
  end
106
106
 
@@ -145,7 +145,7 @@ module Alchemy
145
145
  end
146
146
 
147
147
  it "should load all elements from clipboard" do
148
- get :new, {:page_id => page.id, :format => :js}
148
+ get :new, {:page_id => alchemy_page.id, :format => :js}
149
149
  assigns(:clipboard_items).should be_kind_of(Array)
150
150
  end
151
151
 
@@ -232,10 +232,10 @@ module Alchemy
232
232
  end
233
233
 
234
234
  context "on a page with a setting for insert_elements_at of top" do
235
- let(:page) { FactoryGirl.create(:public_page, :name => 'News') }
236
- let(:element_in_clipboard) { FactoryGirl.create(:element, :page => page, :name => 'news') }
237
- let(:cell) { page.cells.first }
238
- let(:element) { FactoryGirl.create(:element, :name => 'news', :page => page, :cell => cell) }
235
+ let(:alchemy_page) { FactoryGirl.create(:public_page, :name => 'News') }
236
+ let(:element_in_clipboard) { FactoryGirl.create(:element, :page => alchemy_page, :name => 'news') }
237
+ let(:cell) { alchemy_page.cells.first }
238
+ let(:element) { FactoryGirl.create(:element, :name => 'news', :page => alchemy_page, :cell => cell) }
239
239
 
240
240
  before do
241
241
  PageLayout.stub(:get).and_return({
@@ -250,7 +250,7 @@ module Alchemy
250
250
  end
251
251
 
252
252
  it "should insert the element at top of list" do
253
- post :create, {:element => {:name => 'news', :page_id => page.id}, :paste_from_clipboard => "#{element_in_clipboard.id}##{cell.name}", :format => :js}
253
+ post :create, {:element => {:name => 'news', :page_id => alchemy_page.id}, :paste_from_clipboard => "#{element_in_clipboard.id}##{cell.name}", :format => :js}
254
254
  cell.elements.count.should == 2
255
255
  cell.elements.first.name.should == 'news'
256
256
  cell.elements.first.should_not == element
@@ -270,7 +270,7 @@ module Alchemy
270
270
  end
271
271
 
272
272
  it "should create an element from clipboard" do
273
- post :create, {:paste_from_clipboard => element_in_clipboard.id, :element => {:page_id => page.id}, :format => :js}
273
+ post :create, {:paste_from_clipboard => element_in_clipboard.id, :element => {:page_id => alchemy_page.id}, :format => :js}
274
274
  response.status.should == 200
275
275
  response.body.should match(/Succesfully added new element/)
276
276
  end
@@ -278,7 +278,7 @@ module Alchemy
278
278
  context "and with cut as action parameter" do
279
279
 
280
280
  it "should also remove the element id from clipboard" do
281
- post :create, {:paste_from_clipboard => element_in_clipboard.id, :element => {:page_id => page.id}, :format => :js}
281
+ post :create, {:paste_from_clipboard => element_in_clipboard.id, :element => {:page_id => alchemy_page.id}, :format => :js}
282
282
  session[:clipboard].contains?(:elements, element_in_clipboard.id).should_not be_true
283
283
  end
284
284
 
@@ -1,3 +1,4 @@
1
+ require 'ostruct'
1
2
  require 'spec_helper'
2
3
 
3
4
  module Alchemy
@@ -36,6 +37,20 @@ module Alchemy
36
37
 
37
38
  end
38
39
 
40
+ describe "#configure" do
41
+ render_views
42
+
43
+ context "with page having nested urlname" do
44
+ let(:page) { mock_model(Page, {name: 'Foobar', slug: 'foobar', urlname: 'root/parent/foobar', redirects_to_external?: false, layoutpage?: false, taggable?: false}) }
45
+
46
+ it "should always show the slug" do
47
+ Page.stub!(:find).and_return(page)
48
+ get :configure, {:id => page.id, :format => :js}
49
+ response.body.should match /value="foobar"/
50
+ end
51
+ end
52
+ end
53
+
39
54
  describe '#create' do
40
55
 
41
56
  let(:parent) { FactoryGirl.create(:public_page) }
@@ -1,14 +1,4 @@
1
- require File.dirname(__FILE__) + "/../../../lib/alchemy/resource"
2
- require File.dirname(__FILE__) + "/../../../lib/alchemy/resources_helper"
3
-
4
- module Alchemy
5
- module Admin
6
- class ResourcesController
7
- helper Alchemy::ResourcesHelper
8
- end
9
- end
10
- end
11
-
1
+ require "spec_helper"
12
2
 
13
3
  describe Alchemy::Admin::ResourcesController do
14
4
  describe "index" do
@@ -7,12 +7,12 @@ module Alchemy
7
7
 
8
8
  render_views
9
9
 
10
- let(:page) do
10
+ let(:alchemy_page) do
11
11
  FactoryGirl.create(:page, :parent_id => Page.rootpage.id)
12
12
  end
13
13
 
14
14
  let(:element) do
15
- FactoryGirl.create(:element, :public => false, :page => page)
15
+ FactoryGirl.create(:element, :public => false, :page => alchemy_page)
16
16
  end
17
17
 
18
18
  before do
@@ -21,13 +21,13 @@ module Alchemy
21
21
  end
22
22
 
23
23
  it "should hold trashed elements" do
24
- get :index, :page_id => page.id
24
+ get :index, :page_id => alchemy_page.id
25
25
  response.body.should have_selector("#element_#{element.id}.element_editor")
26
26
  end
27
27
 
28
28
  it "should not hold elements that are not trashed" do
29
- element = FactoryGirl.create(:element, :page => page, :public => false)
30
- get :index, :page_id => page.id
29
+ element = FactoryGirl.create(:element, :page => alchemy_page, :public => false)
30
+ get :index, :page_id => alchemy_page.id
31
31
  response.body.should_not have_selector("#element_#{element.id}.element_editor")
32
32
  end
33
33
 
@@ -42,7 +42,7 @@ module Alchemy
42
42
  context "and no unique elements on the page" do
43
43
 
44
44
  it "unique elements should be draggable" do
45
- get :index, :page_id => page.id
45
+ get :index, :page_id => alchemy_page.id
46
46
  response.body.should have_selector("#element_#{element.id}.element_editor.draggable")
47
47
  end
48
48
 
@@ -51,8 +51,8 @@ module Alchemy
51
51
  context "and with an unique element on the page" do
52
52
 
53
53
  it "unique elements should not be draggable" do
54
- FactoryGirl.create(:element, :page => page, :public => false)
55
- get :index, :page_id => page.id
54
+ FactoryGirl.create(:element, :page => alchemy_page, :public => false)
55
+ get :index, :page_id => alchemy_page.id
56
56
  response.body.should have_selector("#element_#{element.id}.element_editor.not-draggable")
57
57
  end
58
58
 
@@ -63,7 +63,7 @@ module Alchemy
63
63
  context "#clear" do
64
64
 
65
65
  it "should destroy all containing elements" do
66
- post :clear, {:page_id => page.id, :format => :js}
66
+ post :clear, {:page_id => alchemy_page.id, :format => :js}
67
67
  Element.trashed.should be_empty
68
68
  end
69
69
 
@@ -8,9 +8,9 @@ end
8
8
  module Alchemy
9
9
  describe AttachmentsController do
10
10
 
11
- let(:page) { FactoryGirl.create(:public_page, :restricted => true) }
12
- let(:element) { FactoryGirl.create(:element, :page => page, :name => 'download', :create_contents_after_create => true) }
13
- let(:attachment) { Attachment.create(:uploaded_data => fixture_file_upload(File.expand_path('../../support/image.png', __FILE__), 'image/png')) }
11
+ let(:public_page) { FactoryGirl.create(:public_page, :restricted => true) }
12
+ let(:element) { FactoryGirl.create(:element, :page => public_page, :name => 'download', :create_contents_after_create => true) }
13
+ let(:attachment) { Attachment.create(:file => File.new(File.expand_path('../../support/image.png', __FILE__))) }
14
14
 
15
15
  before do
16
16
  essence = element.contents.where(:name => 'file').first.essence
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  module Alchemy
4
4
  describe ElementsController do
5
5
 
6
- let(:page) { FactoryGirl.create(:public_page) }
7
- let(:element) { FactoryGirl.create(:element, :page => page, :name => 'download') }
6
+ let(:public_page) { FactoryGirl.create(:public_page) }
7
+ let(:element) { FactoryGirl.create(:element, :page => public_page, :name => 'download') }
8
8
  let(:restricted_page) { FactoryGirl.create(:public_page, :restricted => true) }
9
9
  let(:restricted_element) { FactoryGirl.create(:element, :page => restricted_page, :name => 'download') }
10
10
 
@@ -1,200 +1,231 @@
1
+ require 'ostruct'
1
2
  require 'spec_helper'
2
3
 
3
- describe Alchemy::PagesController do
4
+ module Alchemy
5
+ describe PagesController do
4
6
 
5
- let(:default_language) { Alchemy::Language.get_default }
6
- let(:default_language_root) { FactoryGirl.create(:language_root_page, :language => default_language, :name => 'Home', :public => true) }
7
+ let(:default_language) { Language.get_default }
8
+ let(:default_language_root) { FactoryGirl.create(:language_root_page, :language => default_language, :name => 'Home', :public => true) }
7
9
 
8
- context "requested for a page containing a feed" do
9
- render_views
10
+ context "requested for a page containing a feed" do
11
+ render_views
10
12
 
11
- let(:page) { FactoryGirl.create(:public_page, :parent_id => default_language_root.id, :page_layout => 'news', :name => 'News', :language => default_language, :do_not_autogenerate => false) }
13
+ let(:page) { FactoryGirl.create(:public_page, :parent_id => default_language_root.id, :page_layout => 'news', :name => 'News', :language => default_language, :do_not_autogenerate => false) }
12
14
 
13
- it "should render a rss feed" do
14
- get :show, :urlname => page.urlname, :format => :rss
15
- response.content_type.should == 'application/rss+xml'
16
- end
15
+ it "should render a rss feed" do
16
+ get :show, :urlname => page.urlname, :format => :rss
17
+ response.content_type.should == 'application/rss+xml'
18
+ end
19
+
20
+ it "should include content" do
21
+ page.elements.first.content_by_name('news_headline').essence.update_attributes({:body => 'Peters Petshop'})
22
+ get :show, :urlname => 'news', :format => :rss
23
+ response.body.should match /Peters Petshop/
24
+ end
17
25
 
18
- it "should include content" do
19
- page.elements.first.content_by_name('news_headline').essence.update_attributes({:body => 'Peters Petshop'})
20
- get :show, :urlname => 'news', :format => :rss
21
- response.body.should match /Peters Petshop/
22
26
  end
23
27
 
24
- end
28
+ context "requested for a page that does not contain a feed" do
25
29
 
26
- context "requested for a page that does not contain a feed" do
30
+ it "should render xml 404 error" do
31
+ get :show, :urlname => default_language_root.urlname, :format => :rss
32
+ response.status.should == 404
33
+ end
27
34
 
28
- it "should render xml 404 error" do
29
- get :show, :urlname => default_language_root.urlname, :format => :rss
30
- response.status.should == 404
31
35
  end
32
36
 
33
- end
37
+ describe "Layout rendering" do
34
38
 
35
- describe "Layout rendering" do
39
+ context "with param layout set to none" do
36
40
 
37
- context "with param layout set to none" do
41
+ it "should not render a layout" do
42
+ get :show, :urlname => :home, :layout => 'none'
43
+ response.body.should_not match /<head>/
44
+ end
38
45
 
39
- it "should not render a layout" do
40
- get :show, :urlname => :home, :layout => 'none'
41
- response.body.should_not match /<head>/
42
46
  end
43
47
 
44
- end
48
+ context "with param layout set to false" do
45
49
 
46
- context "with param layout set to false" do
50
+ it "should not render a layout" do
51
+ get :show, :urlname => :home, :layout => 'false'
52
+ response.body.should_not match /<head>/
53
+ end
47
54
 
48
- it "should not render a layout" do
49
- get :show, :urlname => :home, :layout => 'false'
50
- response.body.should_not match /<head>/
51
55
  end
52
56
 
53
- end
57
+ context "with params layout set to not existing layout" do
58
+ it "should raise ActionView::MissingTemplate" do
59
+ expect {
60
+ get :show, :urlname => default_language_root.urlname, :layout => 'lkuiuk'
61
+ }.to raise_error(ActionView::MissingTemplate)
62
+ end
63
+ end
64
+
65
+ context "with param layout set to a custom layout" do
66
+ render_views
67
+
68
+ before do
69
+ @custom_layout = Rails.root.join('app/views/layouts', 'custom.html.erb')
70
+ File.open(@custom_layout, 'w') do |custom_layout|
71
+ custom_layout.puts "<html>I am a custom layout</html>"
72
+ end
73
+ end
74
+
75
+ it "should render the custom layout" do
76
+ get :show, :urlname => default_language_root.urlname, :layout => 'custom'
77
+ response.body.should have_content('I am a custom layout')
78
+ end
79
+
80
+ after do
81
+ FileUtils.rm(@custom_layout)
82
+ end
54
83
 
55
- context "with params layout set to not existing layout" do
56
- it "should raise ActionView::MissingTemplate" do
57
- expect {
58
- get :show, :urlname => default_language_root.urlname, :layout => 'lkuiuk'
59
- }.to raise_error(ActionView::MissingTemplate)
60
84
  end
61
85
  end
62
86
 
63
- context "with param layout set to a custom layout" do
87
+ describe "url nesting" do
64
88
  render_views
65
89
 
90
+ let(:catalog) { FactoryGirl.create(:public_page, :name => "Catalog", :parent_id => default_language_root.id, :language => default_language, :visible => true) }
91
+ let(:products) { FactoryGirl.create(:public_page, :name => "Products", :parent_id => catalog.id, :language => default_language, :visible => true) }
92
+ let(:product) { FactoryGirl.create(:public_page, :name => "Screwdriver", :parent_id => products.id, :language => default_language, :do_not_autogenerate => false, :visible => true) }
93
+
66
94
  before do
67
- @custom_layout = Rails.root.join('app/views/layouts', 'custom.html.erb')
68
- File.open(@custom_layout, 'w') do |custom_layout|
69
- custom_layout.puts "<html>I am a custom layout</html>"
70
- end
95
+ User.stub!(:admins).and_return(OpenStruct.new(count: 1))
96
+ Config.stub!(:get) { |arg| arg == :url_nesting ? true : false }
97
+ product.elements.find_by_name('article').contents.essence_texts.first.essence.update_column(:body, 'screwdriver')
71
98
  end
72
99
 
73
- it "should render the custom layout" do
74
- get :show, :urlname => default_language_root.urlname, :layout => 'custom'
75
- response.body.should have_content('I am a custom layout')
76
- end
100
+ context "with correct levelnames in params" do
77
101
 
78
- after do
79
- FileUtils.rm(@custom_layout)
80
- end
81
-
82
- end
83
- end
102
+ it "should show the requested page" do
103
+ get :show, {:urlname => 'catalog/products/screwdriver'}
104
+ response.status.should == 200
105
+ response.body.should have_content("screwdriver")
106
+ end
84
107
 
85
- describe "url nesting" do
86
- render_views
108
+ end
87
109
 
88
- before(:each) do
89
- @catalog = FactoryGirl.create(:public_page, :name => "Catalog", :parent_id => default_language_root.id, :language => default_language)
90
- @products = FactoryGirl.create(:public_page, :name => "Products", :parent_id => @catalog.id, :language => default_language)
91
- @product = FactoryGirl.create(:public_page, :name => "Screwdriver", :parent_id => @products.id, :language => default_language, :do_not_autogenerate => false)
92
- @product.elements.find_by_name('article').contents.essence_texts.first.essence.update_column(:body, 'screwdriver')
93
- controller.stub!(:configuration) { |arg| arg == :url_nesting ? true : false }
94
- end
110
+ context "with incorrect levelnames in params" do
95
111
 
96
- context "with correct levelnames in params" do
112
+ it "should render a 404 page" do
113
+ get :show, {:urlname => 'catalog/faqs/screwdriver'}
114
+ response.status.should == 404
115
+ response.body.should have_content('The page you were looking for doesn\'t exist')
116
+ end
97
117
 
98
- it "should show the requested page" do
99
- get :show, {:level1 => 'catalog', :level2 => 'products', :urlname => 'screwdriver'}
100
- response.status.should == 200
101
- response.body.should have_content("screwdriver")
102
118
  end
103
119
 
104
120
  end
105
121
 
106
- context "with incorrect levelnames in params" do
107
-
108
- it "should render a 404 page" do
109
- get :show, {:level1 => 'catalog', :level2 => 'faqs', :urlname => 'screwdriver'}
122
+ context "when a non-existent page is requested" do
123
+ it "should rescue a RoutingError with rendering a 404 page." do
124
+ FactoryGirl.create(:admin_user) # otherwise we are redirected to create_user
125
+ get :show, {:urlname => 'doesntexist'}
110
126
  response.status.should == 404
111
127
  response.body.should have_content('The page you were looking for doesn\'t exist')
112
128
  end
113
-
114
129
  end
115
130
 
116
- end
131
+ describe '#redirect_to_public_child' do
117
132
 
118
- context "when a non-existent page is requested" do
119
- it "should rescue a RoutingError with rendering a 404 page." do
120
- FactoryGirl.create(:admin_user) # otherwise we are redirected to create_user
121
- get :show, {:urlname => 'doesntexist'}
122
- response.status.should == 404
123
- response.body.should have_content('The page you were looking for doesn\'t exist')
124
- end
125
- end
133
+ let(:root_page) { FactoryGirl.create(:language_root_page, :public => false) }
134
+ let(:page) { FactoryGirl.create(:page, :parent_id => root_page.id) }
135
+ let(:public_page) { FactoryGirl.create(:public_page, :parent_id => page.id) }
126
136
 
127
- describe '#redirect_to_public_child' do
137
+ before { controller.instance_variable_set("@page", root_page) }
128
138
 
129
- let(:root_page) { FactoryGirl.create(:language_root_page, :public => false) }
130
- let(:page) { FactoryGirl.create(:page, :parent_id => root_page.id) }
131
- let(:public_page) { FactoryGirl.create(:public_page, :parent_id => page.id) }
139
+ context "with unpublished and published pages in page tree" do
132
140
 
133
- before { controller.instance_variable_set("@page", root_page) }
141
+ before do
142
+ public_page
143
+ root_page.reload
144
+ end
134
145
 
135
- context "with unpublished and published pages in page tree" do
146
+ it "should redirect to first public child" do
147
+ controller.should_receive(:redirect_page)
148
+ controller.send(:redirect_to_public_child)
149
+ controller.instance_variable_get('@page').should == public_page
150
+ end
136
151
 
137
- before do
138
- public_page
139
- root_page.reload
140
152
  end
141
153
 
142
- it "should redirect to first public child" do
143
- controller.should_receive(:redirect_page)
144
- controller.send(:redirect_to_public_child)
145
- controller.instance_variable_get('@page').should == public_page
146
- end
154
+ context "with only unpublished pages in page tree" do
147
155
 
148
- end
156
+ before do
157
+ page
158
+ root_page.reload
159
+ end
149
160
 
150
- context "with only unpublished pages in page tree" do
161
+ it "should raise not found error" do
162
+ expect {
163
+ controller.send(:redirect_to_public_child)
164
+ }.to raise_error(ActionController::RoutingError)
165
+ end
151
166
 
152
- before do
153
- page
154
- root_page.reload
155
167
  end
168
+ end
156
169
 
157
- it "should raise not found error" do
158
- expect {
159
- controller.send(:redirect_to_public_child)
160
- }.to raise_error(ActionController::RoutingError)
161
- end
170
+ describe 'Redirecting to legacy page urls' do
171
+ context 'Request a page with legacy url' do
162
172
 
163
- end
164
- end
173
+ # otherwise we are redirected to signup
174
+ before { FactoryGirl.create(:admin_user) }
165
175
 
166
- describe 'Redirecting to legacy page urls' do
167
- context 'Request a page with legacy url' do
176
+ let(:page) { FactoryGirl.create(:public_page, :name => 'New page name') }
177
+ let(:second_page) { FactoryGirl.create(:public_page, :name => 'Second Page') }
178
+ let(:legacy_page) { FactoryGirl.create(:public_page, :name => 'Legacy Url') }
179
+ let(:legacy_url) { LegacyPageUrl.create(:urlname => 'legacy-url', :page => page) }
180
+ let(:legacy_url2) { LegacyPageUrl.create(:urlname => 'legacy-url', :page => second_page) }
168
181
 
169
- # otherwise we are redirected to signup
170
- before { FactoryGirl.create(:admin_user) }
182
+ it "should redirect permanently to page that belongs to legacy page url." do
183
+ get :show, :urlname => legacy_url.urlname
184
+ response.status.should == 301
185
+ response.should redirect_to('/new-page-name')
186
+ end
171
187
 
172
- let(:page) { FactoryGirl.create(:public_page, :name => 'New page name') }
173
- let(:second_page) { FactoryGirl.create(:public_page, :name => 'Second Page') }
174
- let(:legacy_page) { FactoryGirl.create(:public_page, :name => 'Legacy Url') }
175
- let(:legacy_url) { Alchemy::LegacyPageUrl.create(:urlname => 'legacy-url', :page => page) }
176
- let(:legacy_url2) { Alchemy::LegacyPageUrl.create(:urlname => 'legacy-url', :page => second_page) }
188
+ it "should only redirect to legacy url if no page was found for urlname" do
189
+ legacy_url
190
+ get :show, :urlname => legacy_page.urlname
191
+ response.status.should == 200
192
+ response.should_not redirect_to('/new-page-name')
193
+ end
177
194
 
178
- it "should redirect permanently to page that belongs to legacy page url." do
179
- get :show, :urlname => legacy_url.urlname
180
- response.status.should == 301
181
- response.should redirect_to('/alchemy/new-page-name')
182
- end
195
+ it "should redirect to last page that has that legacy url" do
196
+ legacy_url
197
+ get :show, :urlname => legacy_url2.urlname
198
+ response.should redirect_to('/second-page')
199
+ end
183
200
 
184
- it "should only redirect to legacy url if no page was found for urlname" do
185
- legacy_url
186
- get :show, :urlname => legacy_page.urlname
187
- response.status.should == 200
188
- response.should_not redirect_to('/alchemy/new-page-name')
189
201
  end
202
+ end
203
+
204
+ describe "while redirecting" do
205
+
206
+ context "not in multi language mode" do
207
+
208
+ before do
209
+ PagesController.any_instance.stub(:multi_language?).and_return(false)
210
+ end
211
+
212
+ context "with no lang parameter present" do
213
+
214
+ it "should store defaults language id in the session." do
215
+ get :show, :urlname => 'a-public-page'
216
+ controller.session[:language_id].should == Language.get_default.id
217
+ end
218
+
219
+ it "should store defaults language code in the session." do
220
+ get :show, :urlname => 'a-public-page'
221
+ controller.session[:language_code].should == Language.get_default.code
222
+ end
223
+
224
+ end
190
225
 
191
- it "should redirect to last page that has that legacy url" do
192
- legacy_url
193
- get :show, :urlname => legacy_url2.urlname
194
- response.should redirect_to('/alchemy/second-page')
195
226
  end
196
227
 
197
228
  end
198
- end
199
229
 
230
+ end
200
231
  end