alchemy_cms 3.3.0.rc1 → 3.3.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -2
- data/Gemfile +1 -0
- data/alchemy_cms.gemspec +6 -6
- data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +0 -7
- data/app/assets/javascripts/alchemy/alchemy.dialog.js.coffee +4 -4
- data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +51 -5
- data/app/assets/javascripts/alchemy/alchemy.sitemap.js.coffee +0 -2
- data/app/assets/stylesheets/alchemy/elements.scss +2 -2
- data/app/controllers/alchemy/admin/elements_controller.rb +2 -0
- data/app/controllers/alchemy/admin/pages_controller.rb +11 -3
- data/app/controllers/alchemy/admin/pictures_controller.rb +1 -0
- data/app/models/alchemy/element.rb +3 -1
- data/app/models/alchemy/element/element_contents.rb +2 -7
- data/app/models/alchemy/element/presenters.rb +11 -4
- data/app/models/alchemy/page.rb +3 -1
- data/app/views/alchemy/admin/attachments/archive_overlay.js.erb +0 -1
- data/app/views/alchemy/admin/contents/create.js.erb +0 -1
- data/app/views/alchemy/admin/elements/_element_header.html.erb +3 -1
- data/app/views/alchemy/admin/elements/order.js.erb +25 -10
- data/app/views/alchemy/admin/elements/update.js.erb +1 -2
- data/app/views/alchemy/admin/essence_files/assign.js.erb +0 -1
- data/app/views/alchemy/admin/essence_pictures/assign.js.erb +0 -1
- data/app/views/alchemy/admin/legacy_page_urls/create.js.erb +0 -1
- data/app/views/alchemy/admin/pages/destroy.js.erb +0 -1
- data/app/views/alchemy/admin/pages/update.js.erb +6 -4
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +2 -1
- data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -7
- data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +0 -1
- data/bin/alchemy +1 -1
- data/bin/rspec +3 -2
- data/bin/spring +6 -6
- data/config/alchemy/config.yml +6 -1
- data/lib/alchemy/seeder.rb +9 -3
- data/lib/alchemy/version.rb +1 -1
- metadata +6 -471
- data/spec/controllers/alchemy/admin/attachments_controller_spec.rb +0 -193
- data/spec/controllers/alchemy/admin/base_controller_spec.rb +0 -87
- data/spec/controllers/alchemy/admin/clipboard_controller_spec.rb +0 -60
- data/spec/controllers/alchemy/admin/contents_controller_spec.rb +0 -78
- data/spec/controllers/alchemy/admin/dashboard_controller_spec.rb +0 -144
- data/spec/controllers/alchemy/admin/elements_controller_spec.rb +0 -496
- data/spec/controllers/alchemy/admin/essence_files_controller_spec.rb +0 -76
- data/spec/controllers/alchemy/admin/essence_pictures_controller_spec.rb +0 -202
- data/spec/controllers/alchemy/admin/languages_controller_spec.rb +0 -73
- data/spec/controllers/alchemy/admin/layoutpages_controller_spec.rb +0 -21
- data/spec/controllers/alchemy/admin/pages_controller_spec.rb +0 -639
- data/spec/controllers/alchemy/admin/pictures_controller_spec.rb +0 -383
- data/spec/controllers/alchemy/admin/resources_controller_spec.rb +0 -81
- data/spec/controllers/alchemy/admin/tags_controller_spec.rb +0 -63
- data/spec/controllers/alchemy/admin/trash_controller_spec.rb +0 -67
- data/spec/controllers/alchemy/api/contents_controller_spec.rb +0 -125
- data/spec/controllers/alchemy/api/elements_controller_spec.rb +0 -124
- data/spec/controllers/alchemy/api/pages_controller_spec.rb +0 -167
- data/spec/controllers/alchemy/attachments_controller_spec.rb +0 -64
- data/spec/controllers/alchemy/base_controller_spec.rb +0 -106
- data/spec/controllers/alchemy/elements_controller_spec.rb +0 -48
- data/spec/controllers/alchemy/messages_controller_spec.rb +0 -204
- data/spec/controllers/alchemy/on_page_layout_mixin_spec.rb +0 -330
- data/spec/controllers/alchemy/pages_controller_spec.rb +0 -343
- data/spec/controllers/alchemy/pictures_controller_spec.rb +0 -415
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/controllers/admin/events_controller.rb +0 -3
- data/spec/dummy/app/controllers/application_controller.rb +0 -15
- data/spec/dummy/app/controllers/login_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/ability.rb +0 -9
- data/spec/dummy/app/models/dummy_model.rb +0 -3
- data/spec/dummy/app/models/dummy_user.rb +0 -15
- data/spec/dummy/app/models/event.rb +0 -10
- data/spec/dummy/app/models/location.rb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_all_you_can_eat_editor.html.erb +0 -11
- data/spec/dummy/app/views/alchemy/elements/_all_you_can_eat_view.html.erb +0 -31
- data/spec/dummy/app/views/alchemy/elements/_article_editor.html.erb +0 -6
- data/spec/dummy/app/views/alchemy/elements/_article_view.html.erb +0 -10
- data/spec/dummy/app/views/alchemy/elements/_bild_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_bild_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_contactform_editor.html.erb +0 -6
- data/spec/dummy/app/views/alchemy/elements/_contactform_view.html.erb +0 -16
- data/spec/dummy/app/views/alchemy/elements/_download_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_download_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_erb_element_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_erb_element_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_header_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_header_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_headline_editor.html.erb +0 -1
- data/spec/dummy/app/views/alchemy/elements/_headline_view.html.erb +0 -1
- data/spec/dummy/app/views/alchemy/elements/_news_editor.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_news_view.html.erb +0 -11
- data/spec/dummy/app/views/alchemy/elements/_search_editor.html.erb +0 -1
- data/spec/dummy/app/views/alchemy/elements/_search_view.html.erb +0 -4
- data/spec/dummy/app/views/alchemy/elements/_slide_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_slide_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/elements/_slider_editor.html.erb +0 -2
- data/spec/dummy/app/views/alchemy/elements/_slider_view.html.erb +0 -4
- data/spec/dummy/app/views/alchemy/elements/_text_editor.html.erb +0 -3
- data/spec/dummy/app/views/alchemy/elements/_text_view.html.erb +0 -5
- data/spec/dummy/app/views/alchemy/page_layouts/_standard.html.erb +0 -15
- data/spec/dummy/app/views/layouts/application.html.erb +0 -17
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/alchemy/cells.yml +0 -5
- data/spec/dummy/config/alchemy/elements.yml +0 -109
- data/spec/dummy/config/alchemy/page_layouts.yml +0 -32
- data/spec/dummy/config/application.rb +0 -32
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -32
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -77
- data/spec/dummy/config/environments/test.rb +0 -43
- data/spec/dummy/config/initializers/alchemy.rb +0 -3
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/secret_token.rb +0 -12
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/kl.yml +0 -2
- data/spec/dummy/config/routes.rb +0 -12
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/db/migrate/20121026104128_create_events.rb +0 -20
- data/spec/dummy/db/migrate/20130328101418_create_locations.rb +0 -9
- data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -1
- data/spec/dummy/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +0 -1
- data/spec/dummy/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +0 -1
- data/spec/dummy/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +0 -1
- data/spec/dummy/db/migrate/20131209225243_create_dummy_users.rb +0 -9
- data/spec/dummy/db/migrate/20150122213511_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +0 -31
- data/spec/dummy/db/migrate/20150122213512_add_missing_unique_indices.acts_as_taggable_on_engine.rb +0 -20
- data/spec/dummy/db/migrate/20150122213513_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +0 -15
- data/spec/dummy/db/migrate/20150122213514_add_missing_taggable_index.acts_as_taggable_on_engine.rb +0 -10
- data/spec/dummy/db/migrate/20150412103152_create_dummy_model.rb +0 -7
- data/spec/dummy/db/migrate/20150608204610_add_parent_element_id_to_alchemy_elements.rb +0 -1
- data/spec/dummy/db/migrate/20150729151825_add_link_text_to_alchemy_essence_files.rb +0 -1
- data/spec/dummy/db/migrate/20150906195818_add_locale_to_alchemy_languages.rb +0 -1
- data/spec/dummy/db/schema.rb +0 -326
- data/spec/dummy/db/seeds.rb +0 -1
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/javascripts +0 -1
- data/spec/factories.rb +0 -13
- data/spec/features/admin/admin_layout_spec.rb +0 -14
- data/spec/features/admin/dashboard_spec.rb +0 -81
- data/spec/features/admin/edit_elements_feature_spec.rb +0 -36
- data/spec/features/admin/language_tree_feature_spec.rb +0 -32
- data/spec/features/admin/languages_features_spec.rb +0 -65
- data/spec/features/admin/legacy_page_url_management_spec.rb +0 -62
- data/spec/features/admin/link_overlay_spec.rb +0 -53
- data/spec/features/admin/locale_select_feature_spec.rb +0 -25
- data/spec/features/admin/modules_integration_spec.rb +0 -23
- data/spec/features/admin/navigation_feature_spec.rb +0 -22
- data/spec/features/admin/page_creation_feature_spec.rb +0 -51
- data/spec/features/admin/page_editing_feature_spec.rb +0 -135
- data/spec/features/admin/picture_library_integration_spec.rb +0 -62
- data/spec/features/admin/resources_integration_spec.rb +0 -128
- data/spec/features/admin/site_select_feature_spec.rb +0 -31
- data/spec/features/admin/tinymce_feature_spec.rb +0 -33
- data/spec/features/navigation_spec.rb +0 -9
- data/spec/features/page_feature_spec.rb +0 -186
- data/spec/features/page_redirects_spec.rb +0 -358
- data/spec/features/picture_security_spec.rb +0 -29
- data/spec/features/security_spec.rb +0 -24
- data/spec/features/translation_integration_spec.rb +0 -51
- data/spec/fixtures/500x500.png +0 -0
- data/spec/fixtures/80x60.png +0 -0
- data/spec/fixtures/animated.gif +0 -0
- data/spec/fixtures/image with spaces.png +0 -0
- data/spec/fixtures/image.png +0 -0
- data/spec/fixtures/image2.PNG +0 -0
- data/spec/fixtures/image3.jpeg +0 -0
- data/spec/helpers/alchemy/admin/attachments_helper_spec.rb +0 -15
- data/spec/helpers/alchemy/admin/base_helper_spec.rb +0 -280
- data/spec/helpers/alchemy/admin/contents_helper_spec.rb +0 -46
- data/spec/helpers/alchemy/admin/elements_helper_spec.rb +0 -314
- data/spec/helpers/alchemy/admin/essences_helper_spec.rb +0 -201
- data/spec/helpers/alchemy/admin/navigation_helper_spec.rb +0 -294
- data/spec/helpers/alchemy/admin/pages_helper_spec.rb +0 -63
- data/spec/helpers/alchemy/admin/pictures_helper_spec.rb +0 -28
- data/spec/helpers/alchemy/admin/tags_helper_spec.rb +0 -111
- data/spec/helpers/alchemy/base_helper_spec.rb +0 -44
- data/spec/helpers/alchemy/elements_block_helper_spec.rb +0 -135
- data/spec/helpers/alchemy/elements_helper_spec.rb +0 -326
- data/spec/helpers/alchemy/essences_helper_spec.rb +0 -85
- data/spec/helpers/alchemy/pages_helper_spec.rb +0 -499
- data/spec/helpers/alchemy/picture_url_helpers_spec.rb +0 -78
- data/spec/helpers/alchemy/url_helper_spec.rb +0 -200
- data/spec/javascripts/alchemy/dialog_spec.coffee +0 -82
- data/spec/javascripts/alchemy/link_overlay_spec.coffee +0 -25
- data/spec/javascripts/alchemy_integration_spec.coffee +0 -3
- data/spec/javascripts/fixtures/select.html +0 -3
- data/spec/javascripts/helpers/mock-ajax.js +0 -199
- data/spec/javascripts/helpers/test_responses/test_responses.js +0 -1
- data/spec/javascripts/support/jasmine.yml +0 -29
- data/spec/libraries/auth_accessors_spec.rb +0 -40
- data/spec/libraries/config_spec.rb +0 -111
- data/spec/libraries/controller_actions_spec.rb +0 -133
- data/spec/libraries/i18n_spec.rb +0 -37
- data/spec/libraries/kaminari/scoped_pagination_url_helper_spec.rb +0 -30
- data/spec/libraries/modules_spec.rb +0 -67
- data/spec/libraries/mount_point_spec.rb +0 -77
- data/spec/libraries/page_layout_spec.rb +0 -150
- data/spec/libraries/paths_spec.rb +0 -15
- data/spec/libraries/permissions_spec.rb +0 -260
- data/spec/libraries/resource_spec.rb +0 -344
- data/spec/libraries/resources_helper_spec.rb +0 -193
- data/spec/libraries/shell_spec.rb +0 -121
- data/spec/libraries/template_tracker_spec.rb +0 -85
- data/spec/libraries/tinymce_spec.rb +0 -111
- data/spec/libraries/userstamp_spec.rb +0 -10
- data/spec/mailers/alchemy/messages_spec.rb +0 -21
- data/spec/models/alchemy/attachment_spec.rb +0 -250
- data/spec/models/alchemy/cell_spec.rb +0 -101
- data/spec/models/alchemy/content_spec.rb +0 -513
- data/spec/models/alchemy/element_spec.rb +0 -862
- data/spec/models/alchemy/element_to_page_spec.rb +0 -13
- data/spec/models/alchemy/essence_boolean_spec.rb +0 -10
- data/spec/models/alchemy/essence_date_spec.rb +0 -28
- data/spec/models/alchemy/essence_file_spec.rb +0 -40
- data/spec/models/alchemy/essence_html_spec.rb +0 -18
- data/spec/models/alchemy/essence_link_spec.rb +0 -10
- data/spec/models/alchemy/essence_picture_spec.rb +0 -255
- data/spec/models/alchemy/essence_richtext_spec.rb +0 -23
- data/spec/models/alchemy/essence_select_spec.rb +0 -10
- data/spec/models/alchemy/essence_text_spec.rb +0 -110
- data/spec/models/alchemy/language_spec.rb +0 -243
- data/spec/models/alchemy/legacy_page_url_spec.rb +0 -21
- data/spec/models/alchemy/message_spec.rb +0 -55
- data/spec/models/alchemy/page_spec.rb +0 -2108
- data/spec/models/alchemy/picture_spec.rb +0 -418
- data/spec/models/alchemy/site_spec.rb +0 -168
- data/spec/models/alchemy/tag_spec.rb +0 -29
- data/spec/models/dummy_model_spec.rb +0 -10
- data/spec/requests/alchemy/admin/resources_requests_spec.rb +0 -26
- data/spec/requests/alchemy/admin/site_requests_spec.rb +0 -19
- data/spec/requests/alchemy/site_requests_spec.rb +0 -18
- data/spec/requests/alchemy/sitemap_spec.rb +0 -56
- data/spec/routing/api_routing_spec.rb +0 -150
- data/spec/routing/routing_spec.rb +0 -340
- data/spec/spec_helper.rb +0 -90
- data/spec/support/ci/install_phantomjs +0 -7
- data/spec/support/hint_examples.rb +0 -28
- data/spec/support/test_tweaks.rb +0 -31
- data/spec/support/transformation_examples.rb +0 -179
- data/spec/tasks/helpers_spec.rb +0 -217
- data/spec/views/admin/pictures/show_spec.rb +0 -43
- data/spec/views/essences/essence_boolean_editor_spec.rb +0 -32
- data/spec/views/essences/essence_boolean_view_spec.rb +0 -23
- data/spec/views/essences/essence_date_view_spec.rb +0 -38
- data/spec/views/essences/essence_file_editor_spec.rb +0 -59
- data/spec/views/essences/essence_file_view_spec.rb +0 -77
- data/spec/views/essences/essence_html_view_spec.rb +0 -22
- data/spec/views/essences/essence_link_view_spec.rb +0 -41
- data/spec/views/essences/essence_picture_editor_spec.rb +0 -80
- data/spec/views/essences/essence_picture_view_spec.rb +0 -128
- data/spec/views/essences/essence_richtext_view_spec.rb +0 -32
- data/spec/views/essences/essence_select_view_spec.rb +0 -11
- data/spec/views/essences/essence_text_view_spec.rb +0 -51
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Picture renderung security' do
|
4
|
-
let(:picture) { Alchemy::Picture.create(image_file: File.new(File.expand_path('../../fixtures/image.png', __FILE__))) }
|
5
|
-
|
6
|
-
# Prevent the signup view from being rendered.
|
7
|
-
before { allow(Alchemy.user_class).to receive(:count).and_return 1 }
|
8
|
-
|
9
|
-
context "passing no security token" do
|
10
|
-
it 'should return a bad request (400)' do
|
11
|
-
visit "/pictures/#{picture.id}/show/image.png"
|
12
|
-
expect(page.status_code).to eq(400)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "passing correct security token" do
|
17
|
-
before do
|
18
|
-
visit "/pictures/#{picture.id}/show/image.png?sh=#{picture.security_token}"
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should return image' do
|
22
|
-
expect(page.body).to match(/PNG/)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should return status ok (200)' do
|
26
|
-
expect(page.status_code).to eq(200)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Security." do
|
4
|
-
context "If user is not logged in" do
|
5
|
-
it "should see login form" do
|
6
|
-
visit '/admin/dashboard'
|
7
|
-
expect(current_path).to eq(Alchemy.login_path)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
context "If ssl is enforced" do
|
12
|
-
before do
|
13
|
-
allow_any_instance_of(Alchemy::BaseController)
|
14
|
-
.to receive(:ssl_required?)
|
15
|
-
.and_return(true)
|
16
|
-
authorize_user(:as_admin)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "redirects every request to https." do
|
20
|
-
visit '/admin/dashboard'
|
21
|
-
expect(current_url).to eq('https://www.example.com/admin/dashboard')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Translation integration" do
|
4
|
-
context "in admin backend" do
|
5
|
-
let(:dummy_user) { mock_model(Alchemy.user_class, alchemy_roles: %w(admin), language: 'de') }
|
6
|
-
|
7
|
-
before { authorize_user(dummy_user) }
|
8
|
-
|
9
|
-
it "should be possible to set the locale of the admin backend via params" do
|
10
|
-
visit admin_dashboard_path(locale: 'nl')
|
11
|
-
expect(page).to have_content('Welkom')
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should store the current locale in the session" do
|
15
|
-
visit admin_dashboard_path(locale: 'nl')
|
16
|
-
visit admin_dashboard_path
|
17
|
-
expect(page).to have_content('Welkom')
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should be possible to change the current locale in the session" do
|
21
|
-
visit admin_dashboard_path(locale: 'de')
|
22
|
-
expect(page).to have_content('Willkommen')
|
23
|
-
visit admin_dashboard_path(locale: 'en')
|
24
|
-
expect(page).to have_content('Welcome')
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'with unknown locale' do
|
28
|
-
it "it uses the users default language" do
|
29
|
-
visit admin_dashboard_path(locale: 'ko')
|
30
|
-
expect(page).to have_content('Willkommen')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "if no other parameter is given" do
|
35
|
-
it "should use the current users language setting" do
|
36
|
-
visit admin_dashboard_path
|
37
|
-
expect(page).to have_content('Willkommen')
|
38
|
-
end
|
39
|
-
|
40
|
-
context "if user has no preferred locale" do
|
41
|
-
let(:dummy_user) { mock_model(Alchemy.user_class, alchemy_roles: %w(admin), language: nil) }
|
42
|
-
|
43
|
-
it "should use the browsers language setting" do
|
44
|
-
page.driver.header 'ACCEPT-LANGUAGE', 'es-ES'
|
45
|
-
visit admin_dashboard_path
|
46
|
-
expect(page).to have_content('Bienvenido')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/spec/fixtures/500x500.png
DELETED
Binary file
|
data/spec/fixtures/80x60.png
DELETED
Binary file
|
data/spec/fixtures/animated.gif
DELETED
Binary file
|
Binary file
|
data/spec/fixtures/image.png
DELETED
Binary file
|
data/spec/fixtures/image2.PNG
DELETED
Binary file
|
data/spec/fixtures/image3.jpeg
DELETED
Binary file
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Alchemy::Admin::AttachmentsHelper do
|
4
|
-
describe '#mime_to_human' do
|
5
|
-
context 'when given mime type has no translation' do
|
6
|
-
it "should return the default" do
|
7
|
-
expect(helper.mime_to_human('something')).to eq('File')
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should return the translation for the given mime type" do
|
12
|
-
expect(helper.mime_to_human('text/plain')).to eq('Text-Document')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,280 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Alchemy
|
4
|
-
describe Admin::BaseHelper do
|
5
|
-
context "maximum amount of images option" do
|
6
|
-
subject { helper.max_image_count }
|
7
|
-
|
8
|
-
before { helper.instance_variable_set('@options', options) }
|
9
|
-
|
10
|
-
context "with max_images option set to emtpy string" do
|
11
|
-
let(:options) { {max_images: ""} }
|
12
|
-
|
13
|
-
it { is_expected.to eq(nil) }
|
14
|
-
end
|
15
|
-
|
16
|
-
context "with max_images option set to '1'" do
|
17
|
-
let(:options) { {max_images: "1"} }
|
18
|
-
|
19
|
-
it { is_expected.to eq(1) }
|
20
|
-
end
|
21
|
-
|
22
|
-
context "with maximum_amount_of_images option set to emtpy string" do
|
23
|
-
let(:options) { {maximum_amount_of_images: ""} }
|
24
|
-
|
25
|
-
it { is_expected.to eq(nil) }
|
26
|
-
end
|
27
|
-
|
28
|
-
context "with maximum_amount_of_images option set to '1'" do
|
29
|
-
let(:options) { {maximum_amount_of_images: "1"} }
|
30
|
-
|
31
|
-
it { is_expected.to eq(1) }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#merge_params" do
|
36
|
-
before do
|
37
|
-
allow(controller).to receive(:params).and_return({first: '1', second: '2'})
|
38
|
-
end
|
39
|
-
|
40
|
-
it "returns a hash that contains the current params and additional params given as attributes" do
|
41
|
-
expect(helper.merge_params(third: '3', fourth: '4')).to eq({first: '1', second: '2', third: '3', fourth: '4'})
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#merge_params_without" do
|
46
|
-
before do
|
47
|
-
allow(controller).to receive(:params).and_return({first: '1', second: '2'})
|
48
|
-
end
|
49
|
-
|
50
|
-
it "can delete a single param" do
|
51
|
-
expect(helper.merge_params_without(:second)).to eq({first: '1'})
|
52
|
-
end
|
53
|
-
|
54
|
-
it "can delete several params" do
|
55
|
-
expect(helper.merge_params_without([:first, :second])).to eq({})
|
56
|
-
end
|
57
|
-
|
58
|
-
it "can delete a param and add new params at the same time" do
|
59
|
-
expect(helper.merge_params_without([:first], {third: '3'})).to eq({second: '2', third: '3'})
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should not change params" do
|
63
|
-
helper.merge_params_without([:first])
|
64
|
-
expect(controller.params).to eq({first: '1', second: '2'})
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "#merge_params_only" do
|
69
|
-
before do
|
70
|
-
allow(controller).to receive(:params).and_return({first: '1', second: '2', third: '3'})
|
71
|
-
end
|
72
|
-
|
73
|
-
it "can keep a single param" do
|
74
|
-
expect(helper.merge_params_only(:second)).to eq({second: '2'})
|
75
|
-
end
|
76
|
-
|
77
|
-
it "can keep several params" do
|
78
|
-
expect(helper.merge_params_only([:first, :second])).to eq({first: '1', second: '2'})
|
79
|
-
end
|
80
|
-
|
81
|
-
it "can keep a param and add new params at the same time" do
|
82
|
-
expect(helper.merge_params_only([:first], {third: '3'})).to eq({first: '1', third: '3'})
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should not change params" do
|
86
|
-
helper.merge_params_only([:first])
|
87
|
-
expect(controller.params).to eq({first: '1', second: '2', third: '3'})
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '#toolbar_button' do
|
92
|
-
context "with permission" do
|
93
|
-
before { allow(helper).to receive(:can?).and_return(true) }
|
94
|
-
|
95
|
-
it "renders a toolbar button" do
|
96
|
-
expect(helper.toolbar_button(
|
97
|
-
url: admin_dashboard_path
|
98
|
-
)).to match /<div.+class="button_with_label/
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context "without permission" do
|
103
|
-
before { allow(helper).to receive(:can?).and_return(false) }
|
104
|
-
|
105
|
-
it "returns empty string" do
|
106
|
-
expect(
|
107
|
-
helper.toolbar_button(url: admin_dashboard_path)
|
108
|
-
).to be_empty
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context "with disabled permission check" do
|
113
|
-
before { allow(helper).to receive(:can?).and_return(false) }
|
114
|
-
|
115
|
-
it "returns the button" do
|
116
|
-
expect(
|
117
|
-
helper.toolbar_button(
|
118
|
-
url: admin_dashboard_path,
|
119
|
-
skip_permission_check: true
|
120
|
-
)
|
121
|
-
).to match /<div.+class="button_with_label/
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
context "with empty permission option" do
|
126
|
-
before { allow(helper).to receive(:can?).and_return(true) }
|
127
|
-
|
128
|
-
it "returns reads the permission from url" do
|
129
|
-
expect(helper).to receive(:permission_array_from_url)
|
130
|
-
expect(
|
131
|
-
helper.toolbar_button(
|
132
|
-
url: admin_dashboard_path,
|
133
|
-
if_permitted_to: ''
|
134
|
-
)
|
135
|
-
).not_to be_empty
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
context "with overlay option set to false" do
|
140
|
-
before do
|
141
|
-
allow(helper).to receive(:can?).and_return(true)
|
142
|
-
expect(helper).to receive(:permission_array_from_url)
|
143
|
-
end
|
144
|
-
|
145
|
-
it "renders a normal link" do
|
146
|
-
button = helper.toolbar_button(
|
147
|
-
url: admin_dashboard_path,
|
148
|
-
overlay: false
|
149
|
-
)
|
150
|
-
expect(button).to match /<a.+href="#{admin_dashboard_path}"/
|
151
|
-
expect(button).not_to match /data-alchemy-overlay/
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
describe "#translations_for_select" do
|
157
|
-
it "should return an Array of Arrays with available locales" do
|
158
|
-
allow(Alchemy::I18n).to receive(:available_locales).and_return([:de, :en, :cz, :it])
|
159
|
-
expect(helper.translations_for_select.size).to eq(4)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe '#clipboard_select_tag_options' do
|
164
|
-
let(:page) { build_stubbed(:alchemy_page) }
|
165
|
-
|
166
|
-
before { helper.instance_variable_set('@page', page) }
|
167
|
-
|
168
|
-
context 'with element items' do
|
169
|
-
let(:element) { build_stubbed(:alchemy_element) }
|
170
|
-
let(:clipboard_items) { [element] }
|
171
|
-
|
172
|
-
it "should include select options with the display name and preview text" do
|
173
|
-
allow(element).to receive(:display_name_with_preview_text).and_return('Name with Preview text')
|
174
|
-
expect(helper.clipboard_select_tag_options(clipboard_items)).to have_selector('option', text: 'Name with Preview text')
|
175
|
-
end
|
176
|
-
|
177
|
-
context "when @page can have cells" do
|
178
|
-
before { allow(page).to receive(:can_have_cells?).and_return(true) }
|
179
|
-
|
180
|
-
it "should group the elements in the clipboard by cell" do
|
181
|
-
expect(helper).to receive(:grouped_elements_for_select).and_return({})
|
182
|
-
helper.clipboard_select_tag_options(clipboard_items)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
context 'with page items' do
|
188
|
-
let(:page_in_clipboard) { build_stubbed(:alchemy_page, name: 'Page name') }
|
189
|
-
let(:clipboard_items) { [page_in_clipboard] }
|
190
|
-
|
191
|
-
it "should include select options with page names" do
|
192
|
-
expect(helper.clipboard_select_tag_options(clipboard_items)).to have_selector('option', text: 'Page name')
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
describe '#button_with_confirm' do
|
198
|
-
subject { button_with_confirm }
|
199
|
-
|
200
|
-
it "renders a button tag with a data attribute for confirm dialog" do
|
201
|
-
is_expected.to have_selector('button[data-alchemy-confirm]')
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe '#delete_button' do
|
206
|
-
subject { delete_button('/admin/pages') }
|
207
|
-
|
208
|
-
it "renders a button tag" do
|
209
|
-
is_expected.to have_selector('button')
|
210
|
-
end
|
211
|
-
|
212
|
-
it "returns a form tag with method=delete" do
|
213
|
-
is_expected.to have_selector('form input[name="_method"][value="delete"]')
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
describe '#alchemy_datepicker' do
|
218
|
-
subject { alchemy_datepicker(essence, :date, {value: now}) }
|
219
|
-
|
220
|
-
let(:essence) { EssenceDate.new }
|
221
|
-
let(:now) { Time.current }
|
222
|
-
|
223
|
-
it "renders a date field" do
|
224
|
-
is_expected.to have_selector("input[type='date']")
|
225
|
-
end
|
226
|
-
|
227
|
-
it "sets default date as value" do
|
228
|
-
is_expected.to have_selector("input[value='#{::I18n.l(now, format: :datepicker)}']")
|
229
|
-
end
|
230
|
-
|
231
|
-
context 'with date stored on object' do
|
232
|
-
let(:date) { Time.parse('1976-10-07 00:00 Z') }
|
233
|
-
let(:essence) { EssenceDate.new(date: date) }
|
234
|
-
|
235
|
-
it "sets this date as value" do
|
236
|
-
is_expected.to have_selector("input[value='#{::I18n.l(date, format: :datepicker)}']")
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
describe '#current_alchemy_user_name' do
|
242
|
-
subject { helper.current_alchemy_user_name }
|
243
|
-
|
244
|
-
before { expect(helper).to receive(:current_alchemy_user).and_return(user) }
|
245
|
-
|
246
|
-
context 'with a user having a `alchemy_display_name` method' do
|
247
|
-
let(:user) { double('User', alchemy_display_name: 'Peter Schroeder') }
|
248
|
-
|
249
|
-
it "Returns a span showing the name of the currently logged in user." do
|
250
|
-
is_expected.to have_content("#{Alchemy.t('Logged in as')} Peter Schroeder")
|
251
|
-
is_expected.to have_selector("span.current-user-name")
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
context 'with a user not having a `alchemy_display_name` method' do
|
256
|
-
let(:user) { double('User', name: 'Peter Schroeder') }
|
257
|
-
|
258
|
-
it { is_expected.to be_nil }
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
describe '#link_url_regexp' do
|
263
|
-
subject { helper.link_url_regexp }
|
264
|
-
|
265
|
-
it "returns the regular expression for external link urls" do
|
266
|
-
expect(subject).to be_a(Regexp)
|
267
|
-
end
|
268
|
-
|
269
|
-
context 'if the expression from config is nil' do
|
270
|
-
before do
|
271
|
-
expect(Alchemy::Config).to receive(:get).and_return({link_url: nil})
|
272
|
-
end
|
273
|
-
|
274
|
-
it "returns the default expression" do
|
275
|
-
expect(subject).to_not be_nil
|
276
|
-
end
|
277
|
-
end
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Alchemy::Admin::ContentsHelper do
|
4
|
-
let(:element) { build_stubbed(:alchemy_element, name: 'article') }
|
5
|
-
let(:content) { mock_model('Content', essence_partial_name: 'essence_text') }
|
6
|
-
|
7
|
-
describe 'render_content_name' do
|
8
|
-
let(:content) do
|
9
|
-
mock_model 'Content',
|
10
|
-
name: 'intro',
|
11
|
-
definition: {name: 'intro', type: 'EssenceText'},
|
12
|
-
name_for_label: 'Intro',
|
13
|
-
has_validations?: false
|
14
|
-
end
|
15
|
-
subject { helper.render_content_name(content) }
|
16
|
-
|
17
|
-
it "returns the content name" do
|
18
|
-
is_expected.to eq("Intro")
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'if content is nil' do
|
22
|
-
let(:content) { nil }
|
23
|
-
|
24
|
-
it "returns nil" do
|
25
|
-
is_expected.to be_nil
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with missing definition' do
|
30
|
-
before { expect(content).to receive(:definition).and_return({}) }
|
31
|
-
|
32
|
-
it "renders a warning" do
|
33
|
-
is_expected.to have_selector('span.warning')
|
34
|
-
is_expected.to have_content('Intro')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'with validations' do
|
39
|
-
before { expect(content).to receive(:has_validations?).and_return(true) }
|
40
|
-
|
41
|
-
it "show a validation indicator" do
|
42
|
-
is_expected.to have_selector('.validation_indicator')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|