alchemy_cms 3.3.0.rc1 → 3.3.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -2
  3. data/Gemfile +1 -0
  4. data/alchemy_cms.gemspec +6 -6
  5. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +0 -7
  6. data/app/assets/javascripts/alchemy/alchemy.dialog.js.coffee +4 -4
  7. data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +51 -5
  8. data/app/assets/javascripts/alchemy/alchemy.sitemap.js.coffee +0 -2
  9. data/app/assets/stylesheets/alchemy/elements.scss +2 -2
  10. data/app/controllers/alchemy/admin/elements_controller.rb +2 -0
  11. data/app/controllers/alchemy/admin/pages_controller.rb +11 -3
  12. data/app/controllers/alchemy/admin/pictures_controller.rb +1 -0
  13. data/app/models/alchemy/element.rb +3 -1
  14. data/app/models/alchemy/element/element_contents.rb +2 -7
  15. data/app/models/alchemy/element/presenters.rb +11 -4
  16. data/app/models/alchemy/page.rb +3 -1
  17. data/app/views/alchemy/admin/attachments/archive_overlay.js.erb +0 -1
  18. data/app/views/alchemy/admin/contents/create.js.erb +0 -1
  19. data/app/views/alchemy/admin/elements/_element_header.html.erb +3 -1
  20. data/app/views/alchemy/admin/elements/order.js.erb +25 -10
  21. data/app/views/alchemy/admin/elements/update.js.erb +1 -2
  22. data/app/views/alchemy/admin/essence_files/assign.js.erb +0 -1
  23. data/app/views/alchemy/admin/essence_pictures/assign.js.erb +0 -1
  24. data/app/views/alchemy/admin/legacy_page_urls/create.js.erb +0 -1
  25. data/app/views/alchemy/admin/pages/destroy.js.erb +0 -1
  26. data/app/views/alchemy/admin/pages/update.js.erb +6 -4
  27. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +2 -1
  28. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -7
  29. data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +0 -1
  30. data/bin/alchemy +1 -1
  31. data/bin/rspec +3 -2
  32. data/bin/spring +6 -6
  33. data/config/alchemy/config.yml +6 -1
  34. data/lib/alchemy/seeder.rb +9 -3
  35. data/lib/alchemy/version.rb +1 -1
  36. metadata +6 -471
  37. data/spec/controllers/alchemy/admin/attachments_controller_spec.rb +0 -193
  38. data/spec/controllers/alchemy/admin/base_controller_spec.rb +0 -87
  39. data/spec/controllers/alchemy/admin/clipboard_controller_spec.rb +0 -60
  40. data/spec/controllers/alchemy/admin/contents_controller_spec.rb +0 -78
  41. data/spec/controllers/alchemy/admin/dashboard_controller_spec.rb +0 -144
  42. data/spec/controllers/alchemy/admin/elements_controller_spec.rb +0 -496
  43. data/spec/controllers/alchemy/admin/essence_files_controller_spec.rb +0 -76
  44. data/spec/controllers/alchemy/admin/essence_pictures_controller_spec.rb +0 -202
  45. data/spec/controllers/alchemy/admin/languages_controller_spec.rb +0 -73
  46. data/spec/controllers/alchemy/admin/layoutpages_controller_spec.rb +0 -21
  47. data/spec/controllers/alchemy/admin/pages_controller_spec.rb +0 -639
  48. data/spec/controllers/alchemy/admin/pictures_controller_spec.rb +0 -383
  49. data/spec/controllers/alchemy/admin/resources_controller_spec.rb +0 -81
  50. data/spec/controllers/alchemy/admin/tags_controller_spec.rb +0 -63
  51. data/spec/controllers/alchemy/admin/trash_controller_spec.rb +0 -67
  52. data/spec/controllers/alchemy/api/contents_controller_spec.rb +0 -125
  53. data/spec/controllers/alchemy/api/elements_controller_spec.rb +0 -124
  54. data/spec/controllers/alchemy/api/pages_controller_spec.rb +0 -167
  55. data/spec/controllers/alchemy/attachments_controller_spec.rb +0 -64
  56. data/spec/controllers/alchemy/base_controller_spec.rb +0 -106
  57. data/spec/controllers/alchemy/elements_controller_spec.rb +0 -48
  58. data/spec/controllers/alchemy/messages_controller_spec.rb +0 -204
  59. data/spec/controllers/alchemy/on_page_layout_mixin_spec.rb +0 -330
  60. data/spec/controllers/alchemy/pages_controller_spec.rb +0 -343
  61. data/spec/controllers/alchemy/pictures_controller_spec.rb +0 -415
  62. data/spec/dummy/Rakefile +0 -6
  63. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  64. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  65. data/spec/dummy/app/controllers/admin/events_controller.rb +0 -3
  66. data/spec/dummy/app/controllers/application_controller.rb +0 -15
  67. data/spec/dummy/app/controllers/login_controller.rb +0 -5
  68. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  69. data/spec/dummy/app/mailers/.gitkeep +0 -0
  70. data/spec/dummy/app/models/ability.rb +0 -9
  71. data/spec/dummy/app/models/dummy_model.rb +0 -3
  72. data/spec/dummy/app/models/dummy_user.rb +0 -15
  73. data/spec/dummy/app/models/event.rb +0 -10
  74. data/spec/dummy/app/models/location.rb +0 -3
  75. data/spec/dummy/app/views/alchemy/elements/_all_you_can_eat_editor.html.erb +0 -11
  76. data/spec/dummy/app/views/alchemy/elements/_all_you_can_eat_view.html.erb +0 -31
  77. data/spec/dummy/app/views/alchemy/elements/_article_editor.html.erb +0 -6
  78. data/spec/dummy/app/views/alchemy/elements/_article_view.html.erb +0 -10
  79. data/spec/dummy/app/views/alchemy/elements/_bild_editor.html.erb +0 -3
  80. data/spec/dummy/app/views/alchemy/elements/_bild_view.html.erb +0 -5
  81. data/spec/dummy/app/views/alchemy/elements/_contactform_editor.html.erb +0 -6
  82. data/spec/dummy/app/views/alchemy/elements/_contactform_view.html.erb +0 -16
  83. data/spec/dummy/app/views/alchemy/elements/_download_editor.html.erb +0 -3
  84. data/spec/dummy/app/views/alchemy/elements/_download_view.html.erb +0 -5
  85. data/spec/dummy/app/views/alchemy/elements/_erb_element_editor.html.erb +0 -3
  86. data/spec/dummy/app/views/alchemy/elements/_erb_element_view.html.erb +0 -5
  87. data/spec/dummy/app/views/alchemy/elements/_header_editor.html.erb +0 -3
  88. data/spec/dummy/app/views/alchemy/elements/_header_view.html.erb +0 -5
  89. data/spec/dummy/app/views/alchemy/elements/_headline_editor.html.erb +0 -1
  90. data/spec/dummy/app/views/alchemy/elements/_headline_view.html.erb +0 -1
  91. data/spec/dummy/app/views/alchemy/elements/_news_editor.html.erb +0 -5
  92. data/spec/dummy/app/views/alchemy/elements/_news_view.html.erb +0 -11
  93. data/spec/dummy/app/views/alchemy/elements/_search_editor.html.erb +0 -1
  94. data/spec/dummy/app/views/alchemy/elements/_search_view.html.erb +0 -4
  95. data/spec/dummy/app/views/alchemy/elements/_slide_editor.html.erb +0 -3
  96. data/spec/dummy/app/views/alchemy/elements/_slide_view.html.erb +0 -5
  97. data/spec/dummy/app/views/alchemy/elements/_slider_editor.html.erb +0 -2
  98. data/spec/dummy/app/views/alchemy/elements/_slider_view.html.erb +0 -4
  99. data/spec/dummy/app/views/alchemy/elements/_text_editor.html.erb +0 -3
  100. data/spec/dummy/app/views/alchemy/elements/_text_view.html.erb +0 -5
  101. data/spec/dummy/app/views/alchemy/page_layouts/_standard.html.erb +0 -15
  102. data/spec/dummy/app/views/layouts/application.html.erb +0 -17
  103. data/spec/dummy/bin/bundle +0 -3
  104. data/spec/dummy/bin/rails +0 -4
  105. data/spec/dummy/bin/rake +0 -4
  106. data/spec/dummy/config.ru +0 -4
  107. data/spec/dummy/config/alchemy/cells.yml +0 -5
  108. data/spec/dummy/config/alchemy/elements.yml +0 -109
  109. data/spec/dummy/config/alchemy/page_layouts.yml +0 -32
  110. data/spec/dummy/config/application.rb +0 -32
  111. data/spec/dummy/config/boot.rb +0 -5
  112. data/spec/dummy/config/database.yml +0 -32
  113. data/spec/dummy/config/environment.rb +0 -5
  114. data/spec/dummy/config/environments/development.rb +0 -41
  115. data/spec/dummy/config/environments/production.rb +0 -77
  116. data/spec/dummy/config/environments/test.rb +0 -43
  117. data/spec/dummy/config/initializers/alchemy.rb +0 -3
  118. data/spec/dummy/config/initializers/assets.rb +0 -11
  119. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  120. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  121. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  122. data/spec/dummy/config/initializers/inflections.rb +0 -16
  123. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  124. data/spec/dummy/config/initializers/secret_token.rb +0 -12
  125. data/spec/dummy/config/initializers/session_store.rb +0 -3
  126. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  127. data/spec/dummy/config/locales/kl.yml +0 -2
  128. data/spec/dummy/config/routes.rb +0 -12
  129. data/spec/dummy/config/secrets.yml +0 -22
  130. data/spec/dummy/db/migrate/20121026104128_create_events.rb +0 -20
  131. data/spec/dummy/db/migrate/20130328101418_create_locations.rb +0 -9
  132. data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -1
  133. data/spec/dummy/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +0 -1
  134. data/spec/dummy/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +0 -1
  135. data/spec/dummy/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +0 -1
  136. data/spec/dummy/db/migrate/20131209225243_create_dummy_users.rb +0 -9
  137. data/spec/dummy/db/migrate/20150122213511_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +0 -31
  138. data/spec/dummy/db/migrate/20150122213512_add_missing_unique_indices.acts_as_taggable_on_engine.rb +0 -20
  139. data/spec/dummy/db/migrate/20150122213513_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +0 -15
  140. data/spec/dummy/db/migrate/20150122213514_add_missing_taggable_index.acts_as_taggable_on_engine.rb +0 -10
  141. data/spec/dummy/db/migrate/20150412103152_create_dummy_model.rb +0 -7
  142. data/spec/dummy/db/migrate/20150608204610_add_parent_element_id_to_alchemy_elements.rb +0 -1
  143. data/spec/dummy/db/migrate/20150729151825_add_link_text_to_alchemy_essence_files.rb +0 -1
  144. data/spec/dummy/db/migrate/20150906195818_add_locale_to_alchemy_languages.rb +0 -1
  145. data/spec/dummy/db/schema.rb +0 -326
  146. data/spec/dummy/db/seeds.rb +0 -1
  147. data/spec/dummy/lib/assets/.gitkeep +0 -0
  148. data/spec/dummy/public/404.html +0 -67
  149. data/spec/dummy/public/422.html +0 -67
  150. data/spec/dummy/public/500.html +0 -66
  151. data/spec/dummy/public/favicon.ico +0 -0
  152. data/spec/dummy/spec/javascripts +0 -1
  153. data/spec/factories.rb +0 -13
  154. data/spec/features/admin/admin_layout_spec.rb +0 -14
  155. data/spec/features/admin/dashboard_spec.rb +0 -81
  156. data/spec/features/admin/edit_elements_feature_spec.rb +0 -36
  157. data/spec/features/admin/language_tree_feature_spec.rb +0 -32
  158. data/spec/features/admin/languages_features_spec.rb +0 -65
  159. data/spec/features/admin/legacy_page_url_management_spec.rb +0 -62
  160. data/spec/features/admin/link_overlay_spec.rb +0 -53
  161. data/spec/features/admin/locale_select_feature_spec.rb +0 -25
  162. data/spec/features/admin/modules_integration_spec.rb +0 -23
  163. data/spec/features/admin/navigation_feature_spec.rb +0 -22
  164. data/spec/features/admin/page_creation_feature_spec.rb +0 -51
  165. data/spec/features/admin/page_editing_feature_spec.rb +0 -135
  166. data/spec/features/admin/picture_library_integration_spec.rb +0 -62
  167. data/spec/features/admin/resources_integration_spec.rb +0 -128
  168. data/spec/features/admin/site_select_feature_spec.rb +0 -31
  169. data/spec/features/admin/tinymce_feature_spec.rb +0 -33
  170. data/spec/features/navigation_spec.rb +0 -9
  171. data/spec/features/page_feature_spec.rb +0 -186
  172. data/spec/features/page_redirects_spec.rb +0 -358
  173. data/spec/features/picture_security_spec.rb +0 -29
  174. data/spec/features/security_spec.rb +0 -24
  175. data/spec/features/translation_integration_spec.rb +0 -51
  176. data/spec/fixtures/500x500.png +0 -0
  177. data/spec/fixtures/80x60.png +0 -0
  178. data/spec/fixtures/animated.gif +0 -0
  179. data/spec/fixtures/image with spaces.png +0 -0
  180. data/spec/fixtures/image.png +0 -0
  181. data/spec/fixtures/image2.PNG +0 -0
  182. data/spec/fixtures/image3.jpeg +0 -0
  183. data/spec/helpers/alchemy/admin/attachments_helper_spec.rb +0 -15
  184. data/spec/helpers/alchemy/admin/base_helper_spec.rb +0 -280
  185. data/spec/helpers/alchemy/admin/contents_helper_spec.rb +0 -46
  186. data/spec/helpers/alchemy/admin/elements_helper_spec.rb +0 -314
  187. data/spec/helpers/alchemy/admin/essences_helper_spec.rb +0 -201
  188. data/spec/helpers/alchemy/admin/navigation_helper_spec.rb +0 -294
  189. data/spec/helpers/alchemy/admin/pages_helper_spec.rb +0 -63
  190. data/spec/helpers/alchemy/admin/pictures_helper_spec.rb +0 -28
  191. data/spec/helpers/alchemy/admin/tags_helper_spec.rb +0 -111
  192. data/spec/helpers/alchemy/base_helper_spec.rb +0 -44
  193. data/spec/helpers/alchemy/elements_block_helper_spec.rb +0 -135
  194. data/spec/helpers/alchemy/elements_helper_spec.rb +0 -326
  195. data/spec/helpers/alchemy/essences_helper_spec.rb +0 -85
  196. data/spec/helpers/alchemy/pages_helper_spec.rb +0 -499
  197. data/spec/helpers/alchemy/picture_url_helpers_spec.rb +0 -78
  198. data/spec/helpers/alchemy/url_helper_spec.rb +0 -200
  199. data/spec/javascripts/alchemy/dialog_spec.coffee +0 -82
  200. data/spec/javascripts/alchemy/link_overlay_spec.coffee +0 -25
  201. data/spec/javascripts/alchemy_integration_spec.coffee +0 -3
  202. data/spec/javascripts/fixtures/select.html +0 -3
  203. data/spec/javascripts/helpers/mock-ajax.js +0 -199
  204. data/spec/javascripts/helpers/test_responses/test_responses.js +0 -1
  205. data/spec/javascripts/support/jasmine.yml +0 -29
  206. data/spec/libraries/auth_accessors_spec.rb +0 -40
  207. data/spec/libraries/config_spec.rb +0 -111
  208. data/spec/libraries/controller_actions_spec.rb +0 -133
  209. data/spec/libraries/i18n_spec.rb +0 -37
  210. data/spec/libraries/kaminari/scoped_pagination_url_helper_spec.rb +0 -30
  211. data/spec/libraries/modules_spec.rb +0 -67
  212. data/spec/libraries/mount_point_spec.rb +0 -77
  213. data/spec/libraries/page_layout_spec.rb +0 -150
  214. data/spec/libraries/paths_spec.rb +0 -15
  215. data/spec/libraries/permissions_spec.rb +0 -260
  216. data/spec/libraries/resource_spec.rb +0 -344
  217. data/spec/libraries/resources_helper_spec.rb +0 -193
  218. data/spec/libraries/shell_spec.rb +0 -121
  219. data/spec/libraries/template_tracker_spec.rb +0 -85
  220. data/spec/libraries/tinymce_spec.rb +0 -111
  221. data/spec/libraries/userstamp_spec.rb +0 -10
  222. data/spec/mailers/alchemy/messages_spec.rb +0 -21
  223. data/spec/models/alchemy/attachment_spec.rb +0 -250
  224. data/spec/models/alchemy/cell_spec.rb +0 -101
  225. data/spec/models/alchemy/content_spec.rb +0 -513
  226. data/spec/models/alchemy/element_spec.rb +0 -862
  227. data/spec/models/alchemy/element_to_page_spec.rb +0 -13
  228. data/spec/models/alchemy/essence_boolean_spec.rb +0 -10
  229. data/spec/models/alchemy/essence_date_spec.rb +0 -28
  230. data/spec/models/alchemy/essence_file_spec.rb +0 -40
  231. data/spec/models/alchemy/essence_html_spec.rb +0 -18
  232. data/spec/models/alchemy/essence_link_spec.rb +0 -10
  233. data/spec/models/alchemy/essence_picture_spec.rb +0 -255
  234. data/spec/models/alchemy/essence_richtext_spec.rb +0 -23
  235. data/spec/models/alchemy/essence_select_spec.rb +0 -10
  236. data/spec/models/alchemy/essence_text_spec.rb +0 -110
  237. data/spec/models/alchemy/language_spec.rb +0 -243
  238. data/spec/models/alchemy/legacy_page_url_spec.rb +0 -21
  239. data/spec/models/alchemy/message_spec.rb +0 -55
  240. data/spec/models/alchemy/page_spec.rb +0 -2108
  241. data/spec/models/alchemy/picture_spec.rb +0 -418
  242. data/spec/models/alchemy/site_spec.rb +0 -168
  243. data/spec/models/alchemy/tag_spec.rb +0 -29
  244. data/spec/models/dummy_model_spec.rb +0 -10
  245. data/spec/requests/alchemy/admin/resources_requests_spec.rb +0 -26
  246. data/spec/requests/alchemy/admin/site_requests_spec.rb +0 -19
  247. data/spec/requests/alchemy/site_requests_spec.rb +0 -18
  248. data/spec/requests/alchemy/sitemap_spec.rb +0 -56
  249. data/spec/routing/api_routing_spec.rb +0 -150
  250. data/spec/routing/routing_spec.rb +0 -340
  251. data/spec/spec_helper.rb +0 -90
  252. data/spec/support/ci/install_phantomjs +0 -7
  253. data/spec/support/hint_examples.rb +0 -28
  254. data/spec/support/test_tweaks.rb +0 -31
  255. data/spec/support/transformation_examples.rb +0 -179
  256. data/spec/tasks/helpers_spec.rb +0 -217
  257. data/spec/views/admin/pictures/show_spec.rb +0 -43
  258. data/spec/views/essences/essence_boolean_editor_spec.rb +0 -32
  259. data/spec/views/essences/essence_boolean_view_spec.rb +0 -23
  260. data/spec/views/essences/essence_date_view_spec.rb +0 -38
  261. data/spec/views/essences/essence_file_editor_spec.rb +0 -59
  262. data/spec/views/essences/essence_file_view_spec.rb +0 -77
  263. data/spec/views/essences/essence_html_view_spec.rb +0 -22
  264. data/spec/views/essences/essence_link_view_spec.rb +0 -41
  265. data/spec/views/essences/essence_picture_editor_spec.rb +0 -80
  266. data/spec/views/essences/essence_picture_view_spec.rb +0 -128
  267. data/spec/views/essences/essence_richtext_view_spec.rb +0 -32
  268. data/spec/views/essences/essence_select_view_spec.rb +0 -11
  269. data/spec/views/essences/essence_text_view_spec.rb +0 -51
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Site select' do
4
- before do
5
- authorize_user(:as_admin)
6
- end
7
-
8
- it "does not display the site change" do
9
- visit admin_dashboard_path
10
- expect(page).not_to have_select('change_site')
11
- end
12
-
13
- context "multiple sites" do
14
- let!(:a_site) { create(:alchemy_site) }
15
-
16
- it "contains all sites in a selectbox" do
17
- visit admin_dashboard_path
18
- expect(page).to have_select('change_site', options: [Alchemy::Site.default.name, a_site.name], selected: Alchemy::Site.default.name)
19
- end
20
-
21
- context 'when requesting non-default site' do
22
- it "provides the correct site" do
23
- visit admin_pages_path(site_id: a_site.id)
24
- expect(page).to have_select('change_site', selected: a_site.name)
25
-
26
- visit admin_dashboard_path
27
- expect(page).to have_select('change_site', selected: a_site.name)
28
- end
29
- end
30
- end
31
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'TinyMCE Editor' do
4
- before do
5
- authorize_user(:as_admin)
6
- end
7
-
8
- it 'base path should be set to tinymce asset folder' do
9
- visit admin_dashboard_path
10
- expect(page).to have_content <<-TINYMCE
11
- var tinyMCEPreInit = {
12
- base: '/assets/tinymce',
13
- suffix: '.min'
14
- };
15
- TINYMCE
16
- end
17
-
18
- context 'with asset host' do
19
- before do
20
- expect(ActionController::Base.config).to receive(:asset_host_set?).and_return(true)
21
- end
22
-
23
- it 'base path should be set to tinymce asset folder' do
24
- visit admin_dashboard_path
25
- expect(page).to have_content <<-TINYMCE
26
- var tinyMCEPreInit = {
27
- base: 'http://www.example.com/assets/tinymce',
28
- suffix: '.min'
29
- };
30
- TINYMCE
31
- end
32
- end
33
- end
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Dummy App" do
4
- include Capybara::DSL
5
-
6
- it "should be a valid app" do
7
- expect(::Rails.application).to be_a(Dummy::Application)
8
- end
9
- end
@@ -1,186 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe 'Show page feature:' do
5
- let!(:default_language) { Language.default }
6
-
7
- let!(:default_language_root) do
8
- create(:alchemy_page, :language_root, language: default_language, name: 'Home')
9
- end
10
-
11
- let(:public_page) do
12
- create(:alchemy_page, :public, visible: true, name: 'Page 1')
13
- end
14
-
15
- let(:public_child) do
16
- create(:alchemy_page, :public, name: 'Public Child', parent_id: public_page.id)
17
- end
18
-
19
- context "When no page is present" do
20
- before do
21
- Alchemy::Page.delete_all
22
- end
23
-
24
- context "and no admin user is present yet" do
25
- before do
26
- Alchemy.user_class.delete_all
27
- end
28
-
29
- it 'shows a welcome page' do
30
- visit "/"
31
- expect(page).to have_content('Welcome to Alchemy')
32
- end
33
- end
34
- end
35
-
36
- context 'rendered' do
37
- let(:public_page) { create(:alchemy_page, :public, do_not_autogenerate: false) }
38
- let(:article) { public_page.elements.find_by_name('article') }
39
- let(:essence) { article.content_by_name('intro').essence }
40
-
41
- before do
42
- essence.update_attributes(body: 'Welcome to Peters Petshop', public: true)
43
- end
44
-
45
- it "should include all its elements and contents" do
46
- visit "/#{public_page.urlname}"
47
- within('div#content div.article div.intro') do
48
- expect(page).to have_content('Welcome to Peters Petshop')
49
- end
50
- end
51
- end
52
-
53
- it "should show the navigation with all visible pages" do
54
- create(:alchemy_page, :public, visible: true, name: 'Page 1')
55
- create(:alchemy_page, :public, visible: true, name: 'Page 2')
56
- visit '/'
57
- within('div#navigation ul') do
58
- expect(page).to have_selector('li a[href="/page-1"], li a[href="/page-2"]')
59
- end
60
- end
61
-
62
- describe "Handling of non-existing pages" do
63
- before do
64
- # We need a admin user or the signup page will show up
65
- allow(Alchemy.user_class).to receive(:admins).and_return([1, 2])
66
- end
67
-
68
- it "should render public/404.html" do
69
- expect {
70
- visit "/non-existing-page"
71
- }.to raise_error(ActionController::RoutingError)
72
- end
73
- end
74
-
75
- context "with invalid byte code char in urlname parameter" do
76
- it "should raise BadRequest (400) error" do
77
- expect { visit '/%ed' }.to raise_error(ActionController::BadRequest)
78
- end
79
- end
80
-
81
- describe "menubar" do
82
- context "rendering for guest users" do
83
- it "is prohibited" do
84
- visit "/#{public_page.urlname}"
85
- within('body') { expect(page).not_to have_selector('#alchemy_menubar') }
86
- end
87
- end
88
-
89
- context "rendering for members" do
90
- it "is prohibited" do
91
- authorize_user(build(:alchemy_dummy_user))
92
- visit "/#{public_page.urlname}"
93
- within('body') { expect(page).not_to have_selector('#alchemy_menubar') }
94
- end
95
- end
96
-
97
- context "rendering for authors" do
98
- it "is allowed" do
99
- authorize_user(:as_author)
100
- visit "/#{public_page.urlname}"
101
- within('body') { expect(page).to have_selector('#alchemy_menubar') }
102
- end
103
- end
104
-
105
- context "rendering for editors" do
106
- it "is allowed" do
107
- authorize_user(:as_editor)
108
- visit "/#{public_page.urlname}"
109
- within('body') { expect(page).to have_selector('#alchemy_menubar') }
110
- end
111
- end
112
-
113
- context "rendering for admins" do
114
- it "is allowed" do
115
- authorize_user(:as_admin)
116
- visit "/#{public_page.urlname}"
117
- within('body') { expect(page).to have_selector('#alchemy_menubar') }
118
- end
119
- end
120
-
121
- context "contains" do
122
- before do
123
- authorize_user(:as_admin)
124
- visit "/#{public_page.urlname}"
125
- end
126
-
127
- it "a link to the admin area" do
128
- within('#alchemy_menubar') do
129
- expect(page).to have_selector("li a[href='#{alchemy.admin_dashboard_url}']")
130
- end
131
- end
132
-
133
- it "a link to edit the current page" do
134
- within('#alchemy_menubar') do
135
- expect(page).to \
136
- have_selector("li a[href='#{alchemy.edit_admin_page_url(public_page)}']")
137
- end
138
- end
139
-
140
- it "a form and button to logout of alchemy" do
141
- within('#alchemy_menubar') do
142
- expect(page).to \
143
- have_selector("li form[action='#{Alchemy.logout_path}'], li button[type='submit']")
144
- end
145
- end
146
- end
147
- end
148
-
149
- describe 'navigation rendering' do
150
- context 'with page having an external url without protocol' do
151
- let!(:external_page) do
152
- create(:alchemy_page, urlname: 'google.com', page_layout: 'external', visible: true)
153
- end
154
-
155
- it "adds an prefix to url" do
156
- visit "/#{public_page.urlname}"
157
- within '#navigation' do
158
- expect(page.body).to match('http://google.com')
159
- end
160
- end
161
- end
162
- end
163
-
164
- describe 'accessing restricted pages' do
165
- let!(:restricted_page) { create(:alchemy_page, :restricted, public: true) }
166
-
167
- context 'as a guest user' do
168
- it "I am not able to visit the page" do
169
- visit restricted_page.urlname
170
- expect(current_path).to eq(Alchemy.login_path)
171
- end
172
- end
173
-
174
- context 'as a member user' do
175
- before do
176
- authorize_user(create(:alchemy_dummy_user))
177
- end
178
-
179
- it "I am able to visit the page" do
180
- visit restricted_page.urlname
181
- expect(current_path).to eq("/#{restricted_page.urlname}")
182
- end
183
- end
184
- end
185
- end
186
- end
@@ -1,358 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe 'Requesting a page' do
5
- let!(:default_language) { Language.default }
6
-
7
- let!(:default_language_root) do
8
- create(:alchemy_page, :language_root, language: default_language, name: 'Home')
9
- end
10
-
11
- let(:public_page) do
12
- create(:alchemy_page, :public, visible: true, name: 'Page 1')
13
- end
14
-
15
- let(:public_child) do
16
- create(:alchemy_page, :public, name: 'Public Child', parent_id: public_page.id)
17
- end
18
-
19
- context "in multi language mode" do
20
- let(:second_page) { create(:alchemy_page, :public, name: 'Second Page') }
21
-
22
- let(:legacy_url) do
23
- LegacyPageUrl.create(
24
- urlname: 'index.php?option=com_content&view=article&id=48&Itemid=69',
25
- page: second_page
26
- )
27
- end
28
-
29
- before do
30
- allow_any_instance_of(PagesController).to receive(:multi_language?).and_return(true)
31
- end
32
-
33
- context 'if language params are given' do
34
- context "and page locale is default locale" do
35
- it "redirects to unprefixed locale url" do
36
- allow(::I18n).to receive(:default_locale) { public_page.language_code.to_sym }
37
- visit("/#{public_page.language_code}/#{public_page.urlname}")
38
- expect(page.current_path).to eq("/#{public_page.urlname}")
39
- end
40
- end
41
-
42
- context "and page locale is not default locale" do
43
- it "does not redirect" do
44
- allow(::I18n).to receive(:default_locale).and_return(:de)
45
- visit("/#{public_page.language_code}/#{public_page.urlname}")
46
- expect(page.current_path).to eq("/#{public_page.language_code}/#{public_page.urlname}")
47
- end
48
- end
49
- end
50
-
51
- context 'if no language params are given' do
52
- context "and page locale is default locale" do
53
- it "doesn't prepend the url with the locale string" do
54
- allow(::I18n).to receive(:default_locale) { public_page.language_code.to_sym }
55
- visit("/#{public_page.urlname}")
56
- expect(page.current_path).to eq("/#{public_page.urlname}")
57
- end
58
-
59
- it "redirects legacy url with unknown format & query string without locale prefix" do
60
- allow(::I18n).to receive(:default_locale) { second_page.language_code.to_sym }
61
- visit "/#{legacy_url.urlname}"
62
- uri = URI.parse(page.current_url)
63
- expect(uri.query).to be_nil
64
- expect(uri.request_uri).to eq("/#{second_page.urlname}")
65
- end
66
- end
67
-
68
- context "and page locale is not default locale" do
69
- before do
70
- allow(::I18n).to receive(:default_locale).and_return(:de)
71
- end
72
-
73
- it "redirects to url with the locale prefixed" do
74
- visit("/#{public_page.urlname}")
75
- expect(page.current_path).to eq("/en/#{public_page.urlname}")
76
- end
77
-
78
- it "redirects legacy url with unknown format & query string with locale prefix" do
79
- visit "/#{legacy_url.urlname}"
80
- uri = URI.parse(page.current_url)
81
- expect(uri.query).to be_nil
82
- expect(uri.request_uri).to eq("/en/#{second_page.urlname}")
83
- end
84
- end
85
- end
86
-
87
- context "if requested page is unpublished" do
88
- before do
89
- public_page.update_attributes(
90
- public: false,
91
- visible: false,
92
- name: 'Not Public',
93
- urlname: ''
94
- )
95
- public_child
96
- end
97
-
98
- it "redirects to public child" do
99
- visit "/not-public"
100
- expect(page.current_path).to eq("/public-child")
101
- end
102
-
103
- context "with only unpublished pages in page tree" do
104
- before do
105
- public_child.update_attributes(public: false)
106
- end
107
-
108
- it "should raise not found error" do
109
- expect {
110
- visit "/not-public"
111
- }.to raise_error(ActionController::RoutingError)
112
- end
113
- end
114
-
115
- context "if page locale is the default locale" do
116
- it "redirects to public child with prefixed locale" do
117
- allow(::I18n).to receive(:default_locale).and_return(:de)
118
- visit "/not-public"
119
- expect(page.current_path).to eq("/en/public-child")
120
- end
121
- end
122
- end
123
-
124
- context "if requested url is the index url" do
125
- context 'and redirect_index is set to true' do
126
- before do
127
- allow(Config).to receive(:get) do |arg|
128
- arg == :redirect_index ? true : Config.parameter(arg)
129
- end
130
- if Alchemy.version == "4.0.0.rc1"
131
- raise "Remove deprecated `redirect_index` configuration!"
132
- end
133
- ActiveSupport::Deprecation.silenced = true
134
- end
135
-
136
- after do
137
- ActiveSupport::Deprecation.silenced = false
138
- end
139
-
140
- context "and if page locale is the default locale" do
141
- it "redirects to the default language root page without prefixed locale" do
142
- visit '/'
143
- expect(page.current_path).to eq('/home')
144
- end
145
-
146
- context "having additional parameter" do
147
- it "redirects to the default language root page with prefixed locale while keeping the additional params" do
148
- visit '/?search=kitten'
149
- expect(page.current_url).to eq('http://www.example.com/home?search=kitten')
150
- end
151
- end
152
- end
153
-
154
- context "and if page locale is not the default locale" do
155
- before do
156
- allow(::I18n).to receive(:default_locale).and_return(:de)
157
- end
158
-
159
- it "redirects to the default language root page with prefixed locale" do
160
- visit '/'
161
- expect(page.current_path).to eq('/en/home')
162
- end
163
-
164
- context "having additional parameter" do
165
- it "redirects to the default language root page with prefixed locale while keeping the additional params" do
166
- visit '/?search=kitten'
167
- expect(page.current_url).to eq('http://www.example.com/en/home?search=kitten')
168
- end
169
- end
170
- end
171
- end
172
-
173
- context 'and redirect_index is set to false' do
174
- before do
175
- allow(Config).to receive(:get) do |arg|
176
- arg == :redirect_index ? false : Config.parameter(arg)
177
- end
178
- end
179
-
180
- it "does not redirect" do
181
- visit '/'
182
- expect(page.current_path).to eq('/')
183
- end
184
- end
185
- end
186
-
187
- context "if requested url is only the language code" do
188
- context 'and redirect_index is set to true' do
189
- before do
190
- allow(Config).to receive(:get) do |arg|
191
- arg == :redirect_index ? true : Config.parameter(arg)
192
- end
193
- if Alchemy.version == "4.0.0.rc1"
194
- raise "Remove deprecated `redirect_index` configuration!"
195
- end
196
- ActiveSupport::Deprecation.silenced = true
197
- end
198
-
199
- after do
200
- ActiveSupport::Deprecation.silenced = false
201
- end
202
-
203
- context "if page locale is the default locale" do
204
- it "redirects to pages url without locale prefixed" do
205
- visit "/#{default_language.code}"
206
- expect(page.current_path).to eq("/home")
207
- end
208
- end
209
-
210
- context "if page locale is not the default locale" do
211
- it "redirects to the default language root url with prefixed locale" do
212
- allow(::I18n).to receive(:default_locale).and_return(:de)
213
- visit "/#{default_language.code}"
214
- expect(page.current_path).to eq('/en/home')
215
- end
216
- end
217
- end
218
-
219
- context 'and redirect_index is set to false' do
220
- before do
221
- allow(Config).to receive(:get) do |arg|
222
- arg == :redirect_index ? false : Config.parameter(arg)
223
- end
224
- end
225
-
226
- context "if requested locale is the default locale" do
227
- before do
228
- allow(::I18n).to receive(:default_locale) { default_language.code }
229
- end
230
-
231
- it "redirects to '/'" do
232
- visit "/#{default_language.code}"
233
- expect(page.current_path).to eq('/')
234
- end
235
- end
236
-
237
- context "if page locale is not the default locale" do
238
- before do
239
- allow(::I18n).to receive(:default_locale) { :de }
240
- end
241
-
242
- it "does not redirect" do
243
- visit "/#{default_language.code}"
244
- expect(page.current_path).to eq("/#{default_language.code}")
245
- end
246
- end
247
- end
248
- end
249
-
250
- it "should keep additional params" do
251
- visit "/#{public_page.urlname}?query=Peter"
252
- expect(page.current_url).to match(/\?query=Peter/)
253
- end
254
-
255
- context "wrong language requested" do
256
- before do
257
- allow(Alchemy.user_class).to receive(:admins).and_return([1, 2])
258
- end
259
-
260
- it "should render 404 if urlname and lang parameter do not belong to same page" do
261
- create(:alchemy_language, :klingon)
262
- expect {
263
- visit "/kl/#{public_page.urlname}"
264
- }.to raise_error(ActionController::RoutingError)
265
- end
266
-
267
- it "should render 404 if requested language does not exist" do
268
- public_page
269
- LegacyPageUrl.delete_all
270
- expect {
271
- visit "/fo/#{public_page.urlname}"
272
- }.to raise_error(ActionController::RoutingError)
273
- end
274
- end
275
- end
276
-
277
- context "not in multi language mode" do
278
- let(:second_page) { create(:alchemy_page, :public, name: 'Second Page') }
279
-
280
- let(:legacy_url) do
281
- LegacyPageUrl.create(
282
- urlname: 'index.php?option=com_content&view=article&id=48&Itemid=69',
283
- page: second_page
284
- )
285
- end
286
-
287
- before do
288
- allow_any_instance_of(PagesController).to receive(:multi_language?).and_return(false)
289
- end
290
-
291
- it "redirects legacy url with unknown format & query string" do
292
- visit "/#{legacy_url.urlname}"
293
- uri = URI.parse(page.current_url)
294
- expect(uri.query).to be_nil
295
- expect(uri.request_uri).to eq("/#{second_page.urlname}")
296
- end
297
-
298
- it "redirects from nested language code url to normal url" do
299
- visit "/en/#{public_page.urlname}"
300
- expect(page.current_path).to eq("/#{public_page.urlname}")
301
- end
302
-
303
- context "redirects to public child" do
304
- before do
305
- public_page.update_attributes(
306
- public: false,
307
- visible: false,
308
- name: 'Not Public',
309
- urlname: ''
310
- )
311
- public_child
312
- end
313
-
314
- it "if requested page is unpublished" do
315
- visit '/not-public'
316
- expect(page.current_path).to eq('/public-child')
317
- end
318
-
319
- it "with normal url, if requested url has nested language code and is not public" do
320
- visit '/en/not-public'
321
- expect(page.current_path).to eq('/public-child')
322
- end
323
- end
324
-
325
- context 'if requested url is index url' do
326
- context "when locale is prefixed" do
327
- it "redirects to normal url" do
328
- visit "/en"
329
- expect(page.current_path).to eq("/")
330
- end
331
- end
332
-
333
- context "when redirect_index is enabled" do
334
- before do
335
- allow(Config).to receive(:get) do |arg|
336
- arg == :redirect_index ? true : Config.parameter(arg)
337
- end
338
- if Alchemy.version == "4.0.0.rc1"
339
- raise "Remove deprecated `redirect_index` configuration!"
340
- end
341
- end
342
-
343
- it "redirects to pages url" do
344
- ActiveSupport::Deprecation.silence do
345
- visit '/'
346
- expect(page.current_path).to eq('/home')
347
- end
348
- end
349
- end
350
- end
351
-
352
- it "should keep additional params" do
353
- visit "/en/#{public_page.urlname}?query=Peter"
354
- expect(page.current_url).to match(/\?query=Peter/)
355
- end
356
- end
357
- end
358
- end