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,64 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe AttachmentsController do
5
- let(:attachment) { build_stubbed(:alchemy_attachment) }
6
-
7
- it "should raise ActiveRecord::RecordNotFound for requesting not existing attachments" do
8
- expect { alchemy_get :download, id: 0 }.to raise_error(ActiveRecord::RecordNotFound)
9
- end
10
-
11
- context 'with public attachment' do
12
- before do
13
- allow(Attachment).to receive(:find).and_return(attachment)
14
- end
15
-
16
- it "sends download as attachment." do
17
- alchemy_get :download, id: attachment.id
18
- expect(response.status).to eq(200)
19
- expect(response.headers['Content-Disposition']).to match(/attachment/)
20
- end
21
-
22
- it "sends download inline." do
23
- alchemy_get :show, id: attachment.id
24
- expect(response.status).to eq(200)
25
- expect(response.headers['Content-Disposition']).to match(/inline/)
26
- end
27
- end
28
-
29
- context 'with restricted attachment' do
30
- before do
31
- allow(attachment).to receive(:restricted?).and_return(true)
32
- allow(Attachment).to receive(:find).and_return(attachment)
33
- end
34
-
35
- context 'as anonymous user' do
36
- it "should not be possible to download attachments from restricted pages" do
37
- alchemy_get :download, id: attachment.id
38
- expect(response.status).to eq(302)
39
- expect(response).to redirect_to(Alchemy.login_path)
40
- end
41
-
42
- it "should not be possible to see attachments from restricted pages" do
43
- alchemy_get :show, id: attachment.id
44
- expect(response.status).to eq(302)
45
- expect(response).to redirect_to(Alchemy.login_path)
46
- end
47
- end
48
-
49
- context "as member user" do
50
- before { authorize_user(build(:alchemy_dummy_user)) }
51
-
52
- it "should be possible to download attachments from restricted pages" do
53
- alchemy_get :download, id: attachment.id
54
- expect(response.status).to eq(200)
55
- end
56
-
57
- it "should be possible to see attachments from restricted pages" do
58
- alchemy_get :show, id: attachment.id
59
- expect(response.status).to eq(200)
60
- end
61
- end
62
- end
63
- end
64
- end
@@ -1,106 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe BaseController do
5
- describe '#set_locale' do
6
- context 'with Language.current set' do
7
- let(:language) { create(:alchemy_language, :klingon) }
8
-
9
- before { Alchemy::Language.current = language }
10
-
11
- it "sets the ::I18n.locale to current language code" do
12
- controller.send(:set_locale)
13
- expect(::I18n.locale).to eq(language.code.to_sym)
14
- end
15
- end
16
-
17
- context 'without Language.current set' do
18
- before { Alchemy::Language.current = nil }
19
-
20
- it "sets the ::I18n.locale to default language code" do
21
- controller.send(:set_locale)
22
- expect(::I18n.locale).to eq(Language.default.code.to_sym)
23
- end
24
- end
25
- end
26
-
27
- describe "#configuration" do
28
- it "returns certain configuration options" do
29
- allow(Config).to receive(:show).and_return({"some_option" => true})
30
- expect(controller.configuration(:some_option)).to eq(true)
31
- end
32
- end
33
-
34
- describe "#multi_language?" do
35
- context "if more than one published language exists" do
36
- it "returns true" do
37
- allow(Alchemy::Language).to receive(:published).and_return double(count: 2)
38
- expect(controller.multi_language?).to eq(true)
39
- end
40
- end
41
-
42
- context "if less than two published languages exists" do
43
- it "returns false" do
44
- allow(Alchemy::Language).to receive(:published).and_return double(count: 1)
45
- expect(controller.multi_language?).to eq(false)
46
- end
47
- end
48
- end
49
-
50
- describe "#prefix_locale?" do
51
- subject(:prefix_locale?) { controller.prefix_locale? }
52
-
53
- context "if multi_language? is true" do
54
- before do
55
- expect(controller).to receive(:multi_language?) { true }
56
- end
57
-
58
- context "and current language is not the default locale" do
59
- before do
60
- allow(Alchemy::Language).to receive(:current) { double(code: 'en') }
61
- allow(::I18n).to receive(:default_locale) { :de }
62
- end
63
-
64
- it { expect(prefix_locale?).to be(true) }
65
- end
66
-
67
- context "and current language is the default locale" do
68
- before do
69
- allow(Alchemy::Language).to receive(:current) { double(code: 'de') }
70
- allow(::I18n).to receive(:default_locale) { :de }
71
- end
72
-
73
- it { expect(prefix_locale?).to be(false) }
74
- end
75
-
76
- context "and passed in locale is not the default locale" do
77
- subject(:prefix_locale?) { controller.prefix_locale?('en') }
78
-
79
- before do
80
- allow(::I18n).to receive(:default_locale) { :de }
81
- end
82
-
83
- it { expect(prefix_locale?).to be(true) }
84
- end
85
-
86
- context "and passed in locale is the default locale" do
87
- subject(:prefix_locale?) { controller.prefix_locale?('de') }
88
-
89
- before do
90
- allow(::I18n).to receive(:default_locale) { :de }
91
- end
92
-
93
- it { expect(prefix_locale?).to be(false) }
94
- end
95
- end
96
-
97
- context "if multi_language? is false" do
98
- before do
99
- expect(controller).to receive(:multi_language?) { false }
100
- end
101
-
102
- it { expect(prefix_locale?).to be(false) }
103
- end
104
- end
105
- end
106
- end
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe ElementsController do
5
- let(:public_page) { create(:alchemy_page, :public) }
6
- let(:element) { create(:alchemy_element, page: public_page, name: 'download') }
7
- let(:restricted_page) { create(:alchemy_page, :public, restricted: true) }
8
- let(:restricted_element) { create(:alchemy_element, page: restricted_page, name: 'download') }
9
-
10
- describe '#show' do
11
- it "should render available elements" do
12
- alchemy_get :show, id: element.id
13
- expect(response.status).to eq(200)
14
- end
15
-
16
- it "should raise ActiveRecord::RecordNotFound error for trashed elements" do
17
- element.trash!
18
- expect {
19
- alchemy_get :show, id: element.id
20
- }.to raise_error(ActiveRecord::RecordNotFound)
21
- end
22
-
23
- it "should raise ActiveRecord::RecordNotFound error for unpublished elements" do
24
- element.update_attributes(public: false)
25
- expect {
26
- alchemy_get :show, id: element.id
27
- }.to raise_error(ActiveRecord::RecordNotFound)
28
- end
29
-
30
- context "for guest user" do
31
- it "should raise ActiveRecord::RecordNotFound error for elements of restricted pages" do
32
- expect {
33
- alchemy_get :show, id: restricted_element.id
34
- }.to raise_error(ActiveRecord::RecordNotFound)
35
- end
36
- end
37
-
38
- context "for member user" do
39
- before { authorize_user(build(:alchemy_dummy_user)) }
40
-
41
- it "should render elements of restricted pages" do
42
- alchemy_get :show, id: restricted_element.id
43
- expect(response.status).to eq(200)
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,204 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe MessagesController do
5
- let(:page) { mock_model('Page') }
6
-
7
- before do
8
- controller.instance_variable_set(:@page, page)
9
- allow(controller).to receive(:get_page).and_return(page)
10
- end
11
-
12
- describe "#index" do
13
- let(:page) { mock_model('Page', {urlname: 'contact', page_layout: 'contact'}) }
14
-
15
- it "should redirect to @page" do
16
- expect(alchemy_get(:index)).to redirect_to(show_page_path(urlname: page.urlname))
17
- end
18
- end
19
-
20
- describe "#new" do
21
- it "should render the alchemy/pages/show template" do
22
- alchemy_get :new
23
- expect(alchemy_get(:new)).to render_template('alchemy/pages/show')
24
- end
25
- end
26
-
27
- describe "#create" do
28
- before do
29
- allow(controller).to receive(:params).and_return({message: {email: ''}})
30
- end
31
-
32
- let(:page) { mock_model('Page', get_language_root: mock_model('Page')) }
33
- let(:element) { mock_model('Element', page: page, ingredient: '') }
34
- let(:message) { Message.new }
35
-
36
- it "should raise ActiveRecord::RecordNotFound if element of contactform could not be found" do
37
- expect { alchemy_post :create }.to raise_error(ActiveRecord::RecordNotFound)
38
- end
39
-
40
- context "if validation of message" do
41
- before do
42
- allow(Element).to receive(:find_by).and_return(element)
43
- allow(element).to receive(:ingredient).with(:success_page).and_return('thank-you')
44
- allow_any_instance_of(Message).to receive(:contact_form_id).and_return(1)
45
- end
46
-
47
- context "failed" do
48
- before do
49
- allow_any_instance_of(Message).to receive(:valid?).and_return(false)
50
- end
51
-
52
- it "should render 'alchemy/pages/show' template" do
53
- expect(alchemy_post(:create)).to render_template('alchemy/pages/show')
54
- end
55
- end
56
-
57
- context "succeeded" do
58
- before do
59
- allow_any_instance_of(Message).to receive(:valid?).and_return(true)
60
- allow(Messages).to receive(:contact_form_mail).and_return double(deliver: true)
61
- end
62
-
63
- it "Messages should call Messages#contact_form_mail to send the email" do
64
- expect(Messages).to receive(:contact_form_mail)
65
- alchemy_post :create
66
- end
67
-
68
- describe '#mail_to' do
69
- context "with element having mail_to ingredient" do
70
- before do
71
- allow(element).to receive(:ingredient).with(:mail_to).and_return('peter@schroeder.de')
72
- message
73
- allow(Message).to receive(:new).and_return(message)
74
- end
75
-
76
- it "returns the ingredient" do
77
- expect(Messages).to receive(:contact_form_mail).with(message, 'peter@schroeder.de', '', '')
78
- alchemy_post :create
79
- end
80
- end
81
-
82
- context "with element having no mail_to ingredient" do
83
- before do
84
- allow(element).to receive(:ingredient).with(:mail_to).and_return(nil)
85
- message
86
- allow(Message).to receive(:new).and_return(message)
87
- end
88
-
89
- it "returns the config value" do
90
- expect(Messages).to receive(:contact_form_mail).with(message, 'your.mail@your-domain.com', '', '')
91
- alchemy_post :create
92
- end
93
- end
94
- end
95
-
96
- describe '#mail_from' do
97
- context "with element having mail_from ingredient" do
98
- before do
99
- allow(element).to receive(:ingredient).with(:mail_from).and_return('peter@schroeder.de')
100
- message
101
- allow(Message).to receive(:new).and_return(message)
102
- end
103
-
104
- it "returns the ingredient" do
105
- expect(Messages).to receive(:contact_form_mail).with(message, '', 'peter@schroeder.de', '')
106
- alchemy_post :create
107
- end
108
- end
109
-
110
- context "with element having no mail_from ingredient" do
111
- before do
112
- allow(element).to receive(:ingredient).with(:mail_from).and_return(nil)
113
- message
114
- allow(Message).to receive(:new).and_return(message)
115
- end
116
-
117
- it "returns the config value" do
118
- expect(Messages).to receive(:contact_form_mail).with(message, '', 'your.mail@your-domain.com', '')
119
- alchemy_post :create
120
- end
121
- end
122
- end
123
-
124
- describe '#subject' do
125
- context "with element having subject ingredient" do
126
- before do
127
- allow(element).to receive(:ingredient).with(:subject).and_return('A new message')
128
- message
129
- allow(Message).to receive(:new).and_return(message)
130
- end
131
-
132
- it "returns the ingredient" do
133
- expect(Messages).to receive(:contact_form_mail).with(message, '', '', 'A new message')
134
- alchemy_post :create
135
- end
136
- end
137
-
138
- context "with element having no subject ingredient" do
139
- before do
140
- allow(element).to receive(:ingredient).with(:subject).and_return(nil)
141
- message
142
- allow(Message).to receive(:new).and_return(message)
143
- end
144
-
145
- it "returns the config value" do
146
- expect(Messages).to receive(:contact_form_mail).with(message, '', '', 'A new contact form message')
147
- alchemy_post :create
148
- end
149
- end
150
- end
151
-
152
- describe "#redirect_to_success_page" do
153
- context "if 'success_page' ingredient of element is set with urlname" do
154
- before do
155
- allow(element).to receive(:ingredient).with(:success_page).and_return('success-page')
156
- end
157
-
158
- it "should redirect to the given urlname" do
159
- expect(
160
- alchemy_post(:create)
161
- ).to redirect_to(show_page_path(urlname: 'success-page'))
162
- end
163
- end
164
-
165
- context "if 'success_page' ingredient of element is not set" do
166
- before do
167
- allow(element).to receive(:ingredient).with(:success_page).and_return(nil)
168
- end
169
-
170
- context "but mailer_config['forward_to_page'] is true and mailer_config['mail_success_page'] is set" do
171
- before do
172
- allow(controller).to receive(:mailer_config).and_return({'forward_to_page' => true, 'mail_success_page' => 'mailer-config-success-page'})
173
- allow(Page).to receive(:find_by).and_return double(urlname: 'mailer-config-success-page')
174
- end
175
-
176
- it "redirect to the given success page" do
177
- expect(
178
- alchemy_post(:create)
179
- ).to redirect_to(show_page_path(urlname: 'mailer-config-success-page'))
180
- end
181
- end
182
-
183
- context "and mailer_config has no instructions for success_page" do
184
- let(:language) { mock_model('Language', code: 'en', locale: 'en', pages: double(find_by: build_stubbed(:alchemy_page))) }
185
-
186
- before do
187
- allow(controller).to receive(:mailer_config).and_return({})
188
- allow(Language).to receive(:current_root_page).and_return double(urlname: 'lang-root')
189
- end
190
-
191
- it "should redirect to the language root page" do
192
- allow(Language).to receive(:current).and_return(language)
193
- expect(
194
- alchemy_post(:create)
195
- ).to redirect_to(show_page_path(urlname: 'lang-root'))
196
- end
197
- end
198
- end
199
- end
200
- end
201
- end
202
- end
203
- end
204
- end
@@ -1,330 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Alchemy::PagesController, 'OnPageLayout mixin', type: :controller do
4
- before(:all) do
5
- ApplicationController.send(:extend, Alchemy::OnPageLayout)
6
- end
7
-
8
- let(:page) { create(:alchemy_page, :public, page_layout: 'standard') }
9
-
10
- describe '.on_page_layout' do
11
- context 'with :all as argument for page_layout' do
12
- before do
13
- ApplicationController.class_eval do
14
- on_page_layout(:all) do
15
- @on_all_layouts = @page.page_layout
16
- end
17
- end
18
- end
19
-
20
- context "for show action" do
21
- %w(standard news).each do |page_layout|
22
- it "runs callback on #{page_layout} layout" do
23
- page = create(:alchemy_page, :public, page_layout: page_layout)
24
- alchemy_get :show, urlname: page.urlname
25
- expect(assigns(:on_all_layouts)).to eq(page_layout)
26
- end
27
- end
28
- end
29
-
30
- context "for index action" do
31
- %w(standard news).each do |page_layout|
32
- it "runs callback on #{page_layout} layout" do
33
- create(:alchemy_page, :language_root, page_layout: page_layout)
34
-
35
- alchemy_get :index
36
- expect(assigns(:on_all_layouts)).to eq(page_layout)
37
- end
38
- end
39
- end
40
- end
41
-
42
- context 'with :standard as argument for page_layout' do
43
- before do
44
- ApplicationController.class_eval do
45
- on_page_layout(:standard) do
46
- @successful_for_standard = true
47
- end
48
- end
49
- end
50
-
51
- context 'and page having standard layout' do
52
- context "for show action" do
53
- let(:page) { create(:alchemy_page, :public, page_layout: 'standard') }
54
-
55
- it 'runs the callback' do
56
- alchemy_get :show, urlname: page.urlname
57
- expect(assigns(:successful_for_standard)).to eq(true)
58
- end
59
- end
60
-
61
- context "for index action" do
62
- let!(:page) { create(:alchemy_page, :language_root, page_layout: 'standard') }
63
-
64
- it 'runs the callback' do
65
- alchemy_get :index
66
- expect(assigns(:successful_for_standard)).to eq(true)
67
- end
68
- end
69
- end
70
-
71
- context 'and page not having standard layout' do
72
- let(:page) { create(:alchemy_page, :public, page_layout: 'news') }
73
-
74
- context "for show action" do
75
- it "doesn't run the callback" do
76
- alchemy_get :show, urlname: page.urlname
77
- expect(assigns(:successful_for_standard)).to eq(nil)
78
- end
79
- end
80
-
81
- context "for index action" do
82
- let!(:page) { create(:alchemy_page, :language_root, page_layout: 'news') }
83
-
84
- it "doesn't run the callback" do
85
- alchemy_get :index
86
- expect(assigns(:successful_for_standard)).to eq(nil)
87
- end
88
- end
89
- end
90
- end
91
-
92
- context 'when defining two callbacks for different page layouts' do
93
- context "for show action" do
94
- before do
95
- ApplicationController.class_eval do
96
- on_page_layout(:standard) do
97
- @urlname = @page.urlname
98
- end
99
-
100
- on_page_layout(:news) do
101
- @urlname = @page.urlname
102
- end
103
- end
104
- end
105
-
106
- %w(standard news).each do |page_layout|
107
- it "runs both callbacks for #{page_layout} layout" do
108
- page = create(:alchemy_page, :public, page_layout: page_layout)
109
-
110
- alchemy_get :show, urlname: page.urlname
111
- expect(assigns(:urlname)).to eq(page.urlname)
112
- end
113
- end
114
- end
115
-
116
- context "for index action" do
117
- before do
118
- ApplicationController.class_eval do
119
- on_page_layout(:standard) do
120
- @page_layout = @page.page_layout
121
- end
122
-
123
- on_page_layout(:news) do
124
- @page_layout = @page.page_layout
125
- end
126
- end
127
- end
128
-
129
- %w(standard news).each do |page_layout|
130
- it "runs both callbacks on #{page_layout} layout" do
131
- create(:alchemy_page, :language_root, page_layout: page_layout)
132
-
133
- alchemy_get :index
134
- expect(assigns(:page_layout)).to eq(page_layout)
135
- end
136
- end
137
- end
138
- end
139
-
140
- context 'when defining two callbacks for the same page_layout' do
141
- before do
142
- ApplicationController.class_eval do
143
- on_page_layout(:standard) do
144
- @successful_for_standard_first = true
145
- end
146
-
147
- on_page_layout(:standard) do
148
- @successful_for_standard_second = true
149
- end
150
- end
151
- end
152
-
153
- context "for show action" do
154
- it 'runs both callbacks' do
155
- alchemy_get :show, urlname: page.urlname
156
- expect(assigns(:successful_for_standard_first)).to eq(true)
157
- expect(assigns(:successful_for_standard_second)).to eq(true)
158
- end
159
- end
160
-
161
- context "for index action" do
162
- let!(:page) { create(:alchemy_page, :language_root, page_layout: 'standard') }
163
-
164
- it 'runs both callbacks' do
165
- alchemy_get :index
166
- expect(assigns(:successful_for_standard_first)).to eq(true)
167
- expect(assigns(:successful_for_standard_second)).to eq(true)
168
- end
169
- end
170
- end
171
-
172
- context 'when block is given' do
173
- before do
174
- ApplicationController.class_eval do
175
- on_page_layout :standard do
176
- @successful_for_callback_method = true
177
- end
178
- end
179
- end
180
-
181
- context 'for show action' do
182
- it 'evaluates the given block' do
183
- alchemy_get :show, urlname: page.urlname
184
- expect(assigns(:successful_for_callback_method)).to eq(true)
185
- end
186
- end
187
-
188
- context 'for index action' do
189
- let!(:page) { create(:alchemy_page, :language_root, page_layout: 'standard') }
190
-
191
- it 'evaluates the given block' do
192
- alchemy_get :index
193
- expect(assigns(:successful_for_callback_method)).to eq(true)
194
- end
195
- end
196
- end
197
-
198
- context 'when callback method name is given' do
199
- before do
200
- ApplicationController.class_eval do
201
- on_page_layout :standard, :run_method
202
-
203
- def run_method
204
- @successful_for_callback_method = true
205
- end
206
- end
207
- end
208
-
209
- context 'for show action' do
210
- it 'runs the given callback method' do
211
- alchemy_get :show, urlname: page.urlname
212
- expect(assigns(:successful_for_callback_method)).to eq(true)
213
- end
214
- end
215
-
216
- context 'for index action' do
217
- let!(:page) { create(:alchemy_page, :language_root, page_layout: 'standard') }
218
-
219
- it 'runs the given callback method' do
220
- alchemy_get :index
221
- expect(assigns(:successful_for_callback_method)).to eq(true)
222
- end
223
- end
224
- end
225
-
226
- context 'when neither callback method name nor block given' do
227
- it 'raises an ArgumentError' do
228
- expect do
229
- ApplicationController.class_eval do
230
- on_page_layout :standard
231
- end
232
- end.to raise_error(ArgumentError)
233
- end
234
- end
235
-
236
- context 'when passing two page_layouts for a callback' do
237
- before do
238
- ApplicationController.class_eval do
239
- on_page_layout([:standard, :news]) do
240
- @successful = @page.page_layout
241
- end
242
- end
243
- end
244
-
245
- %w(standard news).each do |page_layout|
246
- it 'evaluates the given callback on both page_layouts for show action' do
247
- page = create(:alchemy_page, :public, page_layout: page_layout)
248
-
249
- alchemy_get :show, urlname: page.urlname
250
- expect(assigns(:successful)).to eq(page_layout)
251
- end
252
- end
253
-
254
- %w(standard news).each do |page_layout|
255
- it 'evaluates the given callback on both page_layouts for index action' do
256
- create(:alchemy_page, :language_root, page_layout: page_layout)
257
-
258
- alchemy_get :index
259
- expect(assigns(:successful)).to eq(page_layout)
260
- end
261
- end
262
- end
263
- end
264
- end
265
-
266
- RSpec.describe ApplicationController, 'OnPageLayout mixin', type: :controller do
267
- before(:all) do
268
- ApplicationController.send(:extend, Alchemy::OnPageLayout)
269
- end
270
-
271
- controller do
272
- def index
273
- @another_controller = true
274
- render nothing: true
275
- end
276
- end
277
-
278
- context 'in another controller' do
279
- before do
280
- ApplicationController.class_eval do
281
- on_page_layout(:standard) do
282
- @successful_for_another_controller = true
283
- end
284
- end
285
- end
286
-
287
- it 'callback does not run' do
288
- get :index
289
- expect(assigns(:another_controller)).to eq(true)
290
- expect(assigns(:successful_for_another_controller)).to eq(nil)
291
- end
292
- end
293
- end
294
-
295
- RSpec.describe Alchemy::Admin::PagesController, 'OnPageLayout mixin', type: :controller do
296
- before(:all) do
297
- ApplicationController.send(:extend, Alchemy::OnPageLayout)
298
- end
299
-
300
- context 'in admin/pages_controller' do
301
- before do
302
- ApplicationController.class_eval do
303
- on_page_layout(:standard) do
304
- @successful_for_alchemy_admin_pages_controller = true
305
- end
306
- end
307
- authorize_user(:as_admin)
308
- end
309
-
310
- context "for show action" do
311
- let(:page) { create(:alchemy_page, page_layout: 'standard') }
312
-
313
- it 'callback also runs' do
314
- alchemy_get :show, id: page.id
315
- expect(assigns(:successful_for_alchemy_admin_pages_controller)).to be(true)
316
- end
317
- end
318
-
319
- context "for index action" do
320
- it 'does not run callback' do
321
- alchemy_get :index
322
- expect(assigns(:successful_for_alchemy_admin_pages_controller)).to be(nil)
323
- end
324
- end
325
- end
326
-
327
- after(:all) do
328
- Alchemy::OnPageLayout.instance_variable_set(:@callbacks, nil)
329
- end
330
- end