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
|
@@ -10,22 +10,22 @@ describe "Resources" do
|
|
|
10
10
|
|
|
11
11
|
it "should have a button for creating a new resource items" do
|
|
12
12
|
visit '/admin/events'
|
|
13
|
-
page.
|
|
13
|
+
expect(page).to have_selector('#toolbar div.button_with_label a.icon_button span.icon.create')
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "should list existing items" do
|
|
17
17
|
event
|
|
18
18
|
second_event
|
|
19
19
|
visit '/admin/events'
|
|
20
|
-
page.
|
|
21
|
-
page.
|
|
22
|
-
page.
|
|
20
|
+
expect(page).to have_content("My Event")
|
|
21
|
+
expect(page).to have_content("something fancy")
|
|
22
|
+
expect(page).to have_content("12.32")
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "should list existing resource-items nicely formatted" do
|
|
26
26
|
event
|
|
27
27
|
visit '/admin/events'
|
|
28
|
-
page.
|
|
28
|
+
expect(page).to have_selector('div#archive_all table.list')
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
end
|
|
@@ -33,16 +33,16 @@ describe "Resources" do
|
|
|
33
33
|
describe "form for creating and updating items" do
|
|
34
34
|
it "renders an input field according to the attribute's type" do
|
|
35
35
|
visit '/admin/events/new'
|
|
36
|
-
page.
|
|
37
|
-
page.
|
|
38
|
-
page.
|
|
39
|
-
page.
|
|
36
|
+
expect(page).to have_selector('input#event_name[type="text"]')
|
|
37
|
+
expect(page).to have_selector('input#event_starts_at[type="date"]')
|
|
38
|
+
expect(page).to have_selector('textarea#event_description')
|
|
39
|
+
expect(page).to have_selector('input#event_published[type="checkbox"]')
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it "should have a select box for associated models" do
|
|
43
43
|
visit '/admin/events/new'
|
|
44
44
|
within('form') do
|
|
45
|
-
page.
|
|
45
|
+
expect(page).to have_selector('select')
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
end
|
|
@@ -58,12 +58,12 @@ describe "Resources" do
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
it "lists the new item" do
|
|
61
|
-
page.
|
|
62
|
-
page.
|
|
61
|
+
expect(page).to have_content "My second event"
|
|
62
|
+
expect(page).to have_content "03 Mar 2012"
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
it "shows a success message" do
|
|
66
|
-
page.
|
|
66
|
+
expect(page).to have_content("Succesfully created")
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
@@ -75,15 +75,15 @@ describe "Resources" do
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
it "shows the form again" do
|
|
78
|
-
page.
|
|
78
|
+
expect(page).to have_selector "form input#event_name"
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
it "lists invalid fields" do
|
|
82
|
-
page.
|
|
82
|
+
expect(page).to have_content("can't be blank")
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
it "should not display success notice" do
|
|
86
|
-
page.
|
|
86
|
+
expect(page).not_to have_content("successfully created")
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
89
|
|
|
@@ -97,11 +97,11 @@ describe "Resources" do
|
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
it "shows the updated value" do
|
|
100
|
-
page.
|
|
100
|
+
expect(page).to have_content("New event name")
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
it "shows a success message" do
|
|
104
|
-
page.
|
|
104
|
+
expect(page).to have_content("Succesfully updated")
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
|
@@ -116,12 +116,12 @@ describe "Resources" do
|
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
it "shouldn't be on the list anymore" do
|
|
119
|
-
page.
|
|
120
|
-
page.
|
|
119
|
+
expect(page).to have_content "My Event"
|
|
120
|
+
expect(page).not_to have_content "My second Event"
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
it "should display success message" do
|
|
124
|
-
page.
|
|
124
|
+
expect(page).to have_content("Succesfully removed")
|
|
125
125
|
end
|
|
126
126
|
end
|
|
127
127
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'TinyMCE Editor' do
|
|
4
|
+
let(:user) { DummyUser.new }
|
|
5
|
+
|
|
6
|
+
before do
|
|
7
|
+
user.update(alchemy_roles: %w(admin), name: "Joe User", id: 1)
|
|
8
|
+
authorize_as_admin(user)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'base path should be set to tinymce asset folder' do
|
|
12
|
+
visit admin_dashboard_path
|
|
13
|
+
expect(page).to have_content <<-TINYMCE
|
|
14
|
+
var tinyMCEPreInit = {
|
|
15
|
+
base: '/assets/tinymce',
|
|
16
|
+
suffix: '.min'
|
|
17
|
+
};
|
|
18
|
+
TINYMCE
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context 'with asset host' do
|
|
22
|
+
before do
|
|
23
|
+
expect(ActionController::Base.config).to receive(:asset_host_set?).and_return(true)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'base path should be set to tinymce asset folder' do
|
|
27
|
+
visit admin_dashboard_path
|
|
28
|
+
expect(page).to have_content <<-TINYMCE
|
|
29
|
+
var tinyMCEPreInit = {
|
|
30
|
+
base: 'http://www.example.com/assets/tinymce',
|
|
31
|
+
suffix: '.min'
|
|
32
|
+
};
|
|
33
|
+
TINYMCE
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -14,7 +14,7 @@ module Alchemy
|
|
|
14
14
|
article = p.elements.find_by_name('article')
|
|
15
15
|
article.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
|
|
16
16
|
visit "/#{p.urlname}"
|
|
17
|
-
within('div#content div.article div.intro') { page.
|
|
17
|
+
within('div#content div.article div.intro') { expect(page).to have_content('Welcome to Peters Petshop') }
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "should show the navigation with all visible pages" do
|
|
@@ -23,39 +23,39 @@ module Alchemy
|
|
|
23
23
|
FactoryGirl.create(:public_page, :visible => true, :name => 'Page 2')
|
|
24
24
|
]
|
|
25
25
|
visit '/'
|
|
26
|
-
within('div#navigation ul') { page.
|
|
26
|
+
within('div#navigation ul') { expect(page).to have_selector('li a[href="/page-1"], li a[href="/page-2"]') }
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
describe "redirecting" do
|
|
30
30
|
context "in multi language mode" do
|
|
31
31
|
before do
|
|
32
|
-
Config.
|
|
33
|
-
PagesController.
|
|
32
|
+
allow(Config).to receive(:get) { |arg| arg == :url_nesting ? true : Config.parameter(arg) }
|
|
33
|
+
allow_any_instance_of(PagesController).to receive(:multi_language?).and_return(true)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
context "if no language params are given" do
|
|
37
37
|
it "should redirect to url with nested language code" do
|
|
38
38
|
visit "/#{public_page_1.urlname}"
|
|
39
|
-
page.current_path.
|
|
39
|
+
expect(page.current_path).to eq("/#{public_page_1.language_code}/#{public_page_1.urlname}")
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
context "if requested page is unpublished" do
|
|
44
44
|
before do
|
|
45
|
-
Config.
|
|
45
|
+
allow(Config).to receive(:get) { |arg| arg == :url_nesting ? false : Config.parameter(arg) }
|
|
46
46
|
public_page_1.update_attributes(:public => false, :name => 'Not Public', :urlname => '')
|
|
47
47
|
public_child
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "should redirect to public child" do
|
|
51
51
|
visit "/#{default_language.code}/not-public"
|
|
52
|
-
page.current_path.
|
|
52
|
+
expect(page.current_path).to eq("/#{default_language.code}/public-child")
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
context "and url has no language code" do
|
|
56
56
|
it "should redirect to url of public child with language code of default language" do
|
|
57
57
|
visit '/not-public'
|
|
58
|
-
page.current_path.
|
|
58
|
+
expect(page.current_path).to eq("/#{default_language.code}/public-child")
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
end
|
|
@@ -63,56 +63,56 @@ module Alchemy
|
|
|
63
63
|
context "if requested url is index url" do
|
|
64
64
|
it "should redirect to pages url with default language" do
|
|
65
65
|
visit '/'
|
|
66
|
-
page.current_path.
|
|
66
|
+
expect(page.current_path).to eq("/#{default_language.code}/home")
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
context "if requested url is only the language code" do
|
|
71
71
|
it "should redirect to pages url with default language" do
|
|
72
72
|
visit "/#{default_language.code}"
|
|
73
|
-
page.current_path.
|
|
73
|
+
expect(page.current_path).to eq("/#{default_language.code}/home")
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
context "requested url is only the urlname" do
|
|
78
78
|
it "then it should redirect to pages url with nested language." do
|
|
79
79
|
visit '/home'
|
|
80
|
-
page.current_path.
|
|
80
|
+
expect(page.current_path).to eq('/en/home')
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
it "should keep additional params" do
|
|
85
85
|
visit "/#{public_page_1.urlname}?query=Peter"
|
|
86
|
-
page.current_url.
|
|
86
|
+
expect(page.current_url).to match(/\?query=Peter/)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
context "wrong language requested" do
|
|
90
|
-
before { Alchemy.user_class.
|
|
90
|
+
before { allow(Alchemy.user_class).to receive(:admins).and_return([1, 2]) }
|
|
91
91
|
|
|
92
92
|
it "should render 404 if urlname and lang parameter do not belong to same page" do
|
|
93
93
|
FactoryGirl.create(:klingonian)
|
|
94
94
|
visit "/kl/#{public_page_1.urlname}"
|
|
95
|
-
page.status_code.
|
|
95
|
+
expect(page.status_code).to eq(404)
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
it "should render 404 if requested language does not exist" do
|
|
99
99
|
public_page_1
|
|
100
100
|
LegacyPageUrl.delete_all
|
|
101
101
|
visit "/fo/#{public_page_1.urlname}"
|
|
102
|
-
page.status_code.
|
|
102
|
+
expect(page.status_code).to eq(404)
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
context "not in multi language mode" do
|
|
108
108
|
before do
|
|
109
|
-
PagesController.
|
|
110
|
-
Config.
|
|
109
|
+
allow_any_instance_of(PagesController).to receive(:multi_language?).and_return(false)
|
|
110
|
+
allow(Config).to receive(:get) { |arg| arg == :url_nesting ? false : Config.parameter(arg) }
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
it "should redirect from nested language code url to normal url" do
|
|
114
114
|
visit "/en/#{public_page_1.urlname}"
|
|
115
|
-
page.current_path.
|
|
115
|
+
expect(page.current_path).to eq("/#{public_page_1.urlname}")
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
context "should redirect to public child" do
|
|
@@ -123,35 +123,35 @@ module Alchemy
|
|
|
123
123
|
|
|
124
124
|
it "if requested page is unpublished" do
|
|
125
125
|
visit '/not-public'
|
|
126
|
-
page.current_path.
|
|
126
|
+
expect(page.current_path).to eq('/public-child')
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
it "with normal url, if requested url has nested language code and is not public" do
|
|
130
130
|
visit '/en/not-public'
|
|
131
|
-
page.current_path.
|
|
131
|
+
expect(page.current_path).to eq('/public-child')
|
|
132
132
|
end
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
it "should redirect to pages url, if requested url is index url" do
|
|
136
136
|
visit '/'
|
|
137
|
-
page.current_path.
|
|
137
|
+
expect(page.current_path).to eq('/home')
|
|
138
138
|
end
|
|
139
139
|
|
|
140
140
|
it "should keep additional params" do
|
|
141
141
|
visit "/de/#{public_page_1.urlname}?query=Peter"
|
|
142
|
-
page.current_url.
|
|
142
|
+
expect(page.current_url).to match(/\?query=Peter/)
|
|
143
143
|
end
|
|
144
144
|
end
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
describe "Handling of non-existing pages" do
|
|
148
148
|
before do
|
|
149
|
-
Alchemy.user_class.
|
|
149
|
+
allow(Alchemy.user_class).to receive(:admins).and_return([1, 2]) # We need a admin user or the signup page will show up
|
|
150
150
|
visit "/non-existing-page"
|
|
151
151
|
end
|
|
152
152
|
|
|
153
153
|
it "should render public/404.html" do
|
|
154
|
-
page.status_code.
|
|
154
|
+
expect(page.status_code).to eq(404)
|
|
155
155
|
end
|
|
156
156
|
end
|
|
157
157
|
|
|
@@ -165,7 +165,7 @@ module Alchemy
|
|
|
165
165
|
context "rendering for guest users" do
|
|
166
166
|
it "is prohibited" do
|
|
167
167
|
visit "/#{public_page_1.urlname}"
|
|
168
|
-
within('body') { page.
|
|
168
|
+
within('body') { expect(page).not_to have_selector('#alchemy_menubar') }
|
|
169
169
|
end
|
|
170
170
|
end
|
|
171
171
|
|
|
@@ -173,7 +173,7 @@ module Alchemy
|
|
|
173
173
|
it "is prohibited" do
|
|
174
174
|
authorize_as_admin(mock_model('DummyUser', alchemy_roles: %w(member), language: 'en'))
|
|
175
175
|
visit "/#{public_page_1.urlname}"
|
|
176
|
-
within('body') { page.
|
|
176
|
+
within('body') { expect(page).not_to have_selector('#alchemy_menubar') }
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
179
|
|
|
@@ -181,7 +181,7 @@ module Alchemy
|
|
|
181
181
|
it "is allowed" do
|
|
182
182
|
authorize_as_admin(mock_model('DummyUser', alchemy_roles: %w(author), language: 'en', cache_key: 'aaa'))
|
|
183
183
|
visit "/#{public_page_1.urlname}"
|
|
184
|
-
within('body') { page.
|
|
184
|
+
within('body') { expect(page).to have_selector('#alchemy_menubar') }
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
187
|
|
|
@@ -189,7 +189,7 @@ module Alchemy
|
|
|
189
189
|
it "is allowed" do
|
|
190
190
|
authorize_as_admin(mock_model('DummyUser', alchemy_roles: %w(editor), language: 'en', cache_key: 'aaa'))
|
|
191
191
|
visit "/#{public_page_1.urlname}"
|
|
192
|
-
within('body') { page.
|
|
192
|
+
within('body') { expect(page).to have_selector('#alchemy_menubar') }
|
|
193
193
|
end
|
|
194
194
|
end
|
|
195
195
|
|
|
@@ -197,7 +197,7 @@ module Alchemy
|
|
|
197
197
|
it "is allowed" do
|
|
198
198
|
authorize_as_admin(mock_model('DummyUser', alchemy_roles: %w(admin), language: 'en', cache_key: 'aaa'))
|
|
199
199
|
visit "/#{public_page_1.urlname}"
|
|
200
|
-
within('body') { page.
|
|
200
|
+
within('body') { expect(page).to have_selector('#alchemy_menubar') }
|
|
201
201
|
end
|
|
202
202
|
end
|
|
203
203
|
|
|
@@ -208,15 +208,15 @@ module Alchemy
|
|
|
208
208
|
end
|
|
209
209
|
|
|
210
210
|
it "a link to the admin area" do
|
|
211
|
-
within('#alchemy_menubar') { page.
|
|
211
|
+
within('#alchemy_menubar') { expect(page).to have_selector("li a[href='#{alchemy.admin_dashboard_path}']") }
|
|
212
212
|
end
|
|
213
213
|
|
|
214
214
|
it "a link to edit the current page" do
|
|
215
|
-
within('#alchemy_menubar') { page.
|
|
215
|
+
within('#alchemy_menubar') { expect(page).to have_selector("li a[href='#{alchemy.edit_admin_page_path(public_page_1)}']") }
|
|
216
216
|
end
|
|
217
217
|
|
|
218
218
|
it "a form and button to logout of alchemy" do
|
|
219
|
-
within('#alchemy_menubar') { page.
|
|
219
|
+
within('#alchemy_menubar') { expect(page).to have_selector("li form[action='#{Alchemy.logout_path}'], li button[type='submit']") }
|
|
220
220
|
end
|
|
221
221
|
end
|
|
222
222
|
end
|
|
@@ -240,7 +240,7 @@ module Alchemy
|
|
|
240
240
|
context 'as a guest user' do
|
|
241
241
|
it "I am not able to visit the page" do
|
|
242
242
|
visit restricted_page.urlname
|
|
243
|
-
current_path.
|
|
243
|
+
expect(current_path).to eq(Alchemy.login_path)
|
|
244
244
|
end
|
|
245
245
|
end
|
|
246
246
|
|
|
@@ -249,7 +249,7 @@ module Alchemy
|
|
|
249
249
|
|
|
250
250
|
it "I am able to visit the page" do
|
|
251
251
|
visit restricted_page.urlname
|
|
252
|
-
current_path.
|
|
252
|
+
expect(current_path).to eq("/#{restricted_page.urlname}")
|
|
253
253
|
end
|
|
254
254
|
end
|
|
255
255
|
end
|
|
@@ -5,13 +5,13 @@ describe 'Picture renderung security', :js => true do
|
|
|
5
5
|
let(:picture) { Alchemy::Picture.create(:image_file => File.new(File.expand_path('../../fixtures/image.png', __FILE__))) }
|
|
6
6
|
|
|
7
7
|
# Prevent the signup view from being rendered.
|
|
8
|
-
before { Alchemy.user_class.
|
|
8
|
+
before { allow(Alchemy.user_class).to receive(:count).and_return 1 }
|
|
9
9
|
|
|
10
10
|
context "passing no security token" do
|
|
11
11
|
|
|
12
12
|
it 'should return a bad request (400)' do
|
|
13
13
|
visit "/pictures/#{picture.id}/show/image.png"
|
|
14
|
-
page.status_code.
|
|
14
|
+
expect(page.status_code).to eq(400)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
end
|
|
@@ -23,11 +23,11 @@ describe 'Picture renderung security', :js => true do
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it 'should return image' do
|
|
26
|
-
page.body.
|
|
26
|
+
expect(page.body).to match(/img/)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it 'should return status ok (200)' do
|
|
30
|
-
page.status_code.
|
|
30
|
+
expect(page.status_code).to eq(200)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
end
|
|
@@ -6,33 +6,33 @@ describe "Translation integration" do
|
|
|
6
6
|
|
|
7
7
|
it "should be possible to set the locale of the admin backend via params" do
|
|
8
8
|
visit admin_dashboard_path(locale: 'de')
|
|
9
|
-
page.
|
|
9
|
+
expect(page).to have_content('Willkommen')
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
it "should store the current locale in the session" do
|
|
13
13
|
visit admin_dashboard_path(locale: 'de')
|
|
14
14
|
visit admin_dashboard_path
|
|
15
|
-
page.
|
|
15
|
+
expect(page).to have_content('Willkommen')
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "should be possible to change the current locale in the session" do
|
|
19
19
|
visit admin_dashboard_path(locale: 'de')
|
|
20
|
-
page.
|
|
20
|
+
expect(page).to have_content('Willkommen')
|
|
21
21
|
visit admin_dashboard_path(locale: 'en')
|
|
22
|
-
page.
|
|
22
|
+
expect(page).to have_content('Welcome')
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
context 'with unknown locale' do
|
|
26
26
|
it "it uses the users default language" do
|
|
27
27
|
visit admin_dashboard_path(locale: 'ko')
|
|
28
|
-
page.
|
|
28
|
+
expect(page).to have_content('Willkommen')
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
context "if no other parameter is given" do
|
|
33
33
|
it "should use the current users language setting" do
|
|
34
34
|
visit admin_dashboard_path
|
|
35
|
-
page.
|
|
35
|
+
expect(page).to have_content('Willkommen')
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -41,7 +41,7 @@ describe "Translation integration" do
|
|
|
41
41
|
|
|
42
42
|
it "should use the browsers language setting if no other parameter is given" do
|
|
43
43
|
visit admin_dashboard_path
|
|
44
|
-
page.
|
|
44
|
+
expect(page).to have_content('Willkommen')
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
end
|