alchemy_cms 3.0.4 → 3.1.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -4,32 +4,32 @@ describe "Picture url helpers" do
|
|
|
4
4
|
|
|
5
5
|
it "should generate a url string for cropped picture" do
|
|
6
6
|
p = show_picture_path(:id => 3, :crop => "crop", :size => "100x33", :name => "kitten", :format => "jpg")
|
|
7
|
-
p.
|
|
7
|
+
expect(p).to eq("/pictures/3/show/100x33/crop/kitten.jpg")
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it "should generate a url string for cropped and masked picture" do
|
|
11
11
|
p = show_picture_path(:id => 3, :crop => "crop", :crop_from => "0x0", :crop_size => "900x300", :size => "100x33", :name => "kitten", :format => :jpg)
|
|
12
|
-
p.
|
|
12
|
+
expect(p).to eq("/pictures/3/show/100x33/crop/0x0/900x300/kitten.jpg")
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "should generate a url string for cropped thumbnail" do
|
|
16
16
|
p = thumbnail_path(:id => 3, :crop => "crop", :size => "100x33", :name => "kitten", :format => :jpg)
|
|
17
|
-
p.
|
|
17
|
+
expect(p).to eq("/pictures/3/thumbnails/100x33/crop/kitten.jpg")
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "should generate a url string for thumbnail with default name and format" do
|
|
21
21
|
p = thumbnail_path(:id => 3, :size => "100x33")
|
|
22
|
-
p.
|
|
22
|
+
expect(p).to eq("/pictures/3/thumbnails/100x33/thumbnail.png")
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "should generate a url string for cropped and masked thumbnail" do
|
|
26
26
|
p = thumbnail_path(:id => 3, :crop_from => "0x0", :crop_size => "900x300", :size => "100x33", :name => "kitten", :format => :jpg)
|
|
27
|
-
p.
|
|
27
|
+
expect(p).to eq("/pictures/3/thumbnails/100x33/0x0/900x300/kitten.jpg")
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should generate a url string for zoomed image" do
|
|
31
31
|
p = zoom_picture_path(:id => 3, :name => "kitten", :format => :jpg)
|
|
32
|
-
p.
|
|
32
|
+
expect(p).to eq("/pictures/3/zoom/kitten.jpg")
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
end
|
|
@@ -12,33 +12,33 @@ module Alchemy
|
|
|
12
12
|
context "when multi_language" do
|
|
13
13
|
|
|
14
14
|
before do
|
|
15
|
-
helper.
|
|
15
|
+
allow(helper).to receive(:multi_language?).and_return(true)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "should return a Hash with urlname and language_id parameter" do
|
|
19
|
-
helper.
|
|
20
|
-
helper.show_page_path_params(page).
|
|
19
|
+
allow(helper).to receive(:multi_language?).and_return(true)
|
|
20
|
+
expect(helper.show_page_path_params(page)).to include(urlname: 'testpage', lang: 'en')
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it "should return a Hash with urlname, language_id and query parameter" do
|
|
24
|
-
helper.
|
|
25
|
-
helper.show_page_path_params(page, {query: 'test'}).
|
|
24
|
+
allow(helper).to receive(:multi_language?).and_return(true)
|
|
25
|
+
expect(helper.show_page_path_params(page, {query: 'test'})).to include(urlname: 'testpage', lang: 'en', query: 'test')
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
context "not multi_language" do
|
|
30
30
|
before do
|
|
31
|
-
helper.
|
|
31
|
+
allow(helper).to receive(:multi_language?).and_return(false)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "should return a Hash with the urlname but without language_id parameter" do
|
|
35
|
-
helper.show_page_path_params(page).
|
|
36
|
-
helper.show_page_path_params(page).
|
|
35
|
+
expect(helper.show_page_path_params(page)).to include(urlname: 'testpage')
|
|
36
|
+
expect(helper.show_page_path_params(page)).not_to include(lang: 'en')
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "should return a Hash with urlname and query parameter" do
|
|
40
|
-
helper.show_page_path_params(page, {query: 'test'}).
|
|
41
|
-
helper.show_page_path_params(page).
|
|
40
|
+
expect(helper.show_page_path_params(page, {query: 'test'})).to include(urlname: 'testpage', query: 'test')
|
|
41
|
+
expect(helper.show_page_path_params(page)).not_to include(lang: 'en')
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
end
|
|
@@ -47,29 +47,29 @@ module Alchemy
|
|
|
47
47
|
context "when multi_language" do
|
|
48
48
|
|
|
49
49
|
before do
|
|
50
|
-
helper.
|
|
50
|
+
allow(helper).to receive(:multi_language?).and_return(true)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it "should return the correct relative path string" do
|
|
54
|
-
helper.show_alchemy_page_path(page).
|
|
54
|
+
expect(helper.show_alchemy_page_path(page)).to eq("/#{page.language_code}/testpage")
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "should return the correct relative path string with additional parameters" do
|
|
58
|
-
helper.show_alchemy_page_path(page, {query: 'test'}).
|
|
58
|
+
expect(helper.show_alchemy_page_path(page, {query: 'test'})).to eq("/#{page.language_code}/testpage?query=test")
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
context "not multi_language" do
|
|
63
63
|
before do
|
|
64
|
-
helper.
|
|
64
|
+
allow(helper).to receive(:multi_language?).and_return(false)
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it "should return the correct relative path string" do
|
|
68
|
-
helper.show_alchemy_page_path(page).
|
|
68
|
+
expect(helper.show_alchemy_page_path(page)).to eq("/testpage")
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it "should return the correct relative path string with additional parameter" do
|
|
72
|
-
helper.show_alchemy_page_path(page, {query: 'test'}).
|
|
72
|
+
expect(helper.show_alchemy_page_path(page, {query: 'test'})).to eq("/testpage?query=test")
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
end
|
|
@@ -78,29 +78,29 @@ module Alchemy
|
|
|
78
78
|
context "when multi_language" do
|
|
79
79
|
|
|
80
80
|
before do
|
|
81
|
-
helper.
|
|
81
|
+
allow(helper).to receive(:multi_language?).and_return(true)
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
it "should return the correct url string" do
|
|
85
|
-
helper.show_alchemy_page_url(page).
|
|
85
|
+
expect(helper.show_alchemy_page_url(page)).to eq("http://#{helper.request.host}/#{page.language_code}/testpage")
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
it "should return the correct url string with additional parameters" do
|
|
89
|
-
helper.show_alchemy_page_url(page, {query: 'test'}).
|
|
89
|
+
expect(helper.show_alchemy_page_url(page, {query: 'test'})).to eq("http://#{helper.request.host}/#{page.language_code}/testpage?query=test")
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
context "not multi_language" do
|
|
94
94
|
before do
|
|
95
|
-
helper.
|
|
95
|
+
allow(helper).to receive(:multi_language?).and_return(false)
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
it "should return the correct url string" do
|
|
99
|
-
helper.show_alchemy_page_url(page).
|
|
99
|
+
expect(helper.show_alchemy_page_url(page)).to eq("http://#{helper.request.host}/testpage")
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
it "should return the correct url string with additional parameter" do
|
|
103
|
-
helper.show_alchemy_page_url(page, {query: 'test'}).
|
|
103
|
+
expect(helper.show_alchemy_page_url(page, {query: 'test'})).to eq("http://#{helper.request.host}/testpage?query=test")
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
end
|
|
@@ -111,35 +111,35 @@ module Alchemy
|
|
|
111
111
|
|
|
112
112
|
describe '#show_alchemy_picture_path' do
|
|
113
113
|
it "should return the correct relative path string" do
|
|
114
|
-
helper.show_alchemy_picture_path(picture).
|
|
114
|
+
expect(helper.show_alchemy_picture_path(picture)).to match(Regexp.new("/pictures/42/show/cute_kitten.jpg"))
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
describe '#show_alchemy_picture_url' do
|
|
119
119
|
it "should return the correct url string" do
|
|
120
|
-
helper.show_alchemy_picture_url(picture).
|
|
120
|
+
expect(helper.show_alchemy_picture_url(picture)).to match(Regexp.new("http://#{helper.request.host}/pictures/42/show/cute_kitten.jpg"))
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
describe '#show_picture_path_params' do
|
|
125
125
|
it "should return the correct params for rendering a picture" do
|
|
126
|
-
helper.show_picture_path_params(picture).
|
|
126
|
+
expect(helper.show_picture_path_params(picture)).to include(name: 'cute_kitten', format: 'jpg')
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
it "should include the secure hash parameter" do
|
|
130
|
-
helper.show_picture_path_params(picture).keys.
|
|
131
|
-
helper.show_picture_path_params(picture)[:sh].
|
|
130
|
+
expect(helper.show_picture_path_params(picture).keys).to include(:sh)
|
|
131
|
+
expect(helper.show_picture_path_params(picture)[:sh]).not_to be_empty
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
context "with additional params" do
|
|
135
135
|
it "should include these params" do
|
|
136
|
-
helper.show_picture_path_params(picture, {format: 'png'}).
|
|
136
|
+
expect(helper.show_picture_path_params(picture, {format: 'png'})).to include(name: 'cute_kitten', format: 'png')
|
|
137
137
|
end
|
|
138
138
|
end
|
|
139
139
|
|
|
140
140
|
context "with additional params crop set to true" do
|
|
141
141
|
it "should include crop as parameter" do
|
|
142
|
-
helper.show_picture_path_params(picture, {crop: true}).
|
|
142
|
+
expect(helper.show_picture_path_params(picture, {crop: true})).to include(name: 'cute_kitten', crop: 'crop')
|
|
143
143
|
end
|
|
144
144
|
end
|
|
145
145
|
end
|
|
@@ -149,11 +149,11 @@ module Alchemy
|
|
|
149
149
|
let(:attachment) { mock_model(Attachment, urlname: 'test-attachment.pdf') }
|
|
150
150
|
|
|
151
151
|
it 'should return the correct relative path to download an attachment' do
|
|
152
|
-
helper.download_alchemy_attachment_path(attachment).
|
|
152
|
+
expect(helper.download_alchemy_attachment_path(attachment)).to eq("/attachment/#{attachment.id}/download/#{attachment.urlname}")
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
it 'should return the correct url to download an attachment' do
|
|
156
|
-
helper.download_alchemy_attachment_url(attachment).
|
|
156
|
+
expect(helper.download_alchemy_attachment_url(attachment)).to eq("http://#{helper.request.host}/attachment/#{attachment.id}/download/#{attachment.urlname}")
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
159
|
|
|
@@ -164,7 +164,7 @@ module Alchemy
|
|
|
164
164
|
let(:current_server) { '' }
|
|
165
165
|
|
|
166
166
|
it "returns the url to this element" do
|
|
167
|
-
|
|
167
|
+
is_expected.to eq("#{current_server}/#{element.page.urlname}##{element_dom_id(element)}")
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
170
|
end
|
|
@@ -5,12 +5,12 @@ module Alchemy
|
|
|
5
5
|
|
|
6
6
|
describe ".get" do
|
|
7
7
|
it "should call #show" do
|
|
8
|
-
Config.
|
|
8
|
+
expect(Config).to receive(:show).and_return({})
|
|
9
9
|
Config.get(:mailer)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
it "should return the requested part of the config" do
|
|
13
|
-
Config.
|
|
13
|
+
expect(Config).to receive(:show).and_return({'mailer' => {'setting' => 'true'}})
|
|
14
14
|
expect(Config.get(:mailer)).to eq({'setting' => 'true'})
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -19,7 +19,7 @@ module Alchemy
|
|
|
19
19
|
let(:main_app_config_path) { "#{Rails.root}/config/alchemy/config.yml" }
|
|
20
20
|
|
|
21
21
|
it "should call and return .read_file with the correct config path" do
|
|
22
|
-
Config.
|
|
22
|
+
expect(Config).to receive(:read_file).with(main_app_config_path).once.and_return({setting: 'true'})
|
|
23
23
|
expect(Config.send(:main_app_config)).to eq({setting: 'true'})
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -28,7 +28,7 @@ module Alchemy
|
|
|
28
28
|
let(:env_specific_config_path) { "#{Rails.root}/config/alchemy/#{Rails.env}.config.yml" }
|
|
29
29
|
|
|
30
30
|
it "should call and return .read_file with the correct config path" do
|
|
31
|
-
Config.
|
|
31
|
+
expect(Config).to receive(:read_file).with(env_specific_config_path).once.and_return({setting: 'true'})
|
|
32
32
|
expect(Config.send(:env_specific_config)).to eq({setting: 'true'})
|
|
33
33
|
end
|
|
34
34
|
end
|
|
@@ -38,7 +38,7 @@ module Alchemy
|
|
|
38
38
|
before { Config.instance_variable_set("@config", nil) }
|
|
39
39
|
|
|
40
40
|
it "should call and return .merge_configs!" do
|
|
41
|
-
Config.
|
|
41
|
+
expect(Config).to receive(:merge_configs!).once.and_return({setting: 'true'})
|
|
42
42
|
expect(Config.show).to eq({setting: 'true'})
|
|
43
43
|
end
|
|
44
44
|
end
|
|
@@ -55,17 +55,17 @@ module Alchemy
|
|
|
55
55
|
|
|
56
56
|
describe '.read_file' do
|
|
57
57
|
context 'when given path to yml file exists' do
|
|
58
|
-
before { File.
|
|
58
|
+
before { allow(File).to receive(:exists?).and_return(true) }
|
|
59
59
|
|
|
60
60
|
it 'should call YAML.load_file with the given config path' do
|
|
61
|
-
YAML.
|
|
61
|
+
expect(YAML).to receive(:load_file).once.with('path/to/config.yml').and_return({})
|
|
62
62
|
Config.send(:read_file, 'path/to/config.yml')
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
context 'but its empty' do
|
|
66
66
|
before do
|
|
67
|
-
File.
|
|
68
|
-
YAML.
|
|
67
|
+
allow(File).to receive(:exists?).with('empty_file.yml').and_return(true)
|
|
68
|
+
allow(YAML).to receive(:load_file).and_return(false) # YAML.load_file returns false if file is empty.
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it "should return an empty Hash" do
|
|
@@ -18,7 +18,7 @@ describe 'Alchemy::ControllerActions', type: 'controller' do
|
|
|
18
18
|
describe "#current_alchemy_user" do
|
|
19
19
|
context "with default current_user_method" do
|
|
20
20
|
it "calls current_user by default" do
|
|
21
|
-
controller.
|
|
21
|
+
expect(controller).to receive :current_user
|
|
22
22
|
controller.send :current_alchemy_user
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -29,7 +29,7 @@ describe 'Alchemy::ControllerActions', type: 'controller' do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "calls the custom method" do
|
|
32
|
-
controller.
|
|
32
|
+
expect(controller).to receive :current_admin
|
|
33
33
|
controller.send :current_alchemy_user
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -63,7 +63,7 @@ describe 'Alchemy::ControllerActions', type: 'controller' do
|
|
|
63
63
|
context "with a Language argument" do
|
|
64
64
|
it "should set the language to the passed Language instance" do
|
|
65
65
|
controller.send :set_alchemy_language, klingonian
|
|
66
|
-
assigns(:language).
|
|
66
|
+
expect(assigns(:language)).to eq(klingonian)
|
|
67
67
|
expect(Alchemy::Language.current).to eq(klingonian)
|
|
68
68
|
end
|
|
69
69
|
end
|
|
@@ -71,7 +71,7 @@ describe 'Alchemy::ControllerActions', type: 'controller' do
|
|
|
71
71
|
context "with a language id argument" do
|
|
72
72
|
it "should set the language to the language specified by the passed id" do
|
|
73
73
|
controller.send :set_alchemy_language, klingonian.id
|
|
74
|
-
assigns(:language).
|
|
74
|
+
expect(assigns(:language)).to eq(klingonian)
|
|
75
75
|
expect(Alchemy::Language.current).to eq(klingonian)
|
|
76
76
|
end
|
|
77
77
|
end
|
|
@@ -79,16 +79,16 @@ describe 'Alchemy::ControllerActions', type: 'controller' do
|
|
|
79
79
|
context "with a language code argument" do
|
|
80
80
|
it "should set the language to the language specified by the passed code" do
|
|
81
81
|
controller.send :set_alchemy_language, klingonian.code
|
|
82
|
-
assigns(:language).
|
|
82
|
+
expect(assigns(:language)).to eq(klingonian)
|
|
83
83
|
expect(Alchemy::Language.current).to eq(klingonian)
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
context "with no lang param" do
|
|
88
88
|
it "should set the default language" do
|
|
89
|
-
controller.
|
|
89
|
+
allow(controller).to receive(:params).and_return({})
|
|
90
90
|
controller.send :set_alchemy_language
|
|
91
|
-
assigns(:language).
|
|
91
|
+
expect(assigns(:language)).to eq(default_language)
|
|
92
92
|
expect(Alchemy::Language.current).to eq(default_language)
|
|
93
93
|
expect(controller.session).to include_language_information_for(default_language)
|
|
94
94
|
end
|
|
@@ -96,34 +96,34 @@ describe 'Alchemy::ControllerActions', type: 'controller' do
|
|
|
96
96
|
|
|
97
97
|
context "with language in the session" do
|
|
98
98
|
before do
|
|
99
|
-
controller.
|
|
100
|
-
Alchemy::Language.
|
|
99
|
+
allow(controller).to receive(:session).and_return(alchemy_language_id: klingonian.id)
|
|
100
|
+
allow(Alchemy::Language).to receive(:current).and_return(klingonian)
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
it "should use the language from the session" do
|
|
104
104
|
controller.send :set_alchemy_language
|
|
105
|
-
assigns(:language).
|
|
105
|
+
expect(assigns(:language)).to eq(klingonian)
|
|
106
106
|
expect(Alchemy::Language.current).to eq(klingonian)
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
context "with lang param" do
|
|
111
111
|
it "should set the language" do
|
|
112
|
-
controller.
|
|
112
|
+
allow(controller).to receive(:params).and_return(lang: klingonian.code)
|
|
113
113
|
controller.send :set_alchemy_language
|
|
114
|
-
assigns(:language).
|
|
114
|
+
expect(assigns(:language)).to eq(klingonian)
|
|
115
115
|
expect(Alchemy::Language.current).to eq(klingonian)
|
|
116
116
|
expect(controller.session).to include_language_information_for(klingonian)
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
context "for language that does not exist" do
|
|
120
120
|
before do
|
|
121
|
-
controller.
|
|
121
|
+
allow(controller).to receive(:params).and_return(lang: 'fo')
|
|
122
122
|
controller.send :set_alchemy_language
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
it "should set the language to default" do
|
|
126
|
-
assigns(:language).
|
|
126
|
+
expect(assigns(:language)).to eq(default_language)
|
|
127
127
|
expect(Alchemy::Language.current).to eq(default_language)
|
|
128
128
|
expect(controller.session).to include_language_information_for(default_language)
|
|
129
129
|
end
|
data/spec/libraries/i18n_spec.rb
CHANGED
|
@@ -4,19 +4,19 @@ module Alchemy
|
|
|
4
4
|
describe I18n do
|
|
5
5
|
describe '.translation_files' do
|
|
6
6
|
subject { I18n.translation_files }
|
|
7
|
-
it {
|
|
8
|
-
it {
|
|
7
|
+
it { is_expected.to be_a Array }
|
|
8
|
+
it { is_expected.to be_any { |f| f =~ /alchemy.*.yml/ } }
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
describe '.available_locales' do
|
|
12
12
|
subject { I18n.available_locales }
|
|
13
|
-
before { I18n.
|
|
14
|
-
it {
|
|
15
|
-
it {
|
|
13
|
+
before { allow(I18n).to receive(:translation_files).and_return(['alchemy.kl.yml']) }
|
|
14
|
+
it { is_expected.to be_a Array }
|
|
15
|
+
it { is_expected.to include :kl }
|
|
16
16
|
|
|
17
17
|
context 'when locales are already set in @@available_locales' do
|
|
18
18
|
before { I18n.class_variable_set(:@@available_locales, [:kl, :jp]) }
|
|
19
|
-
it {
|
|
19
|
+
it { is_expected.to eq([:kl, :jp]) }
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -11,8 +11,8 @@ describe Kaminari::Helpers::Tag do
|
|
|
11
11
|
let(:options) { {scope: scope} }
|
|
12
12
|
|
|
13
13
|
it "calls url_for on that url proxy scope." do
|
|
14
|
-
template.
|
|
15
|
-
scope.
|
|
14
|
+
expect(template).not_to receive(:url_for)
|
|
15
|
+
expect(scope).to receive(:url_for)
|
|
16
16
|
subject.page_url_for(1)
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -21,8 +21,8 @@ describe Kaminari::Helpers::Tag do
|
|
|
21
21
|
let(:options) { {} }
|
|
22
22
|
|
|
23
23
|
it "calls url_for on the template." do
|
|
24
|
-
template.
|
|
25
|
-
scope.
|
|
24
|
+
expect(template).to receive(:url_for)
|
|
25
|
+
expect(scope).not_to receive(:url_for)
|
|
26
26
|
subject.page_url_for(1)
|
|
27
27
|
end
|
|
28
28
|
end
|
|
@@ -18,7 +18,7 @@ module Alchemy
|
|
|
18
18
|
let(:name) { 'dashboard' }
|
|
19
19
|
|
|
20
20
|
it "returns the module definition" do
|
|
21
|
-
|
|
21
|
+
is_expected.to eq(dashboard_module)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -27,14 +27,14 @@ module Alchemy
|
|
|
27
27
|
let(:name) { {controller: controller_name, action: 'index'} }
|
|
28
28
|
|
|
29
29
|
it "returns the module definition" do
|
|
30
|
-
|
|
30
|
+
is_expected.to eq(dashboard_module)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
context 'with leading slash in controller name' do
|
|
34
34
|
let(:controller_name) { '/alchemy/admin/dashboard' }
|
|
35
35
|
|
|
36
36
|
it "returns the module definition" do
|
|
37
|
-
|
|
37
|
+
is_expected.to eq(dashboard_module)
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -60,7 +60,7 @@ module Alchemy
|
|
|
60
60
|
|
|
61
61
|
it "registers a module definition into global list of modules" do
|
|
62
62
|
Modules.register_module(alchemy_module)
|
|
63
|
-
Modules.alchemy_modules.
|
|
63
|
+
expect(Modules.alchemy_modules).to include(alchemy_module)
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
end
|