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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -6
- data/Gemfile +4 -7
- data/README.md +207 -115
- data/alchemy_cms.gemspec +10 -9
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +2 -2
- data/app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee +2 -2
- data/app/assets/javascripts/alchemy/alchemy.js +6 -7
- data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +1 -43
- data/app/assets/javascripts/alchemy/alchemy.uploader.js.coffee +1 -1
- data/app/assets/stylesheets/alchemy/_mixins.scss +2 -1
- data/app/assets/stylesheets/alchemy/buttons.scss +0 -5
- data/app/assets/stylesheets/alchemy/dialogs.scss +1 -0
- data/app/assets/stylesheets/alchemy/frame.scss +9 -12
- data/app/assets/stylesheets/tinymce/skins/alchemy/content.min.css.scss +11 -2
- data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +9 -1
- data/app/controllers/alchemy/admin/attachments_controller.rb +2 -4
- data/app/controllers/alchemy/admin/essence_pictures_controller.rb +34 -38
- data/app/controllers/alchemy/api/base_controller.rb +19 -0
- data/app/controllers/alchemy/api/contents_controller.rb +35 -0
- data/app/controllers/alchemy/api/elements_controller.rb +29 -0
- data/app/controllers/alchemy/api/pages_controller.rb +32 -0
- data/app/controllers/alchemy/contents_controller.rb +1 -0
- data/app/controllers/alchemy/elements_controller.rb +5 -2
- data/app/controllers/alchemy/pages_controller.rb +4 -1
- data/app/controllers/alchemy/pictures_controller.rb +4 -36
- data/app/helpers/alchemy/admin/essences_helper.rb +5 -2
- data/app/helpers/alchemy/essences_helper.rb +14 -1
- data/app/models/alchemy/content.rb +32 -4
- data/app/models/alchemy/element.rb +2 -16
- data/app/models/alchemy/element/presenters.rb +2 -2
- data/app/models/alchemy/essence_file.rb +5 -0
- data/app/models/alchemy/essence_picture.rb +12 -8
- data/app/models/alchemy/picture.rb +1 -74
- data/app/models/alchemy/picture/transformations.rb +249 -0
- data/app/serializers/alchemy/content_serializer.rb +3 -10
- data/app/serializers/alchemy/element_serializer.rb +6 -3
- data/app/serializers/alchemy/legacy_element_serializer.rb +17 -0
- data/app/views/alchemy/admin/dashboard/_sites.html.erb +14 -4
- data/app/views/alchemy/admin/essence_pictures/crop.html.erb +8 -5
- data/app/views/alchemy/admin/pages/edit.html.erb +9 -9
- data/app/views/alchemy/admin/pictures/info.html.erb +2 -3
- data/app/views/alchemy/admin/tags/edit.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +8 -7
- data/app/views/alchemy/essences/_essence_boolean_view.html.erb +3 -3
- data/app/views/alchemy/essences/_essence_date_editor.html.erb +8 -2
- data/app/views/alchemy/essences/_essence_date_view.html.erb +10 -8
- data/app/views/alchemy/essences/_essence_file_editor.html.erb +48 -53
- data/app/views/alchemy/essences/_essence_file_view.html.erb +5 -5
- data/app/views/alchemy/essences/_essence_html_editor.html.erb +5 -4
- data/app/views/alchemy/essences/_essence_link_editor.html.erb +17 -15
- data/app/views/alchemy/essences/_essence_link_view.html.erb +11 -7
- data/app/views/alchemy/essences/_essence_picture_editor.html.erb +4 -2
- data/app/views/alchemy/essences/_essence_picture_view.html.erb +4 -2
- data/app/views/alchemy/essences/_essence_richtext_view.html.erb +5 -4
- data/app/views/alchemy/essences/_essence_select_editor.html.erb +22 -32
- data/app/views/alchemy/essences/_essence_text_view.html.erb +7 -6
- data/app/views/alchemy/essences/shared/_essence_picture_tools.html.erb +1 -1
- data/app/views/layouts/alchemy/admin.html.erb +5 -3
- data/config/initializers/inflections.rb +3 -0
- data/config/initializers/simple_form.rb +1 -1
- data/config/locales/alchemy.en.yml +0 -1
- data/config/routes.rb +14 -0
- data/lib/alchemy/capistrano.rb +71 -0
- data/lib/alchemy/engine.rb +0 -3
- data/lib/alchemy/essence.rb +1 -1
- data/lib/alchemy/permissions.rb +19 -5
- data/lib/alchemy/picture_attributes.rb +1 -1
- data/lib/alchemy/test_support/auth_helpers.rb +1 -1
- data/lib/alchemy/test_support/essence_shared_examples.rb +37 -22
- data/lib/alchemy/test_support/integration_helpers.rb +1 -1
- data/lib/alchemy/tinymce.rb +21 -4
- data/lib/alchemy/upgrader/three_point_one.rb +43 -0
- data/lib/alchemy/upgrader/three_point_zero.rb +13 -0
- data/lib/alchemy/version.rb +2 -1
- data/lib/rails/generators/alchemy/module/module_generator.rb +30 -0
- data/lib/rails/generators/alchemy/module/templates/ability.rb.tt +11 -0
- data/lib/rails/generators/alchemy/module/templates/controller.rb.tt +2 -0
- data/lib/rails/generators/alchemy/module/templates/module_config.rb.tt +15 -0
- data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +0 -1
- data/lib/rails/templates/alchemy.rb +2 -2
- data/lib/tasks/alchemy/db.rake +7 -1
- data/spec/controllers/admin/attachments_controller_spec.rb +38 -38
- data/spec/controllers/admin/base_controller_spec.rb +18 -18
- data/spec/controllers/admin/clipboard_controller_spec.rb +23 -18
- data/spec/controllers/admin/contents_controller_spec.rb +33 -27
- data/spec/controllers/admin/dashboard_controller_spec.rb +14 -14
- data/spec/controllers/admin/elements_controller_spec.rb +125 -105
- data/spec/controllers/admin/essence_files_controller_spec.rb +6 -7
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +52 -42
- data/spec/controllers/admin/languages_controller_spec.rb +3 -3
- data/spec/controllers/admin/pages_controller_spec.rb +81 -71
- data/spec/controllers/admin/pictures_controller_spec.rb +69 -72
- data/spec/controllers/admin/resources_controller_spec.rb +5 -5
- data/spec/controllers/admin/trash_controller_spec.rb +15 -12
- data/spec/controllers/alchemy/admin/tags_controller_spec.rb +8 -8
- data/spec/controllers/alchemy/api/contents_controller_spec.rb +73 -0
- data/spec/controllers/alchemy/api/elements_controller_spec.rb +69 -0
- data/spec/controllers/alchemy/api/pages_controller_spec.rb +86 -0
- data/spec/controllers/attachments_controller_spec.rb +8 -8
- data/spec/controllers/contents_controller_spec.rb +22 -0
- data/spec/controllers/elements_controller_spec.rb +10 -4
- data/spec/controllers/messages_controller_spec.rb +35 -34
- data/spec/controllers/pages_controller_spec.rb +37 -28
- data/spec/controllers/pictures_controller_spec.rb +90 -23
- data/spec/dummy/app/models/dummy_user.rb +0 -4
- data/spec/dummy/app/views/alchemy/elements/_all_you_can_eat_editor.html.erb +11 -0
- data/spec/dummy/config/alchemy/elements.yml +22 -1
- data/spec/dummy/config/alchemy/page_layouts.yml +4 -0
- data/spec/dummy/config/application.rb +2 -1
- data/spec/dummy/config/environments/test.rb +3 -1
- data/spec/features/admin/dashboard_spec.rb +41 -6
- data/spec/features/admin/language_tree_feature_spec.rb +3 -3
- data/spec/features/admin/legacy_page_url_management_spec.rb +1 -1
- data/spec/features/admin/link_overlay_spec.rb +7 -7
- data/spec/features/admin/locale_select_feature_spec.rb +5 -2
- data/spec/features/admin/modules_integration_spec.rb +1 -1
- data/spec/features/admin/page_creation_feature_spec.rb +3 -2
- data/spec/features/admin/page_editing_feature_spec.rb +66 -79
- data/spec/features/admin/picture_library_integration_spec.rb +8 -8
- data/spec/features/admin/resources_integration_spec.rb +21 -21
- data/spec/features/admin/tinymce_feature_spec.rb +36 -0
- data/spec/features/navigation_spec.rb +1 -1
- data/spec/features/page_feature_spec.rb +34 -34
- data/spec/features/picture_security_spec.rb +4 -4
- data/spec/features/security_spec.rb +1 -1
- data/spec/features/translation_integration_spec.rb +7 -7
- data/spec/helpers/admin/base_helper_spec.rb +51 -49
- data/spec/helpers/admin/contents_helper_spec.rb +11 -11
- data/spec/helpers/admin/elements_helper_spec.rb +20 -17
- data/spec/helpers/admin/essences_helper_spec.rb +42 -11
- data/spec/helpers/admin/navigation_helper_spec.rb +64 -54
- data/spec/helpers/admin/pages_helper_spec.rb +10 -10
- data/spec/helpers/admin/tags_helper_spec.rb +16 -16
- data/spec/helpers/base_helper_spec.rb +11 -11
- data/spec/helpers/elements_block_helper_spec.rb +24 -24
- data/spec/helpers/elements_helper_spec.rb +46 -46
- data/spec/helpers/essences_helper_spec.rb +90 -17
- data/spec/helpers/pages_helper_spec.rb +53 -53
- data/spec/helpers/picture_url_helpers_spec.rb +6 -6
- data/spec/helpers/url_helper_spec.rb +32 -32
- data/spec/libraries/config_spec.rb +9 -9
- data/spec/libraries/controller_actions_spec.rb +14 -14
- data/spec/libraries/i18n_spec.rb +6 -6
- data/spec/libraries/kaminari/scoped_pagination_url_helper_spec.rb +4 -4
- data/spec/libraries/modules_spec.rb +4 -4
- data/spec/libraries/mount_point_spec.rb +13 -13
- data/spec/libraries/page_layout_spec.rb +24 -24
- data/spec/libraries/permissions_spec.rb +97 -80
- data/spec/libraries/resource_spec.rb +37 -37
- data/spec/libraries/resources_helper_spec.rb +19 -19
- data/spec/libraries/shell_spec.rb +17 -17
- data/spec/libraries/template_tracker_spec.rb +14 -14
- data/spec/libraries/tinymce_spec.rb +8 -8
- data/spec/libraries/userstamp_spec.rb +2 -2
- data/spec/mailers/messages_spec.rb +4 -4
- data/spec/models/attachment_spec.rb +86 -30
- data/spec/models/cell_spec.rb +10 -10
- data/spec/models/content_spec.rb +106 -46
- data/spec/models/element_spec.rb +94 -115
- data/spec/models/essence_date_spec.rb +1 -1
- data/spec/models/essence_file_spec.rb +4 -4
- data/spec/models/essence_picture_spec.rb +56 -25
- data/spec/models/essence_richtext_spec.rb +1 -1
- data/spec/models/essence_text_spec.rb +7 -7
- data/spec/models/language_spec.rb +12 -12
- data/spec/models/legacy_page_url_spec.rb +2 -2
- data/spec/models/message_spec.rb +12 -5
- data/spec/models/page_spec.rb +259 -235
- data/spec/models/picture_spec.rb +72 -166
- data/spec/models/site_spec.rb +41 -41
- data/spec/models/tag_spec.rb +7 -7
- data/spec/routing/api_routing_spec.rb +150 -0
- data/spec/routing/routing_spec.rb +28 -28
- data/spec/spec_helper.rb +6 -5
- data/spec/support/hint_examples.rb +5 -5
- data/spec/support/transformation_examples.rb +173 -0
- data/spec/tasks/helpers_spec.rb +29 -29
- data/spec/views/essences/essence_boolean_editor_spec.rb +32 -0
- data/spec/views/essences/essence_boolean_view_spec.rb +2 -2
- data/spec/views/essences/essence_date_view_spec.rb +1 -1
- data/spec/views/essences/essence_link_view_spec.rb +11 -0
- data/spec/views/essences/essence_picture_view_spec.rb +56 -11
- data/spec/views/essences/essence_richtext_view_spec.rb +12 -0
- data/spec/views/essences/essence_text_view_spec.rb +12 -0
- data/vendor/assets/javascripts/tinymce/langs/de.js +20 -2
- data/vendor/assets/javascripts/tinymce/langs/fr.js +14 -1
- data/vendor/assets/javascripts/tinymce/langs/nl.js +22 -4
- data/vendor/assets/javascripts/tinymce/plugins/anchor/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/autoresize/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/charmap/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/code/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/directionality/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/hr/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/link/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/tabfocus/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/table/plugin.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/themes/modern/theme.min.js +1 -1
- data/vendor/assets/javascripts/tinymce/tinymce.min.js +11 -10
- metadata +72 -42
- data/app/views/alchemy/messages/contact_form_mail.es.text.erb +0 -12
- data/config/locales/alchemy.es.yml +0 -958
- data/config/locales/alchemy.ru.yml +0 -837
- data/config/locales/simple_form.es.yml +0 -6
- data/config/locales/simple_form.ru.yml +0 -25
- data/lib/rails/generators/alchemy/scaffold/files/alchemy.es.yml +0 -31
- data/vendor/assets/javascripts/tinymce/langs/es.js +0 -197
- 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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
50
|
-
response.
|
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.
|
64
|
-
Config.
|
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.
|
72
|
-
response.body.
|
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.
|
80
|
-
response.body.
|
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.
|
89
|
-
response.body.
|
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.
|
117
|
+
expect(controller).to receive(:redirect_page)
|
109
118
|
controller.send(:redirect_to_public_child)
|
110
|
-
controller.instance_variable_get('@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.
|
141
|
-
response.
|
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.
|
147
|
-
response.
|
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.
|
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.
|
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.
|
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].
|
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.
|
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.
|
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').
|
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.
|
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.
|
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').
|
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').
|
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').
|
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').
|
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').
|
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.
|
94
|
-
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',
|
109
|
-
|
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.
|
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.
|
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.
|
150
|
-
response.
|
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.
|
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').
|
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').
|
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').
|
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').
|
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').
|
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').
|
311
|
+
expect(response.body[0x10..0x18].unpack('NN')).to eq([40,30])
|
245
312
|
end
|
246
313
|
end
|
247
314
|
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
|
-
|
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
|