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
@@ -6,31 +6,31 @@ describe Alchemy::MountPoint do
|
|
6
6
|
describe '.get' do
|
7
7
|
|
8
8
|
it "returns the path of alchemy's mount point" do
|
9
|
-
Alchemy::MountPoint.
|
10
|
-
Alchemy::MountPoint.get.
|
9
|
+
allow(Alchemy::MountPoint).to receive(:mount_point).and_return('/cms')
|
10
|
+
expect(Alchemy::MountPoint.get).to eq('/cms')
|
11
11
|
end
|
12
12
|
|
13
13
|
it "removes the leading slash if root mount point" do
|
14
|
-
Alchemy::MountPoint.
|
15
|
-
Alchemy::MountPoint.get.
|
14
|
+
allow(Alchemy::MountPoint).to receive(:mount_point).and_return('/')
|
15
|
+
expect(Alchemy::MountPoint.get).to eq('')
|
16
16
|
end
|
17
17
|
|
18
18
|
context "with remove_leading_slash_if_blank set to false" do
|
19
19
|
before {
|
20
|
-
Alchemy::MountPoint.
|
20
|
+
allow(Alchemy::MountPoint).to receive(:mount_point).and_return('/')
|
21
21
|
}
|
22
22
|
|
23
23
|
it "does not remove the leading white slash of path" do
|
24
|
-
Alchemy::MountPoint.get(false).
|
24
|
+
expect(Alchemy::MountPoint.get(false)).to eq('/')
|
25
25
|
end
|
26
26
|
|
27
27
|
context "and with mount point not root" do
|
28
28
|
before {
|
29
|
-
Alchemy::MountPoint.
|
29
|
+
allow(Alchemy::MountPoint).to receive(:mount_point).and_return('/cms')
|
30
30
|
}
|
31
31
|
|
32
32
|
it "does not remove the leading white slash of path" do
|
33
|
-
Alchemy::MountPoint.get(false).
|
33
|
+
expect(Alchemy::MountPoint.get(false)).to eq('/cms')
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -38,23 +38,23 @@ describe Alchemy::MountPoint do
|
|
38
38
|
|
39
39
|
describe '.routes' do
|
40
40
|
it "returns the routes object from alchemy engine" do
|
41
|
-
Alchemy::MountPoint.routes.
|
41
|
+
expect(Alchemy::MountPoint.routes).to be_instance_of(ActionDispatch::Journey::Route)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe '.mount_point' do
|
46
46
|
it 'returns the raw mount point path from routes' do
|
47
|
-
Alchemy::MountPoint.
|
48
|
-
Alchemy::MountPoint.mount_point.
|
47
|
+
allow(Alchemy::MountPoint).to receive(:routes).and_return(OpenStruct.new(path: OpenStruct.new(spec: '/cms')))
|
48
|
+
expect(Alchemy::MountPoint.mount_point).to eq('/cms')
|
49
49
|
end
|
50
50
|
|
51
51
|
context "Alchemy routes could not be found" do
|
52
52
|
before {
|
53
|
-
Alchemy::MountPoint.
|
53
|
+
allow(Alchemy::MountPoint).to receive(:routes).and_return(nil)
|
54
54
|
}
|
55
55
|
|
56
56
|
it "falls back to root path" do
|
57
|
-
Alchemy::MountPoint.mount_point.
|
57
|
+
expect(Alchemy::MountPoint.mount_point).to eq('/')
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -10,20 +10,20 @@ module Alchemy
|
|
10
10
|
subject { PageLayout.all }
|
11
11
|
|
12
12
|
it "should return all page_layouts" do
|
13
|
-
|
14
|
-
subject.collect { |l| l['name'] }.
|
13
|
+
is_expected.to be_instance_of(Array)
|
14
|
+
expect(subject.collect { |l| l['name'] }).to include('standard')
|
15
15
|
end
|
16
16
|
|
17
17
|
context "with empty layouts file" do
|
18
|
-
before { YAML.
|
18
|
+
before { expect(YAML).to receive(:load_file).and_return(false) }
|
19
19
|
|
20
20
|
it "returns empty array" do
|
21
|
-
|
21
|
+
is_expected.to eq([])
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
context "with missing layouts file" do
|
26
|
-
before { File.
|
26
|
+
before { expect(File).to receive(:exists?).and_return(false) }
|
27
27
|
|
28
28
|
it "raises error empty array" do
|
29
29
|
expect { subject }.to raise_error(LoadError)
|
@@ -34,19 +34,19 @@ module Alchemy
|
|
34
34
|
describe '.add' do
|
35
35
|
it "adds a definition to all definitions" do
|
36
36
|
PageLayout.add({'name' => 'foo'})
|
37
|
-
PageLayout.all.
|
37
|
+
expect(PageLayout.all).to include({'name' => 'foo'})
|
38
38
|
end
|
39
39
|
|
40
40
|
it "adds a array of definitions to all definitions" do
|
41
41
|
PageLayout.add([{'name' => 'foo'}, {'name' => 'bar'}])
|
42
|
-
PageLayout.all.
|
43
|
-
PageLayout.all.
|
42
|
+
expect(PageLayout.all).to include({'name' => 'foo'})
|
43
|
+
expect(PageLayout.all).to include({'name' => 'bar'})
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe ".get" do
|
48
48
|
it "should return the page_layout description found by given name" do
|
49
|
-
PageLayout.
|
49
|
+
allow(PageLayout).to receive(:all).and_return([{'name' => 'default'}, {'name' => 'contact'}])
|
50
50
|
expect(PageLayout.get('default')).to eq({'name' => 'default'})
|
51
51
|
end
|
52
52
|
end
|
@@ -55,7 +55,7 @@ module Alchemy
|
|
55
55
|
it "should not hold a layout twice" do
|
56
56
|
layouts = PageLayout.layouts_with_own_for_select('standard', 1, false)
|
57
57
|
layouts = layouts.collect(&:last)
|
58
|
-
layouts.select { |l| l == "standard" }.length.
|
58
|
+
expect(layouts.select { |l| l == "standard" }.length).to eq(1)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -65,35 +65,35 @@ module Alchemy
|
|
65
65
|
subject { PageLayout.selectable_layouts(language.id) }
|
66
66
|
|
67
67
|
it "should not display hidden page layouts" do
|
68
|
-
subject.each { |l| l['hide'].
|
68
|
+
subject.each { |l| expect(l['hide']).not_to eq(true) }
|
69
69
|
end
|
70
70
|
|
71
71
|
context "with already taken layouts" do
|
72
|
-
before
|
73
|
-
PageLayout.
|
74
|
-
Page.
|
75
|
-
|
72
|
+
before do
|
73
|
+
allow(PageLayout).to receive(:all).and_return([{'unique' => true}])
|
74
|
+
allow(Page).to receive(:where).and_return double(pluck: [1])
|
75
|
+
end
|
76
76
|
|
77
77
|
it "should not include unique layouts" do
|
78
|
-
subject.each { |l| l['unique'].
|
78
|
+
subject.each { |l| expect(l['unique']).not_to eq(true) }
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
context "with sites layouts present" do
|
83
83
|
let(:site) { Site.new }
|
84
84
|
let(:definitions) { [{'name' => 'default_site', 'page_layouts' => %w(intro)}] }
|
85
|
-
before { Site.
|
85
|
+
before { allow(Site).to receive(:layout_definitions).and_return(definitions) }
|
86
86
|
|
87
87
|
it "should only return layouts for site" do
|
88
|
-
subject.length.
|
89
|
-
subject.first['name'].
|
88
|
+
expect(subject.length).to eq(1)
|
89
|
+
expect(subject.first['name']).to eq('intro')
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
describe ".element_names_for" do
|
95
95
|
it "should return all element names for the given pagelayout" do
|
96
|
-
PageLayout.
|
96
|
+
allow(PageLayout).to receive(:get).with('default').and_return({'name' => 'default', 'elements' => ['element_1', 'element_2']})
|
97
97
|
expect(PageLayout.element_names_for('default')).to eq(['element_1', 'element_2'])
|
98
98
|
end
|
99
99
|
|
@@ -105,7 +105,7 @@ module Alchemy
|
|
105
105
|
|
106
106
|
context "when page_layout description does not contain the elements key" do
|
107
107
|
it "should return an empty array" do
|
108
|
-
PageLayout.
|
108
|
+
allow(PageLayout).to receive(:get).with('layout_without_elements_key').and_return({'name' => 'layout_without_elements_key'})
|
109
109
|
expect(PageLayout.element_names_for('layout_without_elements_key')).to eq([])
|
110
110
|
end
|
111
111
|
end
|
@@ -117,15 +117,15 @@ module Alchemy
|
|
117
117
|
|
118
118
|
context "with no translation present" do
|
119
119
|
it "returns the name capitalized" do
|
120
|
-
|
120
|
+
is_expected.to eq('Contact')
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
124
|
context "with translation present" do
|
125
|
-
before { I18n.
|
125
|
+
before { expect(I18n).to receive(:t).and_return('Kontakt') }
|
126
126
|
|
127
127
|
it "returns the translated name" do
|
128
|
-
|
128
|
+
is_expected.to eq('Kontakt')
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
@@ -15,45 +15,58 @@ describe Alchemy::Permissions do
|
|
15
15
|
let(:not_visible_page) { build_stubbed(:public_page, restricted: false, visible: false) }
|
16
16
|
let(:restricted_page) { build_stubbed(:public_page, public: true, restricted: true) }
|
17
17
|
let(:visible_restricted_page) { build_stubbed(:page, visible: true, restricted: true) }
|
18
|
-
let(:published_element) { mock_model(Alchemy::Element, public
|
19
|
-
let(:restricted_element) { mock_model(Alchemy::Element, public
|
18
|
+
let(:published_element) { mock_model(Alchemy::Element, restricted?: false, public?: true, trashed?: false) }
|
19
|
+
let(:restricted_element) { mock_model(Alchemy::Element, restricted?: true, public?: true, trashed?: false) }
|
20
|
+
let(:published_content) { mock_model(Alchemy::Content, restricted?: false, public?: true, trashed?: false) }
|
21
|
+
let(:restricted_content) { mock_model(Alchemy::Content, restricted?: true, public?: true, trashed?: false) }
|
20
22
|
|
21
23
|
context "A guest user" do
|
22
24
|
let(:user) { nil }
|
23
25
|
|
24
26
|
it "can only download not restricted attachments" do
|
25
|
-
|
26
|
-
|
27
|
+
is_expected.to be_able_to(:download, attachment)
|
28
|
+
is_expected.not_to be_able_to(:download, restricted_attachment)
|
27
29
|
end
|
28
30
|
|
29
31
|
it "can only see not restricted attachments" do
|
30
|
-
|
31
|
-
|
32
|
+
is_expected.to be_able_to(:show, attachment)
|
33
|
+
is_expected.not_to be_able_to(:show, restricted_attachment)
|
32
34
|
end
|
33
35
|
|
34
36
|
it "can only download not restricted pictures" do
|
35
|
-
|
36
|
-
|
37
|
+
is_expected.to be_able_to(:download, picture)
|
38
|
+
is_expected.not_to be_able_to(:download, restricted_picture)
|
37
39
|
end
|
38
40
|
|
39
41
|
it "can only see not restricted pictures" do
|
40
|
-
|
41
|
-
|
42
|
+
is_expected.to be_able_to(:show, picture)
|
43
|
+
is_expected.not_to be_able_to(:show, restricted_picture)
|
42
44
|
end
|
43
45
|
|
44
46
|
it "can only visit not restricted pages" do
|
45
|
-
|
46
|
-
|
47
|
+
is_expected.to be_able_to(:show, public_page)
|
48
|
+
is_expected.not_to be_able_to(:show, restricted_page)
|
49
|
+
is_expected.to be_able_to(:index, public_page)
|
50
|
+
is_expected.not_to be_able_to(:index, restricted_page)
|
47
51
|
end
|
48
52
|
|
49
53
|
it "can only see visible not restricted pages" do
|
50
|
-
|
51
|
-
|
54
|
+
is_expected.to be_able_to(:see, visible_page)
|
55
|
+
is_expected.not_to be_able_to(:see, not_visible_page)
|
52
56
|
end
|
53
57
|
|
54
58
|
it "can only see public not restricted elements" do
|
55
|
-
|
56
|
-
|
59
|
+
is_expected.to be_able_to(:show, published_element)
|
60
|
+
is_expected.not_to be_able_to(:show, restricted_element)
|
61
|
+
is_expected.to be_able_to(:index, published_element)
|
62
|
+
is_expected.not_to be_able_to(:index, restricted_element)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "can only see public not restricted contents" do
|
66
|
+
is_expected.to be_able_to(:show, published_content)
|
67
|
+
is_expected.not_to be_able_to(:show, restricted_content)
|
68
|
+
is_expected.to be_able_to(:index, published_content)
|
69
|
+
is_expected.not_to be_able_to(:index, restricted_content)
|
57
70
|
end
|
58
71
|
end
|
59
72
|
|
@@ -61,42 +74,53 @@ describe Alchemy::Permissions do
|
|
61
74
|
let(:user) { member_user }
|
62
75
|
|
63
76
|
it "can download all attachments" do
|
64
|
-
|
65
|
-
|
77
|
+
is_expected.to be_able_to(:download, attachment)
|
78
|
+
is_expected.to be_able_to(:download, restricted_attachment)
|
66
79
|
end
|
67
80
|
|
68
81
|
it "can see all attachments" do
|
69
|
-
|
70
|
-
|
82
|
+
is_expected.to be_able_to(:show, attachment)
|
83
|
+
is_expected.to be_able_to(:show, restricted_attachment)
|
71
84
|
end
|
72
85
|
|
73
86
|
it "can download all pictures" do
|
74
|
-
|
75
|
-
|
87
|
+
is_expected.to be_able_to(:download, picture)
|
88
|
+
is_expected.to be_able_to(:download, restricted_picture)
|
76
89
|
end
|
77
90
|
|
78
91
|
it "can see all pictures" do
|
79
|
-
|
80
|
-
|
92
|
+
is_expected.to be_able_to(:show, picture)
|
93
|
+
is_expected.to be_able_to(:show, restricted_picture)
|
81
94
|
end
|
82
95
|
|
83
96
|
it "can visit restricted pages" do
|
84
|
-
|
85
|
-
|
97
|
+
is_expected.to be_able_to(:show, public_page)
|
98
|
+
is_expected.to be_able_to(:show, restricted_page)
|
99
|
+
is_expected.to be_able_to(:index, public_page)
|
100
|
+
is_expected.to be_able_to(:index, restricted_page)
|
86
101
|
end
|
87
102
|
|
88
103
|
it "can see visible restricted pages" do
|
89
|
-
|
90
|
-
|
104
|
+
is_expected.to be_able_to(:see, visible_page)
|
105
|
+
is_expected.to be_able_to(:see, visible_restricted_page)
|
91
106
|
end
|
92
107
|
|
93
108
|
it "can not see invisible pages" do
|
94
|
-
|
109
|
+
is_expected.not_to be_able_to(:see, not_visible_page)
|
95
110
|
end
|
96
111
|
|
97
112
|
it "can see public restricted elements" do
|
98
|
-
|
99
|
-
|
113
|
+
is_expected.to be_able_to(:show, published_element)
|
114
|
+
is_expected.to be_able_to(:show, restricted_element)
|
115
|
+
is_expected.to be_able_to(:index, published_element)
|
116
|
+
is_expected.to be_able_to(:index, restricted_element)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "can see public restricted contents" do
|
120
|
+
is_expected.to be_able_to(:show, published_content)
|
121
|
+
is_expected.to be_able_to(:show, restricted_content)
|
122
|
+
is_expected.to be_able_to(:index, published_content)
|
123
|
+
is_expected.to be_able_to(:index, restricted_content)
|
100
124
|
end
|
101
125
|
end
|
102
126
|
|
@@ -104,68 +128,65 @@ describe Alchemy::Permissions do
|
|
104
128
|
let(:user) { author_user }
|
105
129
|
|
106
130
|
it "can visit the dashboard" do
|
107
|
-
|
108
|
-
|
131
|
+
is_expected.to be_able_to(:index, :alchemy_admin_dashboard)
|
132
|
+
is_expected.to be_able_to(:info, :alchemy_admin_dashboard)
|
109
133
|
end
|
110
134
|
|
111
135
|
it "can see picture thumbnails" do
|
112
|
-
|
136
|
+
is_expected.to be_able_to(:thumbnail, Alchemy::Picture)
|
113
137
|
end
|
114
138
|
|
115
139
|
it "can edit page content" do
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
it "can not publish pages" do
|
128
|
-
should_not be_able_to(:publish, Alchemy::Page)
|
140
|
+
is_expected.to be_able_to(:show, unpublic_page)
|
141
|
+
is_expected.to be_able_to(:index, Alchemy::Page)
|
142
|
+
is_expected.to be_able_to(:info, Alchemy::Page)
|
143
|
+
is_expected.to be_able_to(:configure, Alchemy::Page)
|
144
|
+
is_expected.to be_able_to(:update, Alchemy::Page)
|
145
|
+
is_expected.to be_able_to(:fold, Alchemy::Page)
|
146
|
+
is_expected.to be_able_to(:link, Alchemy::Page)
|
147
|
+
is_expected.to be_able_to(:visit, Alchemy::Page)
|
148
|
+
is_expected.to be_able_to(:unlock, Alchemy::Page)
|
149
|
+
is_expected.to be_able_to(:publish, Alchemy::Page)
|
129
150
|
end
|
130
151
|
|
131
152
|
it "can manage elements" do
|
132
|
-
|
153
|
+
is_expected.to be_able_to(:manage, Alchemy::Element)
|
133
154
|
end
|
134
155
|
|
135
156
|
it "can see all attachments" do
|
136
|
-
|
137
|
-
|
157
|
+
is_expected.to be_able_to(:read, Alchemy::Attachment)
|
158
|
+
is_expected.to be_able_to(:download, Alchemy::Attachment)
|
138
159
|
end
|
139
160
|
|
140
161
|
it "can see all pictures" do
|
141
|
-
|
142
|
-
|
162
|
+
is_expected.to be_able_to(:read, Alchemy::Picture)
|
163
|
+
is_expected.to be_able_to(:info, Alchemy::Picture)
|
143
164
|
end
|
144
165
|
|
145
166
|
it "can manage contents" do
|
146
|
-
|
167
|
+
is_expected.to be_able_to(:manage, Alchemy::Content)
|
147
168
|
end
|
148
169
|
|
149
170
|
it "can manage essences" do
|
150
|
-
|
151
|
-
|
171
|
+
is_expected.to be_able_to(:manage, Alchemy::EssencePicture)
|
172
|
+
is_expected.to be_able_to(:manage, Alchemy::EssenceFile)
|
152
173
|
end
|
153
174
|
|
154
175
|
it "can see the trash" do
|
155
|
-
|
176
|
+
is_expected.to be_able_to(:index, :trash)
|
156
177
|
end
|
157
178
|
|
158
179
|
it "can manage the clipboard" do
|
159
|
-
|
180
|
+
is_expected.to be_able_to(:manage, :alchemy_admin_clipboard)
|
160
181
|
end
|
161
182
|
|
162
183
|
it "can see tags" do
|
163
|
-
|
164
|
-
|
184
|
+
is_expected.to be_able_to(:read, Alchemy::Tag)
|
185
|
+
is_expected.to be_able_to(:autocomplete, Alchemy::Tag)
|
165
186
|
end
|
166
187
|
|
167
188
|
it "can index layoutpages" do
|
168
|
-
|
189
|
+
is_expected.to be_able_to(:index, :alchemy_admin_layoutpages)
|
169
190
|
end
|
170
191
|
end
|
171
192
|
|
@@ -173,38 +194,34 @@ describe Alchemy::Permissions do
|
|
173
194
|
let(:user) { editor_user }
|
174
195
|
|
175
196
|
it "can manage pages" do
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
end
|
185
|
-
|
186
|
-
it "can publish pages" do
|
187
|
-
should be_able_to(:publish, Alchemy::Page)
|
197
|
+
is_expected.to be_able_to(:copy, Alchemy::Page)
|
198
|
+
is_expected.to be_able_to(:copy_language_tree, Alchemy::Page)
|
199
|
+
is_expected.to be_able_to(:create, Alchemy::Page)
|
200
|
+
is_expected.to be_able_to(:destroy, Alchemy::Page)
|
201
|
+
is_expected.to be_able_to(:flush, Alchemy::Page)
|
202
|
+
is_expected.to be_able_to(:order, Alchemy::Page)
|
203
|
+
is_expected.to be_able_to(:sort, Alchemy::Page)
|
204
|
+
is_expected.to be_able_to(:switch_language, Alchemy::Page)
|
188
205
|
end
|
189
206
|
|
190
207
|
it "can not see invisible pages" do
|
191
|
-
|
208
|
+
is_expected.not_to be_able_to(:see, not_visible_page)
|
192
209
|
end
|
193
210
|
|
194
211
|
it "can clear the trash" do
|
195
|
-
|
212
|
+
is_expected.to be_able_to(:clear, :trash)
|
196
213
|
end
|
197
214
|
|
198
215
|
it "can manage attachments" do
|
199
|
-
|
216
|
+
is_expected.to be_able_to(:manage, Alchemy::Attachment)
|
200
217
|
end
|
201
218
|
|
202
219
|
it "can manage pictures" do
|
203
|
-
|
220
|
+
is_expected.to be_able_to(:manage, Alchemy::Picture)
|
204
221
|
end
|
205
222
|
|
206
223
|
it "can manage tags" do
|
207
|
-
|
224
|
+
is_expected.to be_able_to(:manage, Alchemy::Tag)
|
208
225
|
end
|
209
226
|
end
|
210
227
|
|
@@ -212,15 +229,15 @@ describe Alchemy::Permissions do
|
|
212
229
|
let(:user) { admin_user }
|
213
230
|
|
214
231
|
it "can check for alchemy updates" do
|
215
|
-
|
232
|
+
is_expected.to be_able_to(:update_check, :alchemy_admin_dashboard)
|
216
233
|
end
|
217
234
|
|
218
235
|
it "can manage languages" do
|
219
|
-
|
236
|
+
is_expected.to be_able_to(:manage, Alchemy::Language)
|
220
237
|
end
|
221
238
|
|
222
239
|
it "can manage sites" do
|
223
|
-
|
240
|
+
is_expected.to be_able_to(:manage, Alchemy::Site)
|
224
241
|
end
|
225
242
|
end
|
226
243
|
end
|