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
@@ -8,37 +8,37 @@ module Alchemy
|
|
8
8
|
describe '#dependencies' do
|
9
9
|
context 'with alchemy/pages/show given as template name' do
|
10
10
|
let(:name) { 'alchemy/pages/show' }
|
11
|
-
before { PageLayout.
|
11
|
+
before { allow(PageLayout).to receive(:all).and_return([{'name' => 'intro'}, {'name' => 'contact'}]) }
|
12
12
|
|
13
13
|
it "returns all page layout view partial names" do
|
14
|
-
|
14
|
+
is_expected.to include('alchemy/page_layouts/_intro', 'alchemy/page_layouts/_contact')
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'with a page layout given as template name' do
|
19
19
|
let(:name) { 'alchemy/page_layouts/_intro' }
|
20
20
|
let(:page_layout) { {'name' => 'intro', 'elements' => ['text']} }
|
21
|
-
before { PageLayout.
|
21
|
+
before { allow(PageLayout).to receive(:get).and_return(page_layout) }
|
22
22
|
|
23
23
|
it "returns all element layout view partial names for that layout" do
|
24
|
-
|
24
|
+
is_expected.to include('alchemy/elements/_text_view')
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'and page layout having cells' do
|
28
28
|
let(:page_layout) { {'name' => 'intro', 'elements' => ['text'], 'cells' => ['header']} }
|
29
29
|
|
30
30
|
it "returns all cell view partial names for that layout" do
|
31
|
-
|
31
|
+
is_expected.to include('alchemy/cells/_header')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'with a cell given as template name' do
|
37
37
|
let(:name) { 'alchemy/cells/_header' }
|
38
|
-
before { Cell.
|
38
|
+
before { allow(Cell).to receive(:definition_for).and_return({'name' => 'header', 'elements' => ['text']}) }
|
39
39
|
|
40
40
|
it "returns all element layout view partial names for that cell" do
|
41
|
-
|
41
|
+
is_expected.to include('alchemy/elements/_text_view')
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -47,17 +47,17 @@ module Alchemy
|
|
47
47
|
let(:elements) { [{'name' => 'text', 'contents' => [{'type' => 'EssenceText'}]}] }
|
48
48
|
|
49
49
|
context 'that is having a description' do
|
50
|
-
before { Element.
|
50
|
+
before { allow(Element).to receive(:descriptions).and_return(elements) }
|
51
51
|
|
52
52
|
it "returns all essence layout view partial names for that element" do
|
53
|
-
|
53
|
+
is_expected.to include('alchemy/essences/_essence_text_view')
|
54
54
|
end
|
55
55
|
|
56
56
|
context 'and element has picture_gallery enabled' do
|
57
57
|
let(:elements) { [{'name' => 'text', 'picture_gallery' => true}] }
|
58
58
|
|
59
59
|
it "has EssencePicture as template dependency" do
|
60
|
-
|
60
|
+
is_expected.to include('alchemy/essences/_essence_picture_view')
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -65,16 +65,16 @@ module Alchemy
|
|
65
65
|
let(:elements) { [{'name' => 'text', 'available_contents' => ['type' => 'EssenceFile']}] }
|
66
66
|
|
67
67
|
it "has these essences as template dependency" do
|
68
|
-
|
68
|
+
is_expected.to include('alchemy/essences/_essence_file_view')
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
context 'that has no description' do
|
74
|
-
before { Element.
|
74
|
+
before { allow(Element).to receive(:descriptions).and_return([]) }
|
75
75
|
|
76
76
|
it "returns empty array" do
|
77
|
-
|
77
|
+
is_expected.to be_empty
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -83,7 +83,7 @@ module Alchemy
|
|
83
83
|
let(:name) { 'shop/cart' }
|
84
84
|
|
85
85
|
it "calls rails template tracker" do
|
86
|
-
ActionView::DependencyTracker::ERBTracker.
|
86
|
+
expect(ActionView::DependencyTracker::ERBTracker).to receive(:call).with(name, nil)
|
87
87
|
subject
|
88
88
|
end
|
89
89
|
end
|
@@ -7,7 +7,7 @@ module Alchemy
|
|
7
7
|
subject { Tinymce.init }
|
8
8
|
|
9
9
|
it "returns the default config" do
|
10
|
-
|
10
|
+
is_expected.to eq(Tinymce.class_variable_get('@@init'))
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -16,7 +16,7 @@ module Alchemy
|
|
16
16
|
|
17
17
|
it "merges the default config with given config" do
|
18
18
|
Tinymce.init = another_config
|
19
|
-
Tinymce.init.
|
19
|
+
expect(Tinymce.init).to include(another_config)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -28,26 +28,26 @@ module Alchemy
|
|
28
28
|
subject { Tinymce.custom_config_contents }
|
29
29
|
|
30
30
|
before do
|
31
|
-
Element.
|
31
|
+
allow(Element).to receive(:definitions).and_return([element_definition])
|
32
32
|
# Preventing memoization
|
33
33
|
Tinymce.class_variable_set('@@custom_config_contents', nil)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "returns an array of content definitions that contain custom tinymce config and element name" do
|
37
|
-
|
38
|
-
|
37
|
+
is_expected.to be_an(Array)
|
38
|
+
is_expected.to include({'element' => element_definition['name']}.merge(content_definition))
|
39
39
|
end
|
40
40
|
|
41
41
|
context 'with no contents having custom tinymce config' do
|
42
42
|
let(:content_definition) { {'name' => 'text'} }
|
43
|
-
it {
|
43
|
+
it { is_expected.to eq([]) }
|
44
44
|
end
|
45
45
|
|
46
46
|
context 'with element definition having nil as contents value' do
|
47
47
|
let(:element_definition) { {'name' => 'element', 'contents' => nil} }
|
48
48
|
|
49
49
|
it "returns empty array" do
|
50
|
-
|
50
|
+
is_expected.to eq([])
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -57,7 +57,7 @@ module Alchemy
|
|
57
57
|
|
58
58
|
it "only returns custom tinymce config for elements of that page" do
|
59
59
|
expect(page).to receive(:element_definitions).and_return([element_definition])
|
60
|
-
|
60
|
+
is_expected.to include({'element' => element_definition['name']}.merge(content_definition))
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe 'Alchemy::AuthAccessors' do
|
4
4
|
describe '.user_class' do
|
5
5
|
it "injects userstamp class methods" do
|
6
|
-
Alchemy.user_class.
|
7
|
-
Alchemy.user_class.stamper_class_name.
|
6
|
+
expect(Alchemy.user_class).to respond_to(:stamper_class_name)
|
7
|
+
expect(Alchemy.user_class.stamper_class_name).to eq(:DummyUser)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -7,16 +7,16 @@ module Alchemy
|
|
7
7
|
let(:mail) { Messages.contact_form_mail(message, 'admin@page.com', 'contact@page.com', 'Subject') }
|
8
8
|
|
9
9
|
it "delivers a mail to owner" do
|
10
|
-
mail.to.
|
11
|
-
mail.subject.
|
10
|
+
expect(mail.to).to eq(['admin@page.com'])
|
11
|
+
expect(mail.subject).to eq('Subject')
|
12
12
|
end
|
13
13
|
|
14
14
|
it "reply_to should be set to senders email" do
|
15
|
-
mail.reply_to.
|
15
|
+
expect(mail.reply_to).to eq([message.email])
|
16
16
|
end
|
17
17
|
|
18
18
|
it "mail body includes message" do
|
19
|
-
mail.body.
|
19
|
+
expect(mail.body).to match /#{message.message}/
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -9,7 +9,7 @@ module Alchemy
|
|
9
9
|
describe 'after assign' do
|
10
10
|
it "stores the file mime type into database" do
|
11
11
|
attachment.update(file: file)
|
12
|
-
attachment.file_mime_type.
|
12
|
+
expect(attachment.file_mime_type).not_to be_blank
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -17,11 +17,11 @@ module Alchemy
|
|
17
17
|
before { attachment.save! }
|
18
18
|
|
19
19
|
it "should have a humanized name" do
|
20
|
-
attachment.name.
|
20
|
+
expect(attachment.name).to eq("image with spaces")
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should have a valid file_name" do
|
24
|
-
attachment.file_name.
|
24
|
+
expect(attachment.file_name).to eq("image-with-spaces.png")
|
25
25
|
end
|
26
26
|
|
27
27
|
after { attachment.destroy }
|
@@ -31,19 +31,19 @@ module Alchemy
|
|
31
31
|
it "should sanitize url characters in the filename" do
|
32
32
|
attachment.file_name = 'f#%&cking cute kitten pic.png'
|
33
33
|
attachment.save!
|
34
|
-
attachment.urlname.
|
34
|
+
expect(attachment.urlname).to eq('f-cking-cute-kitten-pic.png')
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should sanitize lot of dots in the name" do
|
38
38
|
attachment.file_name = 'cute.kitten.pic.png'
|
39
39
|
attachment.save!
|
40
|
-
attachment.urlname.
|
40
|
+
expect(attachment.urlname).to eq('cute-kitten-pic.png')
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should sanitize umlauts in the name" do
|
44
44
|
attachment.file_name = 'süßes katzenbild.png'
|
45
45
|
attachment.save!
|
46
|
-
attachment.urlname.
|
46
|
+
expect(attachment.urlname).to eq('suesses-katzenbild.png')
|
47
47
|
end
|
48
48
|
|
49
49
|
after { attachment.destroy }
|
@@ -52,18 +52,18 @@ module Alchemy
|
|
52
52
|
describe 'validations' do
|
53
53
|
|
54
54
|
context "having a png, but only pdf allowed" do
|
55
|
-
before { Config.
|
55
|
+
before { allow(Config).to receive(:get).and_return({'allowed_filetypes' => {'attachments' => ['pdf']}}) }
|
56
56
|
|
57
57
|
it "should not be valid" do
|
58
|
-
attachment.
|
58
|
+
expect(attachment).not_to be_valid
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
context "having a png and everything allowed" do
|
63
|
-
before { Config.
|
63
|
+
before { allow(Config).to receive(:get).and_return({'allowed_filetypes' => {'attachments' => ['*']}}) }
|
64
64
|
|
65
65
|
it "should be valid" do
|
66
|
-
attachment.
|
66
|
+
expect(attachment).to be_valid
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -71,73 +71,129 @@ module Alchemy
|
|
71
71
|
|
72
72
|
context 'PNG image' do
|
73
73
|
subject { stub_model(Attachment, file_name: 'kitten.png') }
|
74
|
-
|
74
|
+
|
75
|
+
describe '#extension' do
|
76
|
+
subject { super().extension }
|
77
|
+
it { is_expected.to eq("png") }
|
78
|
+
end
|
75
79
|
end
|
76
80
|
|
77
81
|
describe 'css classes' do
|
78
82
|
context 'mp3 file' do
|
79
83
|
subject { stub_model(Attachment, file_mime_type: 'audio/mpeg') }
|
80
|
-
|
84
|
+
|
85
|
+
describe '#icon_css_class' do
|
86
|
+
subject { super().icon_css_class }
|
87
|
+
it { is_expected.to eq("audio") }
|
88
|
+
end
|
81
89
|
end
|
82
90
|
|
83
91
|
context 'video file' do
|
84
92
|
subject { stub_model(Attachment, file_mime_type: 'video/mpeg') }
|
85
|
-
|
93
|
+
|
94
|
+
describe '#icon_css_class' do
|
95
|
+
subject { super().icon_css_class }
|
96
|
+
it { is_expected.to eq("video") }
|
97
|
+
end
|
86
98
|
end
|
87
99
|
|
88
100
|
context 'png file' do
|
89
101
|
subject { stub_model(Attachment, file_mime_type: 'image/png') }
|
90
|
-
|
102
|
+
|
103
|
+
describe '#icon_css_class' do
|
104
|
+
subject { super().icon_css_class }
|
105
|
+
it { is_expected.to eq("image") }
|
106
|
+
end
|
91
107
|
end
|
92
108
|
|
93
109
|
context 'vcf file' do
|
94
110
|
subject { stub_model(Attachment, file_mime_type: 'application/vcard') }
|
95
|
-
|
111
|
+
|
112
|
+
describe '#icon_css_class' do
|
113
|
+
subject { super().icon_css_class }
|
114
|
+
it { is_expected.to eq("vcard") }
|
115
|
+
end
|
96
116
|
end
|
97
117
|
|
98
118
|
context 'zip file' do
|
99
119
|
subject { stub_model(Attachment, file_mime_type: 'application/zip') }
|
100
|
-
|
120
|
+
|
121
|
+
describe '#icon_css_class' do
|
122
|
+
subject { super().icon_css_class }
|
123
|
+
it { is_expected.to eq("archive") }
|
124
|
+
end
|
101
125
|
end
|
102
126
|
|
103
127
|
context 'flash file' do
|
104
128
|
subject { stub_model(Attachment, file_mime_type: 'application/x-shockwave-flash') }
|
105
|
-
|
129
|
+
|
130
|
+
describe '#icon_css_class' do
|
131
|
+
subject { super().icon_css_class }
|
132
|
+
it { is_expected.to eq("flash") }
|
133
|
+
end
|
106
134
|
end
|
107
135
|
|
108
136
|
context 'photoshop file' do
|
109
137
|
subject { stub_model(Attachment, file_mime_type: 'image/x-psd') }
|
110
|
-
|
138
|
+
|
139
|
+
describe '#icon_css_class' do
|
140
|
+
subject { super().icon_css_class }
|
141
|
+
it { is_expected.to eq("psd") }
|
142
|
+
end
|
111
143
|
end
|
112
144
|
|
113
145
|
context 'text file' do
|
114
146
|
subject { stub_model(Attachment, file_mime_type: 'text/plain') }
|
115
|
-
|
147
|
+
|
148
|
+
describe '#icon_css_class' do
|
149
|
+
subject { super().icon_css_class }
|
150
|
+
it { is_expected.to eq("text") }
|
151
|
+
end
|
116
152
|
end
|
117
153
|
|
118
154
|
context 'rtf file' do
|
119
155
|
subject { stub_model(Attachment, file_mime_type: 'application/rtf') }
|
120
|
-
|
156
|
+
|
157
|
+
describe '#icon_css_class' do
|
158
|
+
subject { super().icon_css_class }
|
159
|
+
it { is_expected.to eq("rtf") }
|
160
|
+
end
|
121
161
|
end
|
122
162
|
|
123
163
|
context 'pdf file' do
|
124
164
|
subject { stub_model(Attachment, file_mime_type: 'application/pdf') }
|
125
|
-
|
165
|
+
|
166
|
+
describe '#icon_css_class' do
|
167
|
+
subject { super().icon_css_class }
|
168
|
+
it { is_expected.to eq("pdf") }
|
169
|
+
end
|
126
170
|
end
|
127
171
|
|
128
172
|
context 'word file' do
|
129
173
|
subject { stub_model(Attachment, file_mime_type: 'application/msword') }
|
130
|
-
|
174
|
+
|
175
|
+
describe '#icon_css_class' do
|
176
|
+
subject { super().icon_css_class }
|
177
|
+
it { is_expected.to eq("word") }
|
178
|
+
end
|
131
179
|
end
|
132
180
|
|
133
181
|
context 'excel file' do
|
134
182
|
subject { stub_model(Attachment, file_mime_type: 'application/vnd.ms-excel') }
|
135
|
-
|
183
|
+
|
184
|
+
describe '#icon_css_class' do
|
185
|
+
subject { super().icon_css_class }
|
186
|
+
it { is_expected.to eq("excel") }
|
187
|
+
end
|
136
188
|
end
|
137
189
|
|
138
190
|
context 'unknown file' do
|
139
191
|
subject { stub_model(Attachment, file_mime_type: '') }
|
140
|
-
|
192
|
+
|
193
|
+
describe '#icon_css_class' do
|
194
|
+
subject { super().icon_css_class }
|
195
|
+
it { is_expected.to eq("file") }
|
196
|
+
end
|
141
197
|
end
|
142
198
|
end
|
143
199
|
|
@@ -147,11 +203,11 @@ module Alchemy
|
|
147
203
|
context 'if only on restricted pages' do
|
148
204
|
before do
|
149
205
|
pages = double(any?: true)
|
150
|
-
pages.
|
151
|
-
attachment.
|
206
|
+
expect(pages).to receive(:not_restricted).and_return([])
|
207
|
+
expect(attachment).to receive(:pages).twice.and_return(pages)
|
152
208
|
end
|
153
209
|
|
154
|
-
it {
|
210
|
+
it { is_expected.to be_truthy }
|
155
211
|
end
|
156
212
|
|
157
213
|
context 'if not only on restricted pages' do
|
@@ -159,11 +215,11 @@ module Alchemy
|
|
159
215
|
|
160
216
|
before do
|
161
217
|
pages = double(any?: true)
|
162
|
-
pages.
|
163
|
-
attachment.
|
218
|
+
expect(pages).to receive(:not_restricted).and_return([page])
|
219
|
+
expect(attachment).to receive(:pages).twice.and_return(pages)
|
164
220
|
end
|
165
221
|
|
166
|
-
it {
|
222
|
+
it { is_expected.to be_falsey }
|
167
223
|
end
|
168
224
|
end
|
169
225
|
|
data/spec/models/cell_spec.rb
CHANGED
@@ -30,7 +30,7 @@ module Alchemy
|
|
30
30
|
|
31
31
|
describe ".definitions_for_element" do
|
32
32
|
before do
|
33
|
-
Cell.
|
33
|
+
allow(Cell).to receive(:definitions).and_return([
|
34
34
|
{'name' => 'cell_1', 'elements' => ['target', 'other']},
|
35
35
|
{'name' => 'cell_2', 'elements' => ['other', 'other']},
|
36
36
|
{'name' => 'cell_3', 'elements' => ['other', 'target']}
|
@@ -58,15 +58,15 @@ module Alchemy
|
|
58
58
|
describe "#available_elements" do
|
59
59
|
context "without assigned elements" do
|
60
60
|
it "should return an empty Array" do
|
61
|
-
cell.
|
62
|
-
cell.available_elements.
|
61
|
+
allow(cell).to receive(:definition).and_return({})
|
62
|
+
expect(cell.available_elements).to eq([])
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
context "with assigned elements" do
|
67
67
|
it "should return an Array of element names" do
|
68
|
-
cell.
|
69
|
-
cell.available_elements.
|
68
|
+
allow(cell).to receive(:definition).and_return({'elements' => ['test_element', 'test_element_2']})
|
69
|
+
expect(cell.available_elements).to eq(['test_element', 'test_element_2'])
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -74,22 +74,22 @@ module Alchemy
|
|
74
74
|
describe "#definition" do
|
75
75
|
context "without a definition for the expected cellname" do
|
76
76
|
it "should return an empty Hash" do
|
77
|
-
Cell.
|
78
|
-
cell.definition.
|
77
|
+
allow(Cell).to receive(:definition_for).and_return({})
|
78
|
+
expect(cell.definition).to eq({})
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
context "with a definition for the expected cellname found" do
|
83
83
|
it "should return its definition Hash" do
|
84
|
-
Cell.
|
85
|
-
cell.definition.
|
84
|
+
allow(Cell).to receive(:definition_for).and_return({'name' => 'test_cell', 'elements' => ['test_element', 'test_element_2']})
|
85
|
+
expect(cell.definition).to eq({'name' => 'test_cell', 'elements' => ['test_element', 'test_element_2']})
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
describe "#name_for_label" do
|
91
91
|
it "should call translated_label_for" do
|
92
|
-
Cell.
|
92
|
+
expect(Cell).to receive(:translated_label_for).with(cell.name)
|
93
93
|
cell.name_for_label
|
94
94
|
end
|
95
95
|
end
|