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,314 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe Admin::ElementsHelper do
5
- let(:page) { build_stubbed(:alchemy_page, :public) }
6
- let(:element) { build_stubbed(:alchemy_element, page: page) }
7
-
8
- context "partial rendering" do
9
- it "should render an element editor partial" do
10
- expect(helper).to receive(:render_element).with(element, :editor)
11
- helper.render_editor(element)
12
- end
13
-
14
- it "should render a picture gallery editor partial" do
15
- expect(render_picture_gallery_editor(element)).to match(/class=".+picture_gallery_editor"/)
16
- end
17
- end
18
-
19
- describe "#grouped_elements_for_select" do
20
- let(:elements) do
21
- [
22
- mock_model('Element', name: '1', display_name: '1'),
23
- mock_model('Element', name: '2', display_name: '2')
24
- ]
25
- end
26
- let(:element_definitions) { [{"name" => "1"}, {"name" => "2"}] }
27
- let(:cell_definitions) { [] }
28
- let(:page_definition) { {} }
29
-
30
- before do
31
- allow(page).to receive(:definition).and_return(page_definition)
32
- allow(Cell).to receive(:definitions).and_return(cell_definitions)
33
- allow(Element).to receive(:definitions).and_return(element_definitions)
34
- helper.instance_variable_set('@page', page)
35
- end
36
-
37
- context "with empty elements array given" do
38
- it "return an empty array" do
39
- expect(helper.grouped_elements_for_select([])).to eq([])
40
- end
41
- end
42
-
43
- context "with an element collection given" do
44
- let(:page_definition) do
45
- {'name' => "foo", 'cells' => ["foo_cell"], 'elements' => []}
46
- end
47
-
48
- let(:cell_definitions) do
49
- [{'name' => "foo_cell", 'elements' => ["1", "2"]}]
50
- end
51
-
52
- it "returns an array of elements grouped by cell for select_tag helper" do
53
- expect(helper.grouped_elements_for_select(elements)).to eq("Foo cell" => [["1", "1#foo_cell"], ["2", "2#foo_cell"]])
54
- end
55
-
56
- context "without cells key in page definition" do
57
- let(:page_definition) do
58
- {'name' => "foo", "elements" => ["1", "2"]}
59
- end
60
-
61
- it "returns an empty array" do
62
- expect(helper.grouped_elements_for_select(elements)).to eq([])
63
- end
64
- end
65
-
66
- context "with empty cells in page definition" do
67
- let(:page_definition) do
68
- {"name" => "foo", "cells" => [], "elements" => ["1", "2"]}
69
- end
70
-
71
- it "returns an empty array" do
72
- expect(helper.grouped_elements_for_select(elements)).to eq([])
73
- end
74
- end
75
-
76
- context "with a cell containing no elements" do
77
- let(:cell_definitions) do
78
- [{"name" => "empty_cell", "elements" => []}]
79
- end
80
-
81
- let(:page_definition) do
82
- {"name" => "foo", "cells" => ["empty_cell"], "elements" => ["1", "2"]}
83
- end
84
-
85
- it "does not include that cell" do
86
- expect(helper.grouped_elements_for_select(elements)).to eq("Main content" => [["1", "1"], ["2", "2"]])
87
- end
88
- end
89
-
90
- context "with an element in a cell only" do
91
- let(:elements) do
92
- [mock_model('Element', name: 'in_cell', display_name: 'In Cell')]
93
- end
94
-
95
- let(:page_definition) do
96
- {'name' => "foo", 'cells' => ["foo_cell"], 'elements' => []}
97
- end
98
-
99
- let(:cell_definitions) do
100
- [{'name' => "foo_cell", 'elements' => ["in_cell"]}]
101
- end
102
-
103
- it "returns an option for the element in the cell only" do
104
- expect(helper.grouped_elements_for_select(elements)).to include("Foo cell" => [["In cell", "in_cell#foo_cell"]])
105
- end
106
- end
107
-
108
- context "with the same element in both cell and page" do
109
- let(:element_definitions) do
110
- [{"name" => "in_cell_and_page"}]
111
- end
112
-
113
- let(:elements) do
114
- [mock_model('Element', name: 'in_cell_and_page', display_name: 'In Cell and Page')]
115
- end
116
-
117
- let(:page_definition) do
118
- {
119
- 'name' => "foo",
120
- 'cells' => ["foo_cell"],
121
- 'elements' => ["in_cell_and_page"]
122
- }
123
- end
124
-
125
- let(:cell_definitions) do
126
- [{
127
- 'name' => "foo_cell",
128
- 'elements' => ["in_cell_and_page"]
129
- }]
130
- end
131
-
132
- it "returns two options of same element, one for the cell and one for the page" do
133
- expect(helper.grouped_elements_for_select(elements)).to eq({
134
- "Main content" => [["In cell and page", "in_cell_and_page"]],
135
- "Foo cell" => [["In cell and page", "in_cell_and_page#foo_cell"]]
136
- })
137
- end
138
- end
139
- end
140
- end
141
-
142
- describe "#elements_for_select" do
143
- context "passing element instances" do
144
- let(:element_objects) do
145
- [
146
- mock_model('Element', name: 'element_1', display_name: 'Element 1'),
147
- mock_model('Element', name: 'element_2', display_name: 'Element 2')
148
- ]
149
- end
150
-
151
- it "should return a array for option tags" do
152
- expect(helper.elements_for_select(element_objects)).to include(['Element 1', 'element_1'])
153
- expect(helper.elements_for_select(element_objects)).to include(['Element 2', 'element_2'])
154
- end
155
- end
156
-
157
- context "passing a hash with element definitions" do
158
- let(:element_definitions) do
159
- [{
160
- 'name' => 'headline',
161
- 'contents' => []
162
- }]
163
- end
164
-
165
- subject { helper.elements_for_select(element_definitions) }
166
-
167
- it "should return a array for option tags" do
168
- expect(subject).to include(['Headline', 'headline'])
169
- end
170
-
171
- it "should render the elements display name" do
172
- expect(Element).to receive(:display_name_for).with('headline')
173
- subject
174
- end
175
- end
176
- end
177
-
178
- describe '#element_editor_classes' do
179
- subject { element_editor_classes(element, locals) }
180
-
181
- let(:element) { build_stubbed(:alchemy_element) }
182
- let(:locals) { Hash.new }
183
-
184
- it "returns css classes for element editor partial" do
185
- is_expected.to include('element-editor')
186
- end
187
-
188
- context 'with draggable in locals set to true' do
189
- let(:locals) { {draggable: true} }
190
- it { is_expected.to include('draggable') }
191
- end
192
-
193
- context 'with draggable in locals set to false' do
194
- let(:locals) { {draggable: false} }
195
- it { is_expected.to include('not-draggable') }
196
- end
197
-
198
- context 'with draggable in locals set to nil' do
199
- let(:locals) { {draggable: nil} }
200
- it { is_expected.to include('draggable') }
201
- end
202
-
203
- context 'with element is folded' do
204
- let(:element) { build_stubbed(:alchemy_element, folded: true) }
205
- it { is_expected.to include('folded') }
206
- end
207
-
208
- context 'with element is expanded' do
209
- let(:element) { build_stubbed(:alchemy_element, folded: false) }
210
- it { is_expected.to include('expanded') }
211
- end
212
-
213
- context 'with element is taggable' do
214
- before do
215
- allow(element).to receive(:taggable?) { true }
216
- end
217
-
218
- it { is_expected.to include('taggable') }
219
- end
220
-
221
- context 'with element is not taggable' do
222
- before do
223
- allow(element).to receive(:taggable?) { false }
224
- end
225
-
226
- it { is_expected.to include('not-taggable') }
227
- end
228
-
229
- context 'with element having content_definitions' do
230
- before do
231
- allow(element).to receive(:content_definitions) { [1] }
232
- end
233
-
234
- it { is_expected.to include('with-contents') }
235
- end
236
-
237
- context 'with element not having content_definitions' do
238
- before do
239
- allow(element).to receive(:content_definitions) { [] }
240
- end
241
-
242
- it { is_expected.to include('without-contents') }
243
- end
244
-
245
- context 'with element having nestable_elements' do
246
- before do
247
- allow(element).to receive(:nestable_elements) { [1] }
248
- end
249
-
250
- it { is_expected.to include('nestable') }
251
- end
252
-
253
- context 'with element not having nestable_elements' do
254
- before do
255
- allow(element).to receive(:nestable_elements) { [] }
256
- end
257
-
258
- it { is_expected.to include('not-nestable') }
259
- end
260
- end
261
-
262
- describe "#show_element_footer?" do
263
- subject { show_element_footer?(element, nestable_elements) }
264
- let(:element) { build_stubbed(:alchemy_element) }
265
- let(:nestable_elements) { nil }
266
-
267
- context "for folded element" do
268
- before { allow(element).to receive(:folded?) { true } }
269
- it { is_expected.to eq(false) }
270
- end
271
-
272
- context "for expanded element" do
273
- before { allow(element).to receive(:folded?) { false } }
274
-
275
- context "with nestable_elements argument" do
276
- let(:nestable_elements) { true }
277
-
278
- context "and element having contents defined" do
279
- before { allow(element).to receive(:content_definitions) { [1] } }
280
- it { is_expected.to eq(true) }
281
- end
282
-
283
- context "and element having no contents defined" do
284
- before { allow(element).to receive(:content_definitions) { [] } }
285
-
286
- context "and element beeing taggable" do
287
- before { allow(element).to receive(:taggable?) { true } }
288
- it { is_expected.to eq(true) }
289
- end
290
-
291
- context "and element not beeing taggable" do
292
- before { allow(element).to receive(:taggable?) { false } }
293
- it { is_expected.to eq(false) }
294
- end
295
- end
296
- end
297
-
298
- context "without nestable_elements argument" do
299
- let(:nestable_elements) { nil }
300
-
301
- context "and element having no nestable elements defined" do
302
- before { allow(element).to receive(:nestable_elements) { [] } }
303
- it { is_expected.to eq(true) }
304
- end
305
-
306
- context "and element having nestable elements defined" do
307
- before { allow(element).to receive(:nestable_elements) { [1] } }
308
- it { is_expected.to eq(false) }
309
- end
310
- end
311
- end
312
- end
313
- end
314
- end
@@ -1,201 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Alchemy::Admin::EssencesHelper do
4
- include Alchemy::Admin::ElementsHelper
5
-
6
- let(:element) do
7
- create(:alchemy_element, name: 'article', create_contents_after_create: true)
8
- end
9
-
10
- describe 'essence rendering' do
11
- before do
12
- if element
13
- element.content_by_name('intro').essence.update(body: 'hello!')
14
- end
15
- end
16
-
17
- describe '#render_essence_editor' do
18
- it "should render an essence editor" do
19
- content = element.content_by_name('intro')
20
- expect(helper.render_essence_editor(content)).
21
- to match(/input.+type="text".+value="hello!/)
22
- end
23
- end
24
-
25
- describe '#render_essence_editor_by_name' do
26
- subject { render_essence_editor_by_name(element, content) }
27
-
28
- let(:content) { 'intro' }
29
-
30
- it "renders an essence editor by given name" do
31
- is_expected.to match(/input.+type="text".+value="hello!/)
32
- end
33
-
34
- context 'when element is nil' do
35
- let(:element) { nil }
36
-
37
- it "displays a warning" do
38
- is_expected.to have_selector(".content_editor_error")
39
- is_expected.to have_content("No element given.")
40
- end
41
- end
42
-
43
- context 'when content is not found on element' do
44
- let(:content) { 'sputz' }
45
-
46
- it "displays a warning" do
47
- is_expected.to have_selector(".content_editor.missing")
48
- end
49
- end
50
- end
51
- end
52
-
53
- describe '#pages_for_select' do
54
- let(:contact_form) do
55
- create(:alchemy_element, name: 'contactform', create_contents_after_create: true)
56
- end
57
-
58
- let(:page_a) { create(:alchemy_page, :public, name: 'Page A') }
59
- let(:page_b) { create(:alchemy_page, :public, name: 'Page B') }
60
- let(:page_c) { create(:alchemy_page, :public, name: 'Page C', parent_id: page_b.id) }
61
-
62
- before do
63
- # to be shure the ordering is alphabetic
64
- page_b
65
- page_a
66
- helper.session[:alchemy_language_id] = 1
67
- end
68
-
69
- context "with no arguments given" do
70
- it "should return options for select with all pages ordered by lft" do
71
- expect(helper.pages_for_select).to match(/option.*Page B.*Page A/m)
72
- end
73
-
74
- it "should return options for select with nested page names" do
75
- page_c
76
- output = helper.pages_for_select
77
- expect(output).to match(/option.*Startseite.*>  Page B.*>    Page C.*>  Page A/m)
78
- end
79
- end
80
-
81
- context "with pages passed in" do
82
- before do
83
- @pages = []
84
- 3.times { @pages << create(:alchemy_page, :public) }
85
- end
86
-
87
- it "should return options for select with only these pages" do
88
- output = helper.pages_for_select(@pages)
89
- expect(output).to match(/#{@pages.collect(&:name).join('.*')}/m)
90
- expect(output).not_to match(/Page A/m)
91
- end
92
-
93
- it "should not nest the page names" do
94
- output = helper.pages_for_select(@pages)
95
- expect(output).not_to match(/option.*&nbsp;/m)
96
- end
97
- end
98
- end
99
-
100
- describe '#essence_picture_thumbnail' do
101
- let(:content) { build_stubbed(:alchemy_content, essence: build_stubbed(:alchemy_essence_picture)) }
102
-
103
- it "should return an image tag" do
104
- expect(helper.essence_picture_thumbnail(content, {})).to have_selector('img[src]')
105
- end
106
-
107
- context 'when given content has no ingredient' do
108
- before { allow(content).to receive(:ingredient).and_return(nil) }
109
-
110
- it "should return nil" do
111
- expect(helper.essence_picture_thumbnail(content, {})).to eq(nil)
112
- end
113
- end
114
-
115
- context 'when the picture given has a size of 140x169 and it should be cropped to 250x250' do
116
- before do
117
- allow(content.essence).to receive(:image_file_width).and_return(140)
118
- allow(content.essence).to receive(:image_file_height).and_return(169)
119
- end
120
-
121
- it 'the thumbnail url should contain 77 and 93 as thumbnail width and height' do
122
- expect(helper.essence_picture_thumbnail(content, {image_size: "250x250", crop: true})).to match(/77x93/)
123
- end
124
-
125
- it 'the thumbnail url should contain 77 and 93 as thumbnail width and height' do
126
- expect(helper.essence_picture_thumbnail(content, {image_size: "250x250"})).to match(/77x93/)
127
- end
128
- end
129
-
130
- context 'when the picture given has a size of 300x50 and it should be cropped/resized to 225x175' do
131
- before do
132
- allow(content.essence).to receive(:image_file_width).and_return(300)
133
- allow(content.essence).to receive(:image_file_height).and_return(50)
134
- end
135
-
136
- it 'the thumbnail url should contain 111x25 as thumbnail width and height' do
137
- expect(helper.essence_picture_thumbnail(content, { size: "225x175", crop: true})).to match(/111x25/)
138
- end
139
-
140
- it 'the thumbnail url should contain 111x19 as thumbnail width and height' do
141
- expect(helper.essence_picture_thumbnail(content, { size: "225x175"})).to match(/111x19/)
142
- end
143
- end
144
- end
145
-
146
- describe "#edit_picture_dialog_size" do
147
- let(:content) { build_stubbed(:alchemy_content) }
148
-
149
- subject { edit_picture_dialog_size(content) }
150
-
151
- context "with content having setting caption_as_textarea being true and sizes set" do
152
- before do
153
- allow(content).to receive(:settings) do
154
- {
155
- caption_as_textarea: true,
156
- sizes: ['100x100', '200x200']
157
- }
158
- end
159
-
160
- it { is_expected.to eq("380x320") }
161
- end
162
- end
163
-
164
- context "with content having setting caption_as_textarea being true and no sizes set" do
165
- before do
166
- allow(content).to receive(:settings) do
167
- {
168
- caption_as_textarea: true
169
- }
170
- end
171
-
172
- it { is_expected.to eq("380x300") }
173
- end
174
- end
175
-
176
- context "with content having setting caption_as_textarea being false and sizes set" do
177
- before do
178
- allow(content).to receive(:settings) do
179
- {
180
- caption_as_textarea: false,
181
- sizes: ['100x100', '200x200']
182
- }
183
- end
184
-
185
- it { is_expected.to eq("380x290") }
186
- end
187
- end
188
-
189
- context "with content having setting caption_as_textarea being false and no sizes set" do
190
- before do
191
- allow(content).to receive(:settings) do
192
- {
193
- caption_as_textarea: false
194
- }
195
- end
196
-
197
- it { is_expected.to eq("380x255") }
198
- end
199
- end
200
- end
201
- end