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,193 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe Admin::AttachmentsController do
5
- let(:attachment) { build_stubbed(:alchemy_attachment) }
6
-
7
- before do
8
- authorize_user(:as_admin)
9
- end
10
-
11
- describe "#index" do
12
- it "should always paginate the records" do
13
- expect_any_instance_of(ActiveRecord::Relation).to receive(:page).and_call_original
14
- alchemy_get :index
15
- end
16
-
17
- context "when params[:tagged_with] is set" do
18
- it "should filter the records by tags" do
19
- expect(Attachment).to receive(:tagged_with).and_return(Attachment.all)
20
- alchemy_get :index, tagged_with: "pdf"
21
- end
22
- end
23
-
24
- context "when params[:content_id]" do
25
- let(:content) { mock_model(Content) }
26
-
27
- context "is set" do
28
- it "it renders the archive_overlay partial" do
29
- expect(Content).to receive(:find_by).and_return(content)
30
- alchemy_get :index, {content_id: content.id}
31
- expect(response).to render_template(partial: '_archive_overlay')
32
- expect(assigns(:content)).to eq(content)
33
- end
34
- end
35
-
36
- context "is not set" do
37
- it "should render the default index view" do
38
- alchemy_get :index
39
- expect(response).to render_template(:index)
40
- end
41
- end
42
- end
43
-
44
- describe 'only and expect options' do
45
- let!(:png) { create(:alchemy_attachment) }
46
- let!(:jpg) { create(:alchemy_attachment, file: File.new(File.expand_path('../../../../fixtures/image3.jpeg', __FILE__))) }
47
-
48
- context 'with params[:only]' do
49
- it 'only loads attachments with matching content type' do
50
- alchemy_get :index, only: 'jpeg'
51
- expect(assigns(:attachments).to_a).to eq([jpg])
52
- expect(assigns(:attachments).to_a).to_not eq([png])
53
- end
54
- end
55
-
56
- context 'with params[:except]' do
57
- it 'does not load attachments with matching content type' do
58
- alchemy_get :index, except: 'jpeg'
59
- expect(assigns(:attachments).to_a).to eq([png])
60
- expect(assigns(:attachments).to_a).to_not eq([jpg])
61
- end
62
- end
63
- end
64
- end
65
-
66
- describe '#show' do
67
- before do
68
- expect(Attachment).to receive(:find).and_return(attachment)
69
- end
70
-
71
- it "renders the show template" do
72
- alchemy_get :show, id: attachment.id
73
- expect(response).to render_template(:show)
74
- end
75
- end
76
-
77
- describe '#create' do
78
- subject { alchemy_post :create, params }
79
-
80
- let(:attachment) { mock_model('Attachment', name: 'contract.pdf', to_jq_upload: {}) }
81
- let(:params) { {attachment: {name: ''}} }
82
-
83
- context 'with passing validations' do
84
- before do
85
- expect(Attachment).to receive(:new).and_return(attachment)
86
- expect(attachment).to receive(:save).and_return(true)
87
- end
88
-
89
- it "renders json response with success message" do
90
- subject
91
- expect(response.content_type).to eq('application/json')
92
- expect(response.status).to eq(201)
93
- json = JSON.parse(response.body)
94
- expect(json).to have_key('growl_message')
95
- expect(json).to have_key('files')
96
- end
97
- end
98
-
99
- context 'without passing validations' do
100
- it "renders json response with error message" do
101
- subject
102
- expect(response.content_type).to eq('application/json')
103
- expect(response.status).to eq(422)
104
- json = JSON.parse(response.body)
105
- expect(json).to have_key('growl_message')
106
- expect(json).to have_key('files')
107
- end
108
- end
109
- end
110
-
111
- describe '#update' do
112
- subject { alchemy_put :update, {id: 1, attachment: {name: ''}} }
113
-
114
- let(:attachment) { build_stubbed(:alchemy_attachment) }
115
-
116
- before do
117
- expect(Attachment).to receive(:find).and_return(attachment)
118
- end
119
-
120
- context 'with passing validations' do
121
- before do
122
- expect(attachment).to receive(:update_attributes).and_return(true)
123
- end
124
-
125
- it "redirects to index path" do
126
- is_expected.to redirect_to admin_attachments_path
127
- end
128
-
129
- context 'with search params' do
130
- let(:search_params) do
131
- {
132
- q: {name_cont: 'kitten'},
133
- per_page: 20,
134
- page: 2
135
- }
136
- end
137
-
138
- subject do
139
- alchemy_put :update, {id: 1, attachment: {name: ''}}.merge(search_params)
140
- end
141
-
142
- it "passes them along" do
143
- is_expected.to redirect_to admin_attachments_path(search_params)
144
- end
145
- end
146
- end
147
-
148
- context 'with failing validations' do
149
- before do
150
- expect(attachment).to receive(:update_attributes).and_return(false)
151
- expect(attachment).to receive(:errors).and_return double(empty?: false)
152
- end
153
-
154
- it "renders edit form" do
155
- is_expected.to render_template(:edit)
156
- end
157
- end
158
- end
159
-
160
- describe '#destroy' do
161
- let(:attachment) { build_stubbed(:alchemy_attachment) }
162
-
163
- before do
164
- expect(Attachment).to receive(:find).and_return(attachment)
165
- end
166
-
167
- it "destroys the attachment and sets and success message" do
168
- expect(attachment).to receive(:destroy)
169
- alchemy_xhr :delete, :destroy, id: 1
170
- expect(assigns(:attachment)).to eq(attachment)
171
- expect(assigns(:url)).not_to be_blank
172
- expect(flash[:notice]).not_to be_blank
173
- end
174
- end
175
-
176
- describe "#download" do
177
- before do
178
- expect(Attachment).to receive(:find).with(attachment.id.to_s).and_return(attachment)
179
- allow(controller).to receive(:render).and_return(nil)
180
- end
181
-
182
- it "should assign @attachment with Attachment found by id" do
183
- alchemy_get :download, id: attachment.id
184
- expect(assigns(:attachment)).to eq(attachment)
185
- end
186
-
187
- it "should send the data to the browser" do
188
- expect(controller).to receive(:send_file)
189
- alchemy_get :download, id: attachment.id
190
- end
191
- end
192
- end
193
- end
@@ -1,87 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Alchemy::Admin::BaseController do
4
- describe '#options_from_params' do
5
- subject { controller.send(:options_from_params) }
6
-
7
- context "params[:options] is a JSON string" do
8
- before { expect(controller).to receive(:params).at_least(:once).and_return(options: '{"hallo":"World"}') }
9
-
10
- it "parses the string into an object" do
11
- expect(subject).to be_an_instance_of(Hash)
12
- expect(subject).to eq({hallo: 'World'})
13
- end
14
- end
15
-
16
- context "params[:options] is already an object" do
17
- before { expect(controller).to receive(:params).at_least(:once).and_return(options: {hallo: "World"}) }
18
-
19
- it "parses the string into an object" do
20
- expect(subject).to be_an_instance_of(Hash)
21
- end
22
- end
23
-
24
- context "params[:options] is not present" do
25
- before { expect(controller).to receive(:params).at_least(:once).and_return({}) }
26
-
27
- it "returns ampty object" do
28
- expect(subject).to be_an_instance_of(Hash)
29
- expect(subject).to eq({})
30
- end
31
- end
32
- end
33
-
34
- describe '#raise_exception?' do
35
- subject { controller.send(:raise_exception?) }
36
-
37
- context 'in test mode' do
38
- before { expect(Rails.env).to receive(:test?).and_return true }
39
- it { is_expected.to be_truthy }
40
- end
41
-
42
- context 'not in test mode' do
43
- before { expect(Rails.env).to receive(:test?).and_return false }
44
- it { is_expected.to be_falsey }
45
-
46
- context 'and in page preview' do
47
- before { expect(controller).to receive(:is_page_preview?).and_return true }
48
- it { is_expected.to be_truthy }
49
- end
50
-
51
- context 'and not in page preview' do
52
- before { expect(controller).to receive(:is_page_preview?).and_return false }
53
- it { is_expected.to be_falsey }
54
- end
55
- end
56
- end
57
-
58
- describe '#is_page_preview?' do
59
- subject { controller.send(:is_page_preview?) }
60
-
61
- it { is_expected.to be_falsey }
62
-
63
- context 'is pages controller and show action' do
64
- before do
65
- expect(controller).to receive(:controller_path).and_return('alchemy/admin/pages')
66
- expect(controller).to receive(:action_name).and_return('show')
67
- end
68
-
69
- it { is_expected.to be_truthy }
70
- end
71
- end
72
-
73
- context 'when current_alchemy_user is present' do
74
- let!(:page) { create(:alchemy_page) }
75
- let!(:user) { create(:alchemy_dummy_user, :as_admin) }
76
-
77
- before do
78
- allow(controller).to receive(:current_alchemy_user) { user }
79
- page.lock_to!(user)
80
- end
81
-
82
- it 'loads locked pages' do
83
- controller.send(:load_locked_pages)
84
- expect(assigns(:locked_pages)).to include(page)
85
- end
86
- end
87
- end
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe Admin::ClipboardController do
5
- let(:public_page) { build_stubbed(:alchemy_page, :public) }
6
- let(:element) { build_stubbed(:alchemy_element, page: public_page) }
7
- let(:another_element) { build_stubbed(:alchemy_element, page: public_page) }
8
-
9
- before do
10
- authorize_user(:as_admin)
11
- session[:alchemy_clipboard] = {}
12
- end
13
-
14
- context 'for elements' do
15
- before do
16
- expect(Element).to receive(:find).and_return(element)
17
- end
18
-
19
- describe "#insert" do
20
- it "should hold element ids" do
21
- alchemy_xhr :post, :insert, {remarkable_type: 'elements', remarkable_id: element.id}
22
- expect(session[:alchemy_clipboard]['elements']).to eq([{'id' => element.id.to_s, 'action' => 'copy'}])
23
- end
24
-
25
- it "should not have the same element twice" do
26
- session[:alchemy_clipboard]['elements'] = [{'id' => element.id.to_s, 'action' => 'copy'}]
27
- alchemy_xhr :post, :insert, {remarkable_type: 'elements', remarkable_id: element.id}
28
- expect(session[:alchemy_clipboard]['elements'].collect { |e| e['id'] }).not_to eq([element.id, element.id])
29
- end
30
- end
31
-
32
- describe "#delete" do
33
- it "should remove element ids from clipboard" do
34
- session[:alchemy_clipboard]['elements'] = [{'id' => element.id.to_s, 'action' => 'copy'}]
35
- session[:alchemy_clipboard]['elements'] << {'id' => another_element.id.to_s, 'action' => 'copy'}
36
- alchemy_xhr :delete, :remove, {remarkable_type: 'elements', remarkable_id: another_element.id}
37
- expect(session[:alchemy_clipboard]['elements']).to eq([{'id' => element.id.to_s, 'action' => 'copy'}])
38
- end
39
- end
40
- end
41
-
42
- describe "#clear" do
43
- context "with elements as remarkable_type" do
44
- it "should clear the elements clipboard" do
45
- session[:alchemy_clipboard]['elements'] = [{'id' => element.id.to_s}]
46
- alchemy_xhr :delete, :clear, {remarkable_type: 'elements'}
47
- expect(session[:alchemy_clipboard]['elements']).to be_empty
48
- end
49
- end
50
-
51
- context "with pages as remarkable_type" do
52
- it "should clear the pages clipboard" do
53
- session[:alchemy_clipboard]['pages'] = [{'id' => public_page.id.to_s}]
54
- alchemy_xhr :delete, :clear, {remarkable_type: 'pages'}
55
- expect(session[:alchemy_clipboard]['pages']).to be_empty
56
- end
57
- end
58
- end
59
- end
60
- end
@@ -1,78 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe Admin::ContentsController do
5
- let(:element) { build_stubbed(:alchemy_element) }
6
- let(:content) { build_stubbed(:alchemy_content, element: element) }
7
-
8
- before do
9
- authorize_user(:as_admin)
10
- end
11
-
12
- context 'with element_id parameter' do
13
- before do
14
- expect(Element).to receive(:find).and_return(element)
15
- end
16
-
17
- describe '#create' do
18
- let(:element) { build_stubbed(:alchemy_element, name: 'headline') }
19
-
20
- it "creates a content from name" do
21
- expect(Content).to receive(:create_from_scratch).and_return(content)
22
- alchemy_xhr :post, :create, {content: {element_id: element.id, name: 'headline'}}
23
- end
24
-
25
- it "creates a content from essence_type" do
26
- expect(Content).to receive(:create_from_scratch).and_return(content)
27
- alchemy_xhr :post, :create, {content: {element_id: element.id, essence_type: 'EssencePicture'}}
28
- end
29
- end
30
-
31
- context 'inside a picture gallery' do
32
- let(:attributes) do
33
- {content: {element_id: element.id, essence_type: 'Alchemy::EssencePicture'}, options: {grouped: 'true'}}
34
- end
35
-
36
- it "adds it into the gallery editor" do
37
- alchemy_xhr :post, :create, attributes
38
- expect(assigns(:content_dom_id)).to eq("#add_picture_#{element.id}")
39
- end
40
-
41
- context 'with picture_id given' do
42
- it "assigns the picture" do
43
- expect_any_instance_of(Content).to receive(:update_essence).with(picture_id: '1')
44
- alchemy_xhr :post, :create, attributes.merge(picture_id: '1')
45
- end
46
- end
47
- end
48
- end
49
-
50
- describe '#update' do
51
- before do
52
- expect(Content).to receive(:find).and_return(content)
53
- end
54
-
55
- it "should update a content via ajax" do
56
- expect(content.essence).to receive(:update).with('ingredient' => 'Peters Petshop')
57
- alchemy_xhr :post, :update, {id: content.id, content: {ingredient: 'Peters Petshop'}}
58
- end
59
- end
60
-
61
- describe "#order" do
62
- context "with content_ids in params" do
63
- let(:element) do
64
- create(:alchemy_element, name: 'all_you_can_eat', create_contents_after_create: true)
65
- end
66
-
67
- let(:content_ids) { element.contents.pluck(:id).shuffle }
68
-
69
- it "should reorder the contents" do
70
- alchemy_xhr :post, :order, {content_ids: content_ids}
71
-
72
- expect(response.status).to eq(200)
73
- expect(element.contents(true).pluck(:id)).to eq(content_ids)
74
- end
75
- end
76
- end
77
- end
78
- end
@@ -1,144 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe Admin::DashboardController do
5
- let(:user) { build_stubbed(:alchemy_dummy_user, :as_admin) }
6
-
7
- before { authorize_user(user) }
8
-
9
- describe '#index' do
10
- before do
11
- allow(Page).to receive(:from_current_site).and_return(
12
- double(
13
- all_last_edited_from: [],
14
- locked_by: [],
15
- locked: []
16
- )
17
- )
18
- end
19
-
20
- it "assigns @last_edited_pages" do
21
- alchemy_get :index
22
- expect(assigns(:last_edited_pages)).to eq([])
23
- end
24
-
25
- it "assigns @all_locked_pages" do
26
- alchemy_get :index
27
- expect(assigns(:all_locked_pages)).to eq([])
28
- end
29
-
30
- context 'with user class having logged_in scope' do
31
- context 'with other users online' do
32
- let(:another_user) { mock_model('DummyUser') }
33
-
34
- before do
35
- expect(Alchemy.user_class).to receive(:logged_in).and_return([another_user])
36
- end
37
-
38
- it "assigns @online_users" do
39
- alchemy_get :index
40
- expect(assigns(:online_users)).to eq([another_user])
41
- end
42
- end
43
-
44
- context 'without other users online' do
45
- it "does not assign @online_users" do
46
- alchemy_get :index
47
- expect(assigns(:online_users)).to eq([])
48
- end
49
- end
50
- end
51
-
52
- context 'user having signed in before' do
53
- before do
54
- expect(user).to receive(:sign_in_count).and_return(5)
55
- expect(user).to receive(:last_sign_in_at).and_return(Time.current)
56
- end
57
-
58
- it "assigns @first_time" do
59
- alchemy_get :index
60
- expect(assigns(:first_time)).to eq(false)
61
- end
62
- end
63
-
64
- it "assigns @sites" do
65
- alchemy_get :index
66
- expect(assigns(:sites)).to eq(Site.all)
67
- end
68
- end
69
-
70
- describe '#info' do
71
- it "assigns @alchemy_version with the current Alchemy version" do
72
- alchemy_get :info
73
- expect(assigns(:alchemy_version)).to eq(Alchemy.version)
74
- end
75
- end
76
-
77
- describe '#update_check' do
78
- context "if current Alchemy version equals the latest released version or it is newer" do
79
- before {
80
- allow(controller).to receive(:latest_alchemy_version).and_return('2.6')
81
- allow(Alchemy).to receive(:version).and_return("2.6")
82
- }
83
-
84
- it "should render 'false'" do
85
- alchemy_get :update_check
86
- expect(response.body).to eq('false')
87
- end
88
- end
89
-
90
- context "if current Alchemy version is older than latest released version" do
91
- before {
92
- allow(controller).to receive(:latest_alchemy_version).and_return('2.6')
93
- allow(Alchemy).to receive(:version).and_return("2.5")
94
- }
95
-
96
- it "should render 'true'" do
97
- alchemy_get :update_check
98
- expect(response.body).to eq('true')
99
- end
100
- end
101
-
102
- context "requesting rubygems.org" do
103
- before {
104
- allow_any_instance_of(Net::HTTP).to receive(:request).and_return(
105
- OpenStruct.new({code: '200', body: '[{"number": "2.6"}, {"number": "2.5"}]'})
106
- )
107
- allow(Alchemy).to receive(:version).and_return("2.6")
108
- }
109
-
110
- it "should have response code of 200" do
111
- alchemy_get :update_check
112
- expect(response.code).to eq('200')
113
- end
114
- end
115
-
116
- context "requesting github.com" do
117
- before {
118
- allow(controller).to receive(:query_rubygems).and_return(OpenStruct.new({code: '503'}))
119
- allow_any_instance_of(Net::HTTP).to receive(:request).and_return(
120
- OpenStruct.new({code: '200', body: '[{"name": "2.6"}, {"name": "2.5"}]'})
121
- )
122
- }
123
-
124
- it "should have response code of 200" do
125
- alchemy_get :update_check
126
- expect(response.code).to eq('200')
127
- end
128
- end
129
-
130
- context "rubygems.org and github.com are unavailable" do
131
- before {
132
- allow_any_instance_of(Net::HTTP).to receive(:request).and_return(
133
- OpenStruct.new({code: '503'})
134
- )
135
- }
136
-
137
- it "should have status code 503" do
138
- alchemy_get :update_check
139
- expect(response.code).to eq('503')
140
- end
141
- end
142
- end
143
- end
144
- end