alchemy_cms 3.0.4 → 3.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -6
  3. data/Gemfile +4 -7
  4. data/README.md +207 -115
  5. data/alchemy_cms.gemspec +10 -9
  6. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +2 -2
  7. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee +2 -2
  8. data/app/assets/javascripts/alchemy/alchemy.js +6 -7
  9. data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +1 -43
  10. data/app/assets/javascripts/alchemy/alchemy.uploader.js.coffee +1 -1
  11. data/app/assets/stylesheets/alchemy/_mixins.scss +2 -1
  12. data/app/assets/stylesheets/alchemy/buttons.scss +0 -5
  13. data/app/assets/stylesheets/alchemy/dialogs.scss +1 -0
  14. data/app/assets/stylesheets/alchemy/frame.scss +9 -12
  15. data/app/assets/stylesheets/tinymce/skins/alchemy/content.min.css.scss +11 -2
  16. data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +9 -1
  17. data/app/controllers/alchemy/admin/attachments_controller.rb +2 -4
  18. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +34 -38
  19. data/app/controllers/alchemy/api/base_controller.rb +19 -0
  20. data/app/controllers/alchemy/api/contents_controller.rb +35 -0
  21. data/app/controllers/alchemy/api/elements_controller.rb +29 -0
  22. data/app/controllers/alchemy/api/pages_controller.rb +32 -0
  23. data/app/controllers/alchemy/contents_controller.rb +1 -0
  24. data/app/controllers/alchemy/elements_controller.rb +5 -2
  25. data/app/controllers/alchemy/pages_controller.rb +4 -1
  26. data/app/controllers/alchemy/pictures_controller.rb +4 -36
  27. data/app/helpers/alchemy/admin/essences_helper.rb +5 -2
  28. data/app/helpers/alchemy/essences_helper.rb +14 -1
  29. data/app/models/alchemy/content.rb +32 -4
  30. data/app/models/alchemy/element.rb +2 -16
  31. data/app/models/alchemy/element/presenters.rb +2 -2
  32. data/app/models/alchemy/essence_file.rb +5 -0
  33. data/app/models/alchemy/essence_picture.rb +12 -8
  34. data/app/models/alchemy/picture.rb +1 -74
  35. data/app/models/alchemy/picture/transformations.rb +249 -0
  36. data/app/serializers/alchemy/content_serializer.rb +3 -10
  37. data/app/serializers/alchemy/element_serializer.rb +6 -3
  38. data/app/serializers/alchemy/legacy_element_serializer.rb +17 -0
  39. data/app/views/alchemy/admin/dashboard/_sites.html.erb +14 -4
  40. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +8 -5
  41. data/app/views/alchemy/admin/pages/edit.html.erb +9 -9
  42. data/app/views/alchemy/admin/pictures/info.html.erb +2 -3
  43. data/app/views/alchemy/admin/tags/edit.html.erb +1 -1
  44. data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +8 -7
  45. data/app/views/alchemy/essences/_essence_boolean_view.html.erb +3 -3
  46. data/app/views/alchemy/essences/_essence_date_editor.html.erb +8 -2
  47. data/app/views/alchemy/essences/_essence_date_view.html.erb +10 -8
  48. data/app/views/alchemy/essences/_essence_file_editor.html.erb +48 -53
  49. data/app/views/alchemy/essences/_essence_file_view.html.erb +5 -5
  50. data/app/views/alchemy/essences/_essence_html_editor.html.erb +5 -4
  51. data/app/views/alchemy/essences/_essence_link_editor.html.erb +17 -15
  52. data/app/views/alchemy/essences/_essence_link_view.html.erb +11 -7
  53. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +4 -2
  54. data/app/views/alchemy/essences/_essence_picture_view.html.erb +4 -2
  55. data/app/views/alchemy/essences/_essence_richtext_view.html.erb +5 -4
  56. data/app/views/alchemy/essences/_essence_select_editor.html.erb +22 -32
  57. data/app/views/alchemy/essences/_essence_text_view.html.erb +7 -6
  58. data/app/views/alchemy/essences/shared/_essence_picture_tools.html.erb +1 -1
  59. data/app/views/layouts/alchemy/admin.html.erb +5 -3
  60. data/config/initializers/inflections.rb +3 -0
  61. data/config/initializers/simple_form.rb +1 -1
  62. data/config/locales/alchemy.en.yml +0 -1
  63. data/config/routes.rb +14 -0
  64. data/lib/alchemy/capistrano.rb +71 -0
  65. data/lib/alchemy/engine.rb +0 -3
  66. data/lib/alchemy/essence.rb +1 -1
  67. data/lib/alchemy/permissions.rb +19 -5
  68. data/lib/alchemy/picture_attributes.rb +1 -1
  69. data/lib/alchemy/test_support/auth_helpers.rb +1 -1
  70. data/lib/alchemy/test_support/essence_shared_examples.rb +37 -22
  71. data/lib/alchemy/test_support/integration_helpers.rb +1 -1
  72. data/lib/alchemy/tinymce.rb +21 -4
  73. data/lib/alchemy/upgrader/three_point_one.rb +43 -0
  74. data/lib/alchemy/upgrader/three_point_zero.rb +13 -0
  75. data/lib/alchemy/version.rb +2 -1
  76. data/lib/rails/generators/alchemy/module/module_generator.rb +30 -0
  77. data/lib/rails/generators/alchemy/module/templates/ability.rb.tt +11 -0
  78. data/lib/rails/generators/alchemy/module/templates/controller.rb.tt +2 -0
  79. data/lib/rails/generators/alchemy/module/templates/module_config.rb.tt +15 -0
  80. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +0 -1
  81. data/lib/rails/templates/alchemy.rb +2 -2
  82. data/lib/tasks/alchemy/db.rake +7 -1
  83. data/spec/controllers/admin/attachments_controller_spec.rb +38 -38
  84. data/spec/controllers/admin/base_controller_spec.rb +18 -18
  85. data/spec/controllers/admin/clipboard_controller_spec.rb +23 -18
  86. data/spec/controllers/admin/contents_controller_spec.rb +33 -27
  87. data/spec/controllers/admin/dashboard_controller_spec.rb +14 -14
  88. data/spec/controllers/admin/elements_controller_spec.rb +125 -105
  89. data/spec/controllers/admin/essence_files_controller_spec.rb +6 -7
  90. data/spec/controllers/admin/essence_pictures_controller_spec.rb +52 -42
  91. data/spec/controllers/admin/languages_controller_spec.rb +3 -3
  92. data/spec/controllers/admin/pages_controller_spec.rb +81 -71
  93. data/spec/controllers/admin/pictures_controller_spec.rb +69 -72
  94. data/spec/controllers/admin/resources_controller_spec.rb +5 -5
  95. data/spec/controllers/admin/trash_controller_spec.rb +15 -12
  96. data/spec/controllers/alchemy/admin/tags_controller_spec.rb +8 -8
  97. data/spec/controllers/alchemy/api/contents_controller_spec.rb +73 -0
  98. data/spec/controllers/alchemy/api/elements_controller_spec.rb +69 -0
  99. data/spec/controllers/alchemy/api/pages_controller_spec.rb +86 -0
  100. data/spec/controllers/attachments_controller_spec.rb +8 -8
  101. data/spec/controllers/contents_controller_spec.rb +22 -0
  102. data/spec/controllers/elements_controller_spec.rb +10 -4
  103. data/spec/controllers/messages_controller_spec.rb +35 -34
  104. data/spec/controllers/pages_controller_spec.rb +37 -28
  105. data/spec/controllers/pictures_controller_spec.rb +90 -23
  106. data/spec/dummy/app/models/dummy_user.rb +0 -4
  107. data/spec/dummy/app/views/alchemy/elements/_all_you_can_eat_editor.html.erb +11 -0
  108. data/spec/dummy/config/alchemy/elements.yml +22 -1
  109. data/spec/dummy/config/alchemy/page_layouts.yml +4 -0
  110. data/spec/dummy/config/application.rb +2 -1
  111. data/spec/dummy/config/environments/test.rb +3 -1
  112. data/spec/features/admin/dashboard_spec.rb +41 -6
  113. data/spec/features/admin/language_tree_feature_spec.rb +3 -3
  114. data/spec/features/admin/legacy_page_url_management_spec.rb +1 -1
  115. data/spec/features/admin/link_overlay_spec.rb +7 -7
  116. data/spec/features/admin/locale_select_feature_spec.rb +5 -2
  117. data/spec/features/admin/modules_integration_spec.rb +1 -1
  118. data/spec/features/admin/page_creation_feature_spec.rb +3 -2
  119. data/spec/features/admin/page_editing_feature_spec.rb +66 -79
  120. data/spec/features/admin/picture_library_integration_spec.rb +8 -8
  121. data/spec/features/admin/resources_integration_spec.rb +21 -21
  122. data/spec/features/admin/tinymce_feature_spec.rb +36 -0
  123. data/spec/features/navigation_spec.rb +1 -1
  124. data/spec/features/page_feature_spec.rb +34 -34
  125. data/spec/features/picture_security_spec.rb +4 -4
  126. data/spec/features/security_spec.rb +1 -1
  127. data/spec/features/translation_integration_spec.rb +7 -7
  128. data/spec/helpers/admin/base_helper_spec.rb +51 -49
  129. data/spec/helpers/admin/contents_helper_spec.rb +11 -11
  130. data/spec/helpers/admin/elements_helper_spec.rb +20 -17
  131. data/spec/helpers/admin/essences_helper_spec.rb +42 -11
  132. data/spec/helpers/admin/navigation_helper_spec.rb +64 -54
  133. data/spec/helpers/admin/pages_helper_spec.rb +10 -10
  134. data/spec/helpers/admin/tags_helper_spec.rb +16 -16
  135. data/spec/helpers/base_helper_spec.rb +11 -11
  136. data/spec/helpers/elements_block_helper_spec.rb +24 -24
  137. data/spec/helpers/elements_helper_spec.rb +46 -46
  138. data/spec/helpers/essences_helper_spec.rb +90 -17
  139. data/spec/helpers/pages_helper_spec.rb +53 -53
  140. data/spec/helpers/picture_url_helpers_spec.rb +6 -6
  141. data/spec/helpers/url_helper_spec.rb +32 -32
  142. data/spec/libraries/config_spec.rb +9 -9
  143. data/spec/libraries/controller_actions_spec.rb +14 -14
  144. data/spec/libraries/i18n_spec.rb +6 -6
  145. data/spec/libraries/kaminari/scoped_pagination_url_helper_spec.rb +4 -4
  146. data/spec/libraries/modules_spec.rb +4 -4
  147. data/spec/libraries/mount_point_spec.rb +13 -13
  148. data/spec/libraries/page_layout_spec.rb +24 -24
  149. data/spec/libraries/permissions_spec.rb +97 -80
  150. data/spec/libraries/resource_spec.rb +37 -37
  151. data/spec/libraries/resources_helper_spec.rb +19 -19
  152. data/spec/libraries/shell_spec.rb +17 -17
  153. data/spec/libraries/template_tracker_spec.rb +14 -14
  154. data/spec/libraries/tinymce_spec.rb +8 -8
  155. data/spec/libraries/userstamp_spec.rb +2 -2
  156. data/spec/mailers/messages_spec.rb +4 -4
  157. data/spec/models/attachment_spec.rb +86 -30
  158. data/spec/models/cell_spec.rb +10 -10
  159. data/spec/models/content_spec.rb +106 -46
  160. data/spec/models/element_spec.rb +94 -115
  161. data/spec/models/essence_date_spec.rb +1 -1
  162. data/spec/models/essence_file_spec.rb +4 -4
  163. data/spec/models/essence_picture_spec.rb +56 -25
  164. data/spec/models/essence_richtext_spec.rb +1 -1
  165. data/spec/models/essence_text_spec.rb +7 -7
  166. data/spec/models/language_spec.rb +12 -12
  167. data/spec/models/legacy_page_url_spec.rb +2 -2
  168. data/spec/models/message_spec.rb +12 -5
  169. data/spec/models/page_spec.rb +259 -235
  170. data/spec/models/picture_spec.rb +72 -166
  171. data/spec/models/site_spec.rb +41 -41
  172. data/spec/models/tag_spec.rb +7 -7
  173. data/spec/routing/api_routing_spec.rb +150 -0
  174. data/spec/routing/routing_spec.rb +28 -28
  175. data/spec/spec_helper.rb +6 -5
  176. data/spec/support/hint_examples.rb +5 -5
  177. data/spec/support/transformation_examples.rb +173 -0
  178. data/spec/tasks/helpers_spec.rb +29 -29
  179. data/spec/views/essences/essence_boolean_editor_spec.rb +32 -0
  180. data/spec/views/essences/essence_boolean_view_spec.rb +2 -2
  181. data/spec/views/essences/essence_date_view_spec.rb +1 -1
  182. data/spec/views/essences/essence_link_view_spec.rb +11 -0
  183. data/spec/views/essences/essence_picture_view_spec.rb +56 -11
  184. data/spec/views/essences/essence_richtext_view_spec.rb +12 -0
  185. data/spec/views/essences/essence_text_view_spec.rb +12 -0
  186. data/vendor/assets/javascripts/tinymce/langs/de.js +20 -2
  187. data/vendor/assets/javascripts/tinymce/langs/fr.js +14 -1
  188. data/vendor/assets/javascripts/tinymce/langs/nl.js +22 -4
  189. data/vendor/assets/javascripts/tinymce/plugins/anchor/plugin.min.js +1 -1
  190. data/vendor/assets/javascripts/tinymce/plugins/autoresize/plugin.min.js +1 -1
  191. data/vendor/assets/javascripts/tinymce/plugins/charmap/plugin.min.js +1 -1
  192. data/vendor/assets/javascripts/tinymce/plugins/code/plugin.min.js +1 -1
  193. data/vendor/assets/javascripts/tinymce/plugins/directionality/plugin.min.js +1 -1
  194. data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.min.js +1 -1
  195. data/vendor/assets/javascripts/tinymce/plugins/hr/plugin.min.js +1 -1
  196. data/vendor/assets/javascripts/tinymce/plugins/link/plugin.min.js +1 -1
  197. data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.min.js +1 -1
  198. data/vendor/assets/javascripts/tinymce/plugins/tabfocus/plugin.min.js +1 -1
  199. data/vendor/assets/javascripts/tinymce/plugins/table/plugin.min.js +1 -1
  200. data/vendor/assets/javascripts/tinymce/themes/modern/theme.min.js +1 -1
  201. data/vendor/assets/javascripts/tinymce/tinymce.min.js +11 -10
  202. metadata +72 -42
  203. data/app/views/alchemy/messages/contact_form_mail.es.text.erb +0 -12
  204. data/config/locales/alchemy.es.yml +0 -958
  205. data/config/locales/alchemy.ru.yml +0 -837
  206. data/config/locales/simple_form.es.yml +0 -6
  207. data/config/locales/simple_form.ru.yml +0 -25
  208. data/lib/rails/generators/alchemy/scaffold/files/alchemy.es.yml +0 -31
  209. data/vendor/assets/javascripts/tinymce/langs/es.js +0 -197
  210. data/vendor/assets/javascripts/tinymce/langs/ru.js +0 -197
@@ -7,16 +7,16 @@ module Alchemy
7
7
  let(:default_language_root) { FactoryGirl.create(:language_root_page, language: default_language, name: 'Home', public: true) }
8
8
  let(:page) { FactoryGirl.create(:public_page, parent_id: default_language_root.id, page_layout: 'news', name: 'News', urlname: 'news', language: default_language, do_not_autogenerate: false) }
9
9
 
10
- before { controller.stub(:signup_required?).and_return(false) }
10
+ before { allow(controller).to receive(:signup_required?).and_return(false) }
11
11
 
12
12
  context 'an author' do
13
13
  let(:unpublic) { create(:page, parent: default_language_root) }
14
14
 
15
- before { controller.stub(current_alchemy_user: author_user) }
15
+ before { allow(controller).to receive(:current_alchemy_user).and_return(author_user) }
16
16
 
17
17
  it "should not be able to visit a unpublic page" do
18
18
  get :show, urlname: unpublic.urlname
19
- response.status.should == 404
19
+ expect(response.status).to eq(404)
20
20
  end
21
21
  end
22
22
 
@@ -25,20 +25,29 @@ module Alchemy
25
25
 
26
26
  it "should render a rss feed" do
27
27
  get :show, urlname: page.urlname, format: :rss
28
- response.content_type.should == 'application/rss+xml'
28
+ expect(response.content_type).to eq('application/rss+xml')
29
29
  end
30
30
 
31
31
  it "should include content" do
32
32
  page.elements.first.content_by_name('news_headline').essence.update_attributes({body: 'Peters Petshop'})
33
33
  get :show, urlname: 'news', format: :rss
34
- response.body.should match /Peters Petshop/
34
+ expect(response.body).to match /Peters Petshop/
35
35
  end
36
36
  end
37
37
 
38
38
  context "requested for a page that does not contain a feed" do
39
39
  it "should render xml 404 error" do
40
40
  get :show, urlname: default_language_root.urlname, format: :rss
41
- response.status.should == 404
41
+ expect(response.status).to eq(404)
42
+ end
43
+ end
44
+
45
+ context "requested for json format" do
46
+ it "should render json response but warns about deprecation" do
47
+ expect(ActiveSupport::Deprecation).to receive(:warn)
48
+ get :show, urlname: default_language_root.urlname, format: :json
49
+ expect(response.status).to eq(200)
50
+ expect(response.content_type).to eq('application/json')
42
51
  end
43
52
  end
44
53
 
@@ -46,8 +55,8 @@ module Alchemy
46
55
  context "with ajax request" do
47
56
  it "should not render a layout" do
48
57
  xhr :get, :show, urlname: page.urlname
49
- response.should render_template(:show)
50
- response.should_not render_template(layout: 'application')
58
+ expect(response).to render_template(:show)
59
+ expect(response).not_to render_template(layout: 'application')
51
60
  end
52
61
  end
53
62
  end
@@ -60,24 +69,24 @@ module Alchemy
60
69
  let(:product) { FactoryGirl.create(:public_page, name: "Screwdriver", urlname: 'screwdriver', parent: products, language: default_language, do_not_autogenerate: false, visible: true) }
61
70
 
62
71
  before do
63
- Alchemy.user_class.stub(:admins).and_return(OpenStruct.new(count: 1))
64
- Config.stub(:get) { |arg| arg == :url_nesting ? true : false }
72
+ allow(Alchemy.user_class).to receive(:admins).and_return(OpenStruct.new(count: 1))
73
+ allow(Config).to receive(:get) { |arg| arg == :url_nesting ? true : false }
65
74
  product.elements.find_by_name('article').contents.essence_texts.first.essence.update_column(:body, 'screwdriver')
66
75
  end
67
76
 
68
77
  context "with correct levelnames in params" do
69
78
  it "should show the requested page" do
70
79
  get :show, {urlname: 'catalog/products/screwdriver'}
71
- response.status.should == 200
72
- response.body.should have_content("screwdriver")
80
+ expect(response.status).to eq(200)
81
+ expect(response.body).to have_content("screwdriver")
73
82
  end
74
83
  end
75
84
 
76
85
  context "with incorrect levelnames in params" do
77
86
  it "should render a 404 page" do
78
87
  get :show, {urlname: 'catalog/faqs/screwdriver'}
79
- response.status.should == 404
80
- response.body.should have_content('The page you were looking for doesn\'t exist')
88
+ expect(response.status).to eq(404)
89
+ expect(response.body).to have_content('The page you were looking for doesn\'t exist')
81
90
  end
82
91
  end
83
92
  end
@@ -85,8 +94,8 @@ module Alchemy
85
94
  context "when a non-existent page is requested" do
86
95
  it "should rescue a RoutingError with rendering a 404 page." do
87
96
  get :show, {urlname: 'doesntexist'}
88
- response.status.should == 404
89
- response.body.should have_content('The page you were looking for doesn\'t exist')
97
+ expect(response.status).to eq(404)
98
+ expect(response.body).to have_content('The page you were looking for doesn\'t exist')
90
99
  end
91
100
  end
92
101
 
@@ -105,9 +114,9 @@ module Alchemy
105
114
  end
106
115
 
107
116
  it "should redirect to first public child" do
108
- controller.should_receive(:redirect_page)
117
+ expect(controller).to receive(:redirect_page)
109
118
  controller.send(:redirect_to_public_child)
110
- controller.instance_variable_get('@page').should == public_page
119
+ expect(controller.instance_variable_get('@page')).to eq(public_page)
111
120
  end
112
121
  end
113
122
 
@@ -137,24 +146,24 @@ module Alchemy
137
146
 
138
147
  it "should redirect permanently to page that belongs to legacy page url." do
139
148
  get :show, urlname: legacy_url.urlname
140
- response.status.should == 301
141
- response.should redirect_to("/#{page.urlname}")
149
+ expect(response.status).to eq(301)
150
+ expect(response).to redirect_to("/#{page.urlname}")
142
151
  end
143
152
 
144
153
  it "should only redirect to legacy url if no page was found for urlname" do
145
154
  get :show, urlname: legacy_page.urlname
146
- response.status.should == 200
147
- response.should_not redirect_to("/#{page.urlname}")
155
+ expect(response.status).to eq(200)
156
+ expect(response).not_to redirect_to("/#{page.urlname}")
148
157
  end
149
158
 
150
159
  it "should redirect to last page that has that legacy url" do
151
160
  get :show, urlname: legacy_url2.urlname
152
- response.should redirect_to("/#{second_page.urlname}")
161
+ expect(response).to redirect_to("/#{second_page.urlname}")
153
162
  end
154
163
 
155
164
  it "should redirect even if the url has get parameters" do
156
165
  get :show, urlname: legacy_url3.urlname
157
- response.should redirect_to("/#{second_page.urlname}")
166
+ expect(response).to redirect_to("/#{second_page.urlname}")
158
167
  end
159
168
  end
160
169
  end
@@ -162,18 +171,18 @@ module Alchemy
162
171
  describe "while redirecting" do
163
172
  context "not in multi language mode" do
164
173
  before do
165
- PagesController.any_instance.stub(:multi_language?).and_return(false)
174
+ allow_any_instance_of(PagesController).to receive(:multi_language?).and_return(false)
166
175
  end
167
176
 
168
177
  context "with no lang parameter present" do
169
178
  it "should store defaults language id in the session." do
170
179
  get :show, urlname: 'a-public-page'
171
- controller.session[:alchemy_language_id].should == Language.default.id
180
+ expect(controller.session[:alchemy_language_id]).to eq(Language.default.id)
172
181
  end
173
182
 
174
183
  it "should store default language as class var." do
175
184
  get :show, urlname: 'a-public-page'
176
- Language.current.should == Language.default
185
+ expect(Language.current).to eq(Language.default)
177
186
  end
178
187
  end
179
188
  end
@@ -183,7 +192,7 @@ module Alchemy
183
192
  subject { controller.send(:page_etag) }
184
193
 
185
194
  before do
186
- page.stub(cache_key: 'aaa')
195
+ expect(page).to receive(:cache_key).and_return('aaa')
187
196
  controller.instance_variable_set('@page', page)
188
197
  end
189
198
 
@@ -21,21 +21,21 @@ module Alchemy
21
21
 
22
22
  it "renders the original image without any resizing" do
23
23
  get :zoom, id: picture.id, format: :png, sh: picture.security_token
24
- response.body[0x10..0x18].unpack('NN').should == [80, 60]
24
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([80, 60])
25
25
  end
26
26
  end
27
27
 
28
28
  context "Requesting a picture with tempared security token" do
29
29
  it "should render status 400" do
30
30
  get :show, id: picture.id, format: :png, sh: '14m4b4dh4ck3r'
31
- response.status.should == 400
31
+ expect(response.status).to eq(400)
32
32
  end
33
33
  end
34
34
 
35
35
  context "Requesting a picture with another format then the original image" do
36
36
  it "should convert the picture format" do
37
37
  get :show, id: picture.id, format: :jpeg, sh: picture.security_token
38
- response.content_type.should == 'image/jpeg'
38
+ expect(response.content_type).to eq('image/jpeg')
39
39
  end
40
40
  end
41
41
 
@@ -55,43 +55,43 @@ module Alchemy
55
55
  context 'with size param set to small' do
56
56
  it "resizes the image to 80x60 while maintaining aspect ratio" do
57
57
  get :thumbnail, id: picture.id, size: 'small', format: :png, sh: picture.security_token(size: 'small')
58
- response.body[0x10..0x18].unpack('NN').should == [60, 60]
58
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([60, 60])
59
59
  end
60
60
  end
61
61
 
62
62
  context 'with size param set to medium' do
63
63
  it "resizes the image to 160x120 while maintaining aspect ratio" do
64
64
  get :thumbnail, id: picture.id, size: 'medium', format: :png, sh: picture.security_token(size: 'medium')
65
- response.body[0x10..0x18].unpack('NN').should == [120, 120]
65
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([120, 120])
66
66
  end
67
67
  end
68
68
 
69
69
  context 'with size param set to large' do
70
70
  it "resizes the image to 240x180 while maintaining aspect ratio" do
71
71
  get :thumbnail, id: picture.id, size: 'large', format: :png, sh: picture.security_token(size: 'large')
72
- response.body[0x10..0x18].unpack('NN').should == [180, 180]
72
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([180, 180])
73
73
  end
74
74
  end
75
75
 
76
76
  context 'with size param set to nil' do
77
77
  it "resizes the image to 111x93 while maintaining aspect ratio" do
78
78
  get :thumbnail, id: picture.id, format: :png, sh: picture.security_token
79
- response.body[0x10..0x18].unpack('NN').should == [93, 93]
79
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([93, 93])
80
80
  end
81
81
  end
82
82
 
83
83
  context 'with size param set to another value' do
84
84
  it "resizes the image to the given size while maintaining aspect ratio" do
85
85
  get :thumbnail, id: picture.id, size: '33x33', format: :png, sh: picture.security_token(size: '33x33')
86
- response.body[0x10..0x18].unpack('NN').should == [33, 33]
86
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([33, 33])
87
87
  end
88
88
  end
89
89
  end
90
90
 
91
91
  context "Requesting a picture that has no image file attached" do
92
92
  before do
93
- picture.stub(image_file: nil)
94
- Picture.stub(find: picture)
93
+ expect(picture).to receive(:image_file).and_return(nil)
94
+ expect(Picture).to receive(:find).and_return(picture)
95
95
  end
96
96
 
97
97
  it "raises missing file error" do
@@ -105,15 +105,82 @@ module Alchemy
105
105
  let(:picture) { Picture.create(image_file: fixture_file_upload(File.expand_path('../../fixtures/500x500.png', __FILE__), 'image/png')) }
106
106
 
107
107
  it "renders the cropped picture" do
108
- get :show, id: picture.id, crop: 'crop', size: '123x44', crop_size: '123x44', crop_from: '0x0', format: :png, sh: picture.security_token(crop_size: '123x44', crop_from: '0x0', crop: true, size: '123x44')
109
- response.body[0x10..0x18].unpack('NN').should == [123, 44]
108
+ get :show, id: picture.id, crop: 'crop', size: '123x44', crop_size: '123x44',
109
+ crop_from: '0x0', format: :png,
110
+ sh: picture.security_token(crop_size: '123x44', crop_from: '0x0', crop: true, size: '123x44')
111
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([123, 44])
112
+ end
113
+ end
114
+
115
+ context "Requesting a picture with crop_from and crop_size parameters with different size param" do
116
+ let(:picture) { Picture.create(image_file: fixture_file_upload(File.expand_path('../../fixtures/500x500.png', __FILE__), 'image/png')) }
117
+
118
+ it "renders the cropped picture" do
119
+ get :show,
120
+ id: picture.id,
121
+ crop: 'crop',
122
+ size: '100x100',
123
+ crop_size: '200x200',
124
+ crop_from: '0x0',
125
+ format: :png,
126
+ sh: picture.security_token(
127
+ crop_size: '200x200',
128
+ crop_from: '0x0',
129
+ crop: true,
130
+ size: '100x100'
131
+ )
132
+ expect(response.body[0x10..0x18].unpack('NN')).to eq [100, 100]
133
+ end
134
+ end
135
+
136
+ context "Requesting a picture with crop_from and crop_size parameters with larger size param" do
137
+ let(:picture) { Picture.create(image_file: fixture_file_upload(File.expand_path('../../fixtures/500x500.png', __FILE__), 'image/png')) }
138
+
139
+ it "renders the cropped picture without upsampling" do
140
+ get :show,
141
+ id: picture.id,
142
+ crop: 'crop',
143
+ size: '400x400',
144
+ crop_size: '200x200',
145
+ crop_from: '0x0',
146
+ format: :png,
147
+ sh: picture.security_token(
148
+ crop_size: '200x200',
149
+ crop_from: '0x0',
150
+ crop: true,
151
+ size: '400x400'
152
+ )
153
+ expect(response.body[0x10..0x18].unpack('NN')).to eq [200, 200]
154
+ end
155
+ end
156
+
157
+ context "Requesting a picture with crop_from and crop_size parameters with larger size param and upsample set" do
158
+ let(:picture) { Picture.create(image_file: fixture_file_upload(File.expand_path('../../fixtures/500x500.png', __FILE__), 'image/png')) }
159
+
160
+ it "renders the cropped picture with upsampling" do
161
+ get :show,
162
+ id: picture.id,
163
+ crop: 'crop',
164
+ size: '400x400',
165
+ crop_size: '200x200',
166
+ crop_from: '0x0',
167
+ format: :png,
168
+ upsample: 'true',
169
+ sh: picture.security_token(
170
+ crop_size: '200x200',
171
+ crop_from: '0x0',
172
+ crop: true,
173
+ size: '400x400',
174
+ upsample: 'true'
175
+ )
176
+ expect(response.body[0x10..0x18].unpack('NN')).to eq [400, 400]
110
177
  end
111
178
  end
112
179
 
113
180
  context "Requesting a picture that is not assigned with any page" do
114
181
  it "should render the picture" do
115
182
  get :show, id: picture.id, format: :png, sh: picture.security_token
116
- response.status.should == 200
183
+ expect(response.status).to eq(200)
117
184
  end
118
185
  end
119
186
 
@@ -131,7 +198,7 @@ module Alchemy
131
198
  context "as guest user" do
132
199
  it "should render the picture" do
133
200
  get :show, id: picture.id, format: :png, sh: picture.security_token
134
- response.status.should == 200
201
+ expect(response.status).to eq(200)
135
202
  end
136
203
  end
137
204
  end
@@ -146,8 +213,8 @@ module Alchemy
146
213
  context "as guest user" do
147
214
  it "should not render the picture, but redirect to login path" do
148
215
  get :show, id: picture.id, sh: picture.security_token
149
- response.status.should == 302
150
- response.should redirect_to(Alchemy.login_path)
216
+ expect(response.status).to eq(302)
217
+ expect(response).to redirect_to(Alchemy.login_path)
151
218
  end
152
219
  end
153
220
 
@@ -158,7 +225,7 @@ module Alchemy
158
225
 
159
226
  it "should render the picture" do
160
227
  get :show, id: picture.id, format: :png, sh: picture.security_token
161
- response.status.should == 200
228
+ expect(response.status).to eq(200)
162
229
  end
163
230
  end
164
231
  end
@@ -174,7 +241,7 @@ module Alchemy
174
241
  format: 'png'
175
242
  }
176
243
  get :show, options.merge(id: big_picture.id, sh: big_picture.security_token(options))
177
- response.body[0x10..0x18].unpack('NN').should == [10,10]
244
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([10,10])
178
245
  end
179
246
 
180
247
  context "without a full size specification" do
@@ -198,7 +265,7 @@ module Alchemy
198
265
  format: 'png'
199
266
  }
200
267
  get :show, options.merge(id: picture.id, sh: picture.security_token(options))
201
- response.body[0x10..0x18].unpack('NN').should == [1,1]
268
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([1,1])
202
269
  end
203
270
  end
204
271
 
@@ -211,7 +278,7 @@ module Alchemy
211
278
  format: 'png'
212
279
  }
213
280
  get :show, options.merge(id: picture.id, sh: picture.security_token(options))
214
- response.body[0x10..0x18].unpack('NN').should == [10,10]
281
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([10,10])
215
282
  end
216
283
  end
217
284
  end
@@ -223,7 +290,7 @@ module Alchemy
223
290
  :format => 'png'
224
291
  }
225
292
  get :show, options.merge(:id => big_picture.id, :sh => big_picture.security_token(options))
226
- response.body[0x10..0x18].unpack('NN').should == [40,30]
293
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([40,30])
227
294
  end
228
295
 
229
296
  it "should resize the image inferring the height if not given" do
@@ -232,7 +299,7 @@ module Alchemy
232
299
  :format => 'png'
233
300
  }
234
301
  get :show, options.merge(:id => big_picture.id, :sh => big_picture.security_token(options))
235
- response.body[0x10..0x18].unpack('NN').should == [40,30]
302
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([40,30])
236
303
  end
237
304
 
238
305
  it "should resize the image inferring the width if not given" do
@@ -241,7 +308,7 @@ module Alchemy
241
308
  :format => 'png'
242
309
  }
243
310
  get :show, options.merge(:id => big_picture.id, :sh => big_picture.security_token(options))
244
- response.body[0x10..0x18].unpack('NN').should == [40,30]
311
+ expect(response.body[0x10..0x18].unpack('NN')).to eq([40,30])
245
312
  end
246
313
  end
247
314
  end
@@ -4,8 +4,4 @@ class DummyUser < ActiveRecord::Base
4
4
  def self.logged_in
5
5
  []
6
6
  end
7
-
8
- def alchemy_roles
9
- @alchemy_roles || %w(admin)
10
- end
11
7
  end
@@ -0,0 +1,11 @@
1
+ <%= element_editor_for(element) do |el| -%>
2
+ <%= el.edit :essence_boolean %>
3
+ <%= el.edit :essence_date %>
4
+ <%= el.edit :essence_file %>
5
+ <%= el.edit :essence_html %>
6
+ <%= el.edit :essence_link %>
7
+ <%= el.edit :essence_picture %>
8
+ <%= el.edit :essence_richtext %>
9
+ <%= el.edit :essence_select %>
10
+ <%= el.edit :essence_text %>
11
+ <%- end -%>
@@ -74,10 +74,31 @@
74
74
  - presence
75
75
  - name: subject
76
76
  type: EssenceText
77
- take_me_for_preview: true
77
+ as_element_title: true
78
78
  validate:
79
79
  - presence
80
80
  - name: success_page
81
81
  type: EssenceSelect
82
82
  validate:
83
83
  - presence
84
+
85
+ - name: all_you_can_eat
86
+ contents:
87
+ - name: essence_boolean
88
+ type: EssenceBoolean
89
+ - name: essence_date
90
+ type: EssenceDate
91
+ - name: essence_file
92
+ type: EssenceFile
93
+ - name: essence_html
94
+ type: EssenceHtml
95
+ - name: essence_link
96
+ type: EssenceLink
97
+ - name: essence_picture
98
+ type: EssencePicture
99
+ - name: essence_richtext
100
+ type: EssenceRichtext
101
+ - name: essence_select
102
+ type: EssenceSelect
103
+ - name: essence_text
104
+ type: EssenceText