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,76 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module Alchemy
|
4
|
-
describe Admin::EssenceFilesController do
|
5
|
-
before do
|
6
|
-
authorize_user(:as_admin)
|
7
|
-
end
|
8
|
-
|
9
|
-
let(:essence_file) { mock_model('EssenceFile', :attachment= => nil, content: content) }
|
10
|
-
let(:content) { mock_model('Content') }
|
11
|
-
let(:attachment) { mock_model('Attachment') }
|
12
|
-
|
13
|
-
describe '#edit' do
|
14
|
-
before do
|
15
|
-
expect(EssenceFile).to receive(:find)
|
16
|
-
.with(essence_file.id.to_s)
|
17
|
-
.and_return(essence_file)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "assigns @essence_file with the EssenceFile found by id" do
|
21
|
-
alchemy_get :edit, id: essence_file.id
|
22
|
-
expect(assigns(:essence_file)).to eq(essence_file)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should assign @content with essence_file's content" do
|
26
|
-
alchemy_get :edit, id: essence_file.id
|
27
|
-
expect(assigns(:content)).to eq(content)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#update' do
|
32
|
-
let(:essence_file) { create(:alchemy_essence_file) }
|
33
|
-
|
34
|
-
before do
|
35
|
-
expect(EssenceFile).to receive(:find).and_return(essence_file)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should update the attributes of essence_file" do
|
39
|
-
alchemy_xhr :put, :update, id: essence_file.id, essence_file: {
|
40
|
-
title: 'new title',
|
41
|
-
css_class: 'left',
|
42
|
-
link_text: 'Download this file'
|
43
|
-
}
|
44
|
-
expect(essence_file.title).to eq 'new title'
|
45
|
-
expect(essence_file.css_class).to eq 'left'
|
46
|
-
expect(essence_file.link_text).to eq 'Download this file'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '#assign' do
|
51
|
-
let(:content) { create(:alchemy_content) }
|
52
|
-
|
53
|
-
before do
|
54
|
-
expect(Content).to receive(:find_by).and_return(content)
|
55
|
-
expect(Attachment).to receive(:find_by).and_return(attachment)
|
56
|
-
allow(content).to receive(:essence).and_return(essence_file)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should assign @attachment with the Attachment found by attachment_id" do
|
60
|
-
alchemy_xhr :put, :assign, content_id: content.id, attachment_id: attachment.id
|
61
|
-
expect(assigns(:attachment)).to eq(attachment)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should assign @content.essence.attachment with the attachment found by id" do
|
65
|
-
expect(content.essence).to receive(:attachment=).with(attachment)
|
66
|
-
alchemy_xhr :put, :assign, content_id: content.id, attachment_id: attachment.id
|
67
|
-
end
|
68
|
-
|
69
|
-
it "updates the @content.updated_at column" do
|
70
|
-
expect {
|
71
|
-
alchemy_xhr :put, :assign, content_id: content.id, attachment_id: attachment.id
|
72
|
-
}.to change(content, :updated_at)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,202 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Alchemy
|
4
|
-
describe Admin::EssencePicturesController do
|
5
|
-
before { authorize_user(:as_admin) }
|
6
|
-
|
7
|
-
let(:essence) { EssencePicture.new }
|
8
|
-
let(:content) { Content.new }
|
9
|
-
let(:picture) { Picture.new }
|
10
|
-
|
11
|
-
describe '#edit' do
|
12
|
-
before do
|
13
|
-
expect(EssencePicture).to receive(:find).and_return(essence)
|
14
|
-
expect(Content).to receive(:find).and_return(content)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should assign @essence_picture and @content instance variables' do
|
18
|
-
alchemy_post :edit, id: 1, content_id: 1
|
19
|
-
expect(assigns(:essence_picture)).to be_a(EssencePicture)
|
20
|
-
expect(assigns(:content)).to be_a(Content)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#crop' do
|
25
|
-
before do
|
26
|
-
expect(EssencePicture).to receive(:find).and_return(essence)
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with no picture assigned' do
|
30
|
-
before do
|
31
|
-
expect(essence).to receive(:picture).at_least(:once).and_return(nil)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "renders error message" do
|
35
|
-
alchemy_get :crop, id: 1
|
36
|
-
expect(assigns(:no_image_notice)).to eq(Alchemy.t(:no_image_for_cropper_found))
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'with picture assigned' do
|
41
|
-
let(:default_mask) do
|
42
|
-
{
|
43
|
-
x1: 0,
|
44
|
-
y1: 0,
|
45
|
-
x2: 300,
|
46
|
-
y2: 250
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
before do
|
51
|
-
picture.image_file_width = 300
|
52
|
-
picture.image_file_height = 250
|
53
|
-
expect(essence).to receive(:picture).at_least(:once).and_return(picture)
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'with no render_size present in essence' do
|
57
|
-
before do
|
58
|
-
expect(essence).to receive(:render_size).at_least(:once).and_return(nil)
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'with sizes in params' do
|
62
|
-
it "sets sizes to given values" do
|
63
|
-
alchemy_get :crop, id: 1, options: {image_size: '300x250'}
|
64
|
-
expect(assigns(:min_size)).to eq({ width: 300, height: 250 })
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'with no sizes in params' do
|
69
|
-
it "sets sizes to zero" do
|
70
|
-
alchemy_get :crop, id: 1
|
71
|
-
expect(assigns(:min_size)).to eq({ width: 0, height: 0 })
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'with render_size present in essence' do
|
77
|
-
it "sets sizes from these values" do
|
78
|
-
expect(essence).to receive(:render_size).at_least(:once).and_return('30x25')
|
79
|
-
|
80
|
-
alchemy_get :crop, id: 1
|
81
|
-
expect(assigns(:min_size)).to eq({ width: 30, height: 25 })
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'when width or height is not fixed' do
|
85
|
-
it 'infers the height from the image file preserving the aspect ratio' do
|
86
|
-
expect(essence).to receive(:render_size).at_least(:once).and_return('30x')
|
87
|
-
|
88
|
-
alchemy_get :crop, id: 1
|
89
|
-
expect(assigns(:min_size)).to eq({ width: 30, height: 0})
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'does not infer the height from the image file preserving the aspect ratio' do
|
93
|
-
expect(essence).to receive(:render_size).at_least(:once).and_return('x25')
|
94
|
-
|
95
|
-
alchemy_get :crop, id: 1, options: { fixed_ratio: "2"}
|
96
|
-
expect(assigns(:min_size)).to eq({ width: 50, height: 25 })
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'when width or height is not fixed and an aspect ratio is given' do
|
101
|
-
it 'width is given, it infers the height from width and ratio' do
|
102
|
-
expect(essence).to receive(:render_size).at_least(:once).and_return('30x')
|
103
|
-
|
104
|
-
alchemy_get :crop, id: 1, options: { fixed_ratio: "0.5" }
|
105
|
-
expect(assigns(:min_size)).to eq({ width: 30, height: 60 })
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'infers the height from the image file preserving the aspect ratio' do
|
109
|
-
expect(essence).to receive(:render_size).at_least(:once).and_return('x25')
|
110
|
-
|
111
|
-
alchemy_get :crop, id: 1
|
112
|
-
expect(assigns(:min_size)).to eq({ width: 0, height: 25})
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'no crop sizes present in essence' do
|
118
|
-
before do
|
119
|
-
expect(essence).to receive(:crop_from).and_return(nil)
|
120
|
-
allow(essence).to receive(:crop_size).and_return(nil)
|
121
|
-
end
|
122
|
-
|
123
|
-
it "assigns default mask boxes" do
|
124
|
-
alchemy_get :crop, id: 1
|
125
|
-
expect(assigns(:initial_box)).to eq(default_mask)
|
126
|
-
expect(assigns(:default_box)).to eq(default_mask)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
context 'crop sizes present in essence' do
|
131
|
-
let(:mask) { {'x1' => '0', 'y1' => '0', 'x2' => '120', 'y2' => '160'} }
|
132
|
-
|
133
|
-
before do
|
134
|
-
allow(essence).to receive(:crop_from).and_return('0x0')
|
135
|
-
allow(essence).to receive(:crop_size).and_return('120x160')
|
136
|
-
end
|
137
|
-
|
138
|
-
it "assigns cropping boxes" do
|
139
|
-
expect(essence).to receive(:cropping_mask).and_return(mask)
|
140
|
-
alchemy_get :crop, id: 1
|
141
|
-
expect(assigns(:initial_box)).to eq(mask)
|
142
|
-
expect(assigns(:default_box)).to eq(default_mask)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
context 'with fixed_ratio set to false' do
|
147
|
-
it "sets ratio to false" do
|
148
|
-
alchemy_get :crop, id: 1, options: {fixed_ratio: false}
|
149
|
-
expect(assigns(:ratio)).to eq(false)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
context 'with no fixed_ratio set in params' do
|
154
|
-
it "sets a fixed ratio from sizes" do
|
155
|
-
alchemy_get :crop, id: 1, options: {image_size: '80x60'}
|
156
|
-
expect(assigns(:ratio)).to eq(80.0 / 60.0)
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe '#update' do
|
163
|
-
before do
|
164
|
-
expect(EssencePicture).to receive(:find).and_return(essence)
|
165
|
-
expect(Content).to receive(:find).and_return(content)
|
166
|
-
end
|
167
|
-
|
168
|
-
let(:attributes) { {render_size: '1x1', alt_tag: 'Alt Tag', caption: 'Caption', css_class: 'CSS Class', title: 'Title'} }
|
169
|
-
|
170
|
-
it "updates the essence attributes" do
|
171
|
-
expect(essence).to receive(:update).and_return(true)
|
172
|
-
alchemy_xhr :put, :update, id: 1, essence_picture: attributes
|
173
|
-
end
|
174
|
-
|
175
|
-
it "saves the cropping mask" do
|
176
|
-
expect(essence).to receive(:update).and_return(true)
|
177
|
-
alchemy_xhr :put, :update, id: 1, essence_picture: {render_size: '1x1', crop_from: '0x0', crop_size: '100x100'}
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
describe '#assign' do
|
182
|
-
let(:content) { create(:alchemy_content) }
|
183
|
-
|
184
|
-
before do
|
185
|
-
expect(Content).to receive(:find).and_return(content)
|
186
|
-
expect(content).to receive(:essence).at_least(:once).and_return(essence)
|
187
|
-
expect(Picture).to receive(:find_by).and_return(picture)
|
188
|
-
end
|
189
|
-
|
190
|
-
it "should assign a Picture" do
|
191
|
-
alchemy_xhr :put, :assign, content_id: '1', picture_id: '1'
|
192
|
-
expect(assigns(:content).essence.picture).to eq(picture)
|
193
|
-
end
|
194
|
-
|
195
|
-
it "updates the content timestamp" do
|
196
|
-
expect {
|
197
|
-
alchemy_xhr :put, :assign, content_id: '1', picture_id: '1'
|
198
|
-
}.to change(content, :updated_at)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Alchemy::Admin::LanguagesController do
|
4
|
-
before do
|
5
|
-
authorize_user(:as_admin)
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#new" do
|
9
|
-
context "when default_language.page_layout is set" do
|
10
|
-
before do
|
11
|
-
allow(Alchemy::Config).to receive(:get) do |arg|
|
12
|
-
if arg == :default_language
|
13
|
-
{'page_layout' => "new_standard"}
|
14
|
-
else
|
15
|
-
Alchemy::Config.show[arg.to_s]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "uses it as page_layout-default for the new language" do
|
21
|
-
alchemy_get :new
|
22
|
-
expect(assigns(:language).page_layout).to eq("new_standard")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when default_language is not configured" do
|
27
|
-
before do
|
28
|
-
allow(Alchemy::Config).to receive(:get) do |arg|
|
29
|
-
if arg == :default_language
|
30
|
-
nil
|
31
|
-
else
|
32
|
-
Alchemy::Config.show[arg.to_s]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
it "falls back to default database value." do
|
38
|
-
alchemy_get :new
|
39
|
-
expect(assigns(:language).page_layout).to eq("intro")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "when default language page_layout is not configured" do
|
44
|
-
before do
|
45
|
-
allow(Alchemy::Config).to receive(:get) do |arg|
|
46
|
-
if arg == :default_language
|
47
|
-
{}
|
48
|
-
else
|
49
|
-
Alchemy::Config.show[arg.to_s]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
it "falls back to default database value." do
|
55
|
-
alchemy_get :new
|
56
|
-
expect(assigns(:language).page_layout).to eq("intro")
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "#index" do
|
62
|
-
context "editor users" do
|
63
|
-
before do
|
64
|
-
authorize_user(:as_editor)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should be able to index language" do
|
68
|
-
alchemy_get :index
|
69
|
-
expect(response).to render_template(:index)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Alchemy
|
4
|
-
describe Admin::LayoutpagesController do
|
5
|
-
before(:each) do
|
6
|
-
authorize_user(:as_admin)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "#index" do
|
10
|
-
it "should assign @layout_root" do
|
11
|
-
alchemy_get :index
|
12
|
-
expect(assigns(:layout_root)).to be_a(Page)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should assign @languages" do
|
16
|
-
alchemy_get :index
|
17
|
-
expect(assigns(:languages).first).to be_a(Language)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,639 +0,0 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
module Alchemy
|
5
|
-
describe Admin::PagesController do
|
6
|
-
context 'a guest' do
|
7
|
-
it 'can not access page tree' do
|
8
|
-
alchemy_get :index
|
9
|
-
expect(request).to redirect_to(Alchemy.login_path)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'a member' do
|
14
|
-
before { authorize_user(build(:alchemy_dummy_user)) }
|
15
|
-
|
16
|
-
it 'can not access page tree' do
|
17
|
-
alchemy_get :index
|
18
|
-
expect(request).to redirect_to(root_path)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'with logged in editor user' do
|
23
|
-
let(:user) { build(:alchemy_dummy_user, :as_editor) }
|
24
|
-
|
25
|
-
before { authorize_user(user) }
|
26
|
-
|
27
|
-
describe '#index' do
|
28
|
-
let(:language) { build_stubbed(:alchemy_language) }
|
29
|
-
let(:language_root) { build_stubbed(:alchemy_page, :language_root) }
|
30
|
-
|
31
|
-
context 'with existing language root page' do
|
32
|
-
before do
|
33
|
-
expect(Language).to receive(:current_root_page).and_return(language_root)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "assigns @page_root variable" do
|
37
|
-
alchemy_get :index
|
38
|
-
expect(assigns(:page_root)).to be(language_root)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'without language root page' do
|
43
|
-
before do
|
44
|
-
expect(Language).to receive(:current_root_page).and_return(nil)
|
45
|
-
expect(Language).to receive(:find_by).and_return(language)
|
46
|
-
expect(Language).to receive(:all).and_return([language])
|
47
|
-
expect(Language).to receive(:with_root_page).and_return([language])
|
48
|
-
end
|
49
|
-
|
50
|
-
it "it assigns current language" do
|
51
|
-
alchemy_get :index
|
52
|
-
expect(assigns(:language)).to be(language)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '#tree' do
|
58
|
-
let(:page_1) { create(:alchemy_page, visible: true, name: 'one') }
|
59
|
-
let(:page_2) { create(:alchemy_page, visible: true, name: 'two', parent_id: page_1.id) }
|
60
|
-
let(:page_3) { create(:alchemy_page, visible: true, name: 'three', parent_id: page_2.id) }
|
61
|
-
let(:pages) { [page_1, page_2, page_3] }
|
62
|
-
|
63
|
-
before do
|
64
|
-
pages
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'returns a tree as JSON' do
|
68
|
-
alchemy_get :tree, id: page_1.id, full: 'true'
|
69
|
-
|
70
|
-
expect(response.status).to eq(200)
|
71
|
-
expect(response.content_type).to eq('application/json')
|
72
|
-
|
73
|
-
result = JSON.parse(response.body)
|
74
|
-
|
75
|
-
expect(result).to have_key('pages')
|
76
|
-
expect(result['pages'].count).to eq(1)
|
77
|
-
|
78
|
-
page = result['pages'].first
|
79
|
-
|
80
|
-
expect(page).to have_key('id')
|
81
|
-
expect(page['id']).to eq(page_1.id)
|
82
|
-
expect(page).to have_key('name')
|
83
|
-
expect(page['name']).to eq(page_1.name)
|
84
|
-
expect(page).to have_key('children')
|
85
|
-
expect(page['children'].count).to eq(1)
|
86
|
-
|
87
|
-
page = page['children'].first
|
88
|
-
|
89
|
-
expect(page).to have_key('id')
|
90
|
-
expect(page['id']).to eq(page_2.id)
|
91
|
-
expect(page).to have_key('name')
|
92
|
-
expect(page['name']).to eq(page_2.name)
|
93
|
-
expect(page).to have_key('children')
|
94
|
-
expect(page['children'].count).to eq(1)
|
95
|
-
|
96
|
-
page = page['children'].first
|
97
|
-
|
98
|
-
expect(page).to have_key('id')
|
99
|
-
expect(page['id']).to eq(page_3.id)
|
100
|
-
expect(page).to have_key('name')
|
101
|
-
expect(page['name']).to eq(page_3.name)
|
102
|
-
expect(page).to have_key('children')
|
103
|
-
expect(page['children'].count).to eq(0)
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'does not return a branch that is folded' do
|
107
|
-
alchemy_xhr :post, :fold, id: page_2.id
|
108
|
-
alchemy_get :tree, id: page_1.id, full: 'false'
|
109
|
-
|
110
|
-
expect(response.status).to eq(200)
|
111
|
-
expect(response.content_type).to eq('application/json')
|
112
|
-
|
113
|
-
result = JSON.parse(response.body)
|
114
|
-
page = result['pages'].first['children'].first
|
115
|
-
|
116
|
-
expect(page['children'].count).to eq(0)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe "#flush" do
|
121
|
-
let(:content_page_1) { create(:alchemy_page, :public, name: "content page 1", published_at: Time.current - 5.days) }
|
122
|
-
let(:content_page_2) { create(:alchemy_page, :public, name: "content page 2", published_at: Time.current - 8.days) }
|
123
|
-
let(:layout_page_1) { create(:alchemy_page, layoutpage: true, name: "layout_page 1", published_at: Time.current - 5.days) }
|
124
|
-
let(:layout_page_2) { create(:alchemy_page, layoutpage: true, name: "layout_page 2", published_at: Time.current - 8.days) }
|
125
|
-
let(:content_pages) { [content_page_1, content_page_2] }
|
126
|
-
let(:layout_pages) { [layout_page_1, layout_page_2] }
|
127
|
-
|
128
|
-
before do
|
129
|
-
content_pages
|
130
|
-
layout_pages
|
131
|
-
end
|
132
|
-
|
133
|
-
it "should update the published_at field of content pages" do
|
134
|
-
travel_to(Time.current) do
|
135
|
-
alchemy_xhr :post, :flush
|
136
|
-
content_pages.map(&:reload) # Reloading because published_at was directly updated in the database.
|
137
|
-
content_pages.each do |page|
|
138
|
-
expect(page.published_at).to eq(Time.current)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should update the published_at field of layout pages" do
|
144
|
-
travel_to(Time.current) do
|
145
|
-
alchemy_xhr :post, :flush
|
146
|
-
layout_pages.map(&:reload) # Reloading because published_at was directly updated in the database.
|
147
|
-
layout_pages.each do |page|
|
148
|
-
expect(page.published_at).to eq(Time.current)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe '#new' do
|
155
|
-
context "pages in clipboard" do
|
156
|
-
let(:clipboard) { session[:alchemy_clipboard] = {} }
|
157
|
-
let(:page) { mock_model(Alchemy::Page, name: 'Foobar') }
|
158
|
-
|
159
|
-
before { clipboard['pages'] = [{'id' => page.id.to_s, 'action' => 'copy'}] }
|
160
|
-
|
161
|
-
it "should load all pages from clipboard" do
|
162
|
-
alchemy_xhr :get, :new, {page_id: page.id}
|
163
|
-
expect(assigns(:clipboard_items)).to be_kind_of(Array)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe '#show' do
|
169
|
-
let(:language) { build_stubbed(:alchemy_language, locale: 'nl') }
|
170
|
-
let(:page) { build_stubbed(:alchemy_page, language: language) }
|
171
|
-
|
172
|
-
before do
|
173
|
-
expect(Page).to receive(:find).with(page.id.to_s).and_return(page)
|
174
|
-
allow(Page).to receive(:language_root_for).and_return(mock_model(Alchemy::Page))
|
175
|
-
end
|
176
|
-
|
177
|
-
it "should assign @preview_mode with true" do
|
178
|
-
alchemy_get :show, id: page.id
|
179
|
-
expect(assigns(:preview_mode)).to eq(true)
|
180
|
-
end
|
181
|
-
|
182
|
-
it "should store page as current preview" do
|
183
|
-
Page.current_preview = nil
|
184
|
-
alchemy_get :show, id: page.id
|
185
|
-
expect(Page.current_preview).to eq(page)
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should set the I18n locale to the pages language code" do
|
189
|
-
alchemy_get :show, id: page.id
|
190
|
-
expect(::I18n.locale).to eq(:nl)
|
191
|
-
end
|
192
|
-
|
193
|
-
it "renders the application layout" do
|
194
|
-
alchemy_get :show, id: page.id
|
195
|
-
expect(response).to render_template(layout: 'application')
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
describe '#order' do
|
200
|
-
let(:page_1) { create(:alchemy_page, visible: true) }
|
201
|
-
let(:page_2) { create(:alchemy_page, visible: true) }
|
202
|
-
let(:page_3) { create(:alchemy_page, visible: true) }
|
203
|
-
let(:page_item_1) { {id: page_1.id, slug: page_1.slug, restricted: false, external: page_1.redirects_to_external?, visible: page_1.visible?, children: [page_item_2]} }
|
204
|
-
let(:page_item_2) { {id: page_2.id, slug: page_2.slug, restricted: false, external: page_2.redirects_to_external?, visible: page_2.visible?, children: [page_item_3]} }
|
205
|
-
let(:page_item_3) { {id: page_3.id, slug: page_3.slug, restricted: false, external: page_3.redirects_to_external?, visible: page_3.visible? } }
|
206
|
-
let(:set_of_pages) { [page_item_1] }
|
207
|
-
|
208
|
-
it "stores the new order" do
|
209
|
-
alchemy_xhr :post, :order, set: set_of_pages.to_json
|
210
|
-
page_1.reload
|
211
|
-
expect(page_1.descendants).to eq([page_2, page_3])
|
212
|
-
end
|
213
|
-
|
214
|
-
context 'with url nesting enabled' do
|
215
|
-
before do
|
216
|
-
expect(Alchemy::Config).to receive(:get).with(:url_nesting).at_least(:once).and_return(true)
|
217
|
-
end
|
218
|
-
|
219
|
-
it "updates the pages urlnames" do
|
220
|
-
alchemy_xhr :post, :order, set: set_of_pages.to_json
|
221
|
-
[page_1, page_2, page_3].map(&:reload)
|
222
|
-
expect(page_1.urlname).to eq(page_1.slug.to_s)
|
223
|
-
expect(page_2.urlname).to eq("#{page_1.slug}/#{page_2.slug}")
|
224
|
-
expect(page_3.urlname).to eq("#{page_1.slug}/#{page_2.slug}/#{page_3.slug}")
|
225
|
-
end
|
226
|
-
|
227
|
-
context 'with invisible page in tree' do
|
228
|
-
let(:page_item_2) do
|
229
|
-
{
|
230
|
-
id: page_2.id,
|
231
|
-
slug: page_2.slug,
|
232
|
-
children: [page_item_3],
|
233
|
-
visible: false
|
234
|
-
}
|
235
|
-
end
|
236
|
-
|
237
|
-
it "does not use this pages slug in urlnames of descendants" do
|
238
|
-
alchemy_xhr :post, :order, set: set_of_pages.to_json
|
239
|
-
[page_1, page_2, page_3].map(&:reload)
|
240
|
-
expect(page_1.urlname).to eq(page_1.slug.to_s)
|
241
|
-
expect(page_2.urlname).to eq("#{page_1.slug}/#{page_2.slug}")
|
242
|
-
expect(page_3.urlname).to eq("#{page_1.slug}/#{page_3.slug}")
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
context 'with external page in tree' do
|
247
|
-
let(:page_item_2) do
|
248
|
-
{
|
249
|
-
id: page_2.id,
|
250
|
-
slug: page_2.slug,
|
251
|
-
children: [page_item_3],
|
252
|
-
external: true
|
253
|
-
}
|
254
|
-
end
|
255
|
-
|
256
|
-
it "does not use this pages slug in urlnames of descendants" do
|
257
|
-
alchemy_xhr :post, :order, set: set_of_pages.to_json
|
258
|
-
[page_1, page_2, page_3].map(&:reload)
|
259
|
-
expect(page_3.urlname).to eq("#{page_1.slug}/#{page_3.slug}")
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
context 'with restricted page in tree' do
|
264
|
-
let(:page_2) { create(:alchemy_page, restricted: true) }
|
265
|
-
let(:page_item_2) do
|
266
|
-
{
|
267
|
-
id: page_2.id,
|
268
|
-
slug: page_2.slug,
|
269
|
-
children: [page_item_3],
|
270
|
-
restricted: true
|
271
|
-
}
|
272
|
-
end
|
273
|
-
|
274
|
-
it "updates restricted status of descendants" do
|
275
|
-
alchemy_xhr :post, :order, set: set_of_pages.to_json
|
276
|
-
page_3.reload
|
277
|
-
expect(page_3.restricted).to be_truthy
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
context 'with page having number as slug' do
|
282
|
-
let(:page_item_2) do
|
283
|
-
{
|
284
|
-
id: page_2.id,
|
285
|
-
slug: 42,
|
286
|
-
children: [page_item_3]
|
287
|
-
}
|
288
|
-
end
|
289
|
-
|
290
|
-
it "does not raise error" do
|
291
|
-
expect {
|
292
|
-
alchemy_xhr :post, :order, set: set_of_pages.to_json
|
293
|
-
}.not_to raise_error
|
294
|
-
end
|
295
|
-
|
296
|
-
it "still generates the correct urlname on page_3" do
|
297
|
-
alchemy_xhr :post, :order, set: set_of_pages.to_json
|
298
|
-
[page_1, page_2, page_3].map(&:reload)
|
299
|
-
expect(page_3.urlname).to eq("#{page_1.slug}/#{page_2.slug}/#{page_3.slug}")
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
it "creates legacy urls" do
|
304
|
-
alchemy_xhr :post, :order, set: set_of_pages.to_json
|
305
|
-
[page_2, page_3].map(&:reload)
|
306
|
-
expect(page_2.legacy_urls.size).to eq(1)
|
307
|
-
expect(page_3.legacy_urls.size).to eq(1)
|
308
|
-
end
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
describe "#configure" do
|
313
|
-
render_views
|
314
|
-
|
315
|
-
context "with page having nested urlname" do
|
316
|
-
let(:page) { create(:alchemy_page, name: 'Foobar', urlname: 'foobar') }
|
317
|
-
|
318
|
-
it "should always show the slug" do
|
319
|
-
alchemy_xhr :get, :configure, {id: page.id}
|
320
|
-
expect(response.body).to match /value="foobar"/
|
321
|
-
end
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
describe '#create' do
|
326
|
-
let(:language) { mock_model('Language', code: 'kl') }
|
327
|
-
let(:parent) { mock_model('Page', language: language) }
|
328
|
-
let(:page_params) { {parent_id: parent.id, name: 'new Page'} }
|
329
|
-
|
330
|
-
context "a new page" do
|
331
|
-
before do
|
332
|
-
allow_any_instance_of(Page).to receive(:set_language_from_parent_or_default)
|
333
|
-
allow_any_instance_of(Page).to receive(:save).and_return(true)
|
334
|
-
end
|
335
|
-
|
336
|
-
it "is nested under given parent" do
|
337
|
-
allow(controller).to receive(:edit_admin_page_path).and_return('bla')
|
338
|
-
alchemy_xhr :post, :create, {page: page_params}
|
339
|
-
expect(assigns(:page).parent_id).to eq(parent.id)
|
340
|
-
end
|
341
|
-
|
342
|
-
it "redirects to edit page template" do
|
343
|
-
expect(controller).to receive(:edit_admin_page_path).and_return('bla')
|
344
|
-
alchemy_post :create, page: page_params
|
345
|
-
expect(response).to redirect_to('bla')
|
346
|
-
end
|
347
|
-
|
348
|
-
context "if new page can not be saved" do
|
349
|
-
it "renders the create form" do
|
350
|
-
allow_any_instance_of(Page).to receive(:save).and_return(false)
|
351
|
-
alchemy_post :create, page: {name: 'page'}
|
352
|
-
expect(response).to render_template('new')
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
|
-
context "with redirect_to in params" do
|
357
|
-
let(:page_params) do
|
358
|
-
{name: "Foobar", page_layout: 'standard', parent_id: parent.id}
|
359
|
-
end
|
360
|
-
|
361
|
-
it "should redirect to given url" do
|
362
|
-
alchemy_post :create, page: page_params, redirect_to: admin_pictures_path
|
363
|
-
expect(response).to redirect_to(admin_pictures_path)
|
364
|
-
end
|
365
|
-
|
366
|
-
context "but new page can not be saved" do
|
367
|
-
render_views
|
368
|
-
|
369
|
-
it "should render the `new` template" do
|
370
|
-
allow_any_instance_of(Page).to receive(:save).and_return(false)
|
371
|
-
alchemy_xhr :post, :create, page: {name: 'page'}, redirect_to: admin_pictures_path
|
372
|
-
expect(response.body).to match /form.+action=\"\/admin\/pages\"/
|
373
|
-
end
|
374
|
-
end
|
375
|
-
end
|
376
|
-
|
377
|
-
context 'with page redirecting to external' do
|
378
|
-
it "redirects to sitemap" do
|
379
|
-
expect_any_instance_of(Page).to receive(:redirects_to_external?).and_return(true)
|
380
|
-
alchemy_post :create, page: page_params
|
381
|
-
expect(response).to redirect_to(admin_pages_path)
|
382
|
-
end
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
context "with paste_from_clipboard in parameters" do
|
387
|
-
let(:page_in_clipboard) { mock_model(Alchemy::Page) }
|
388
|
-
|
389
|
-
before do
|
390
|
-
allow(Page).to receive(:find_by).with(id: parent.id.to_s).and_return(parent)
|
391
|
-
allow(Page).to receive(:find).with(page_in_clipboard.id.to_s).and_return(page_in_clipboard)
|
392
|
-
end
|
393
|
-
|
394
|
-
it "should call Page#copy_and_paste" do
|
395
|
-
expect(Page).to receive(:copy_and_paste).with(
|
396
|
-
page_in_clipboard,
|
397
|
-
parent,
|
398
|
-
'pasted Page'
|
399
|
-
).and_return(
|
400
|
-
mock_model('Page', save: true, name: 'pasted Page', redirects_to_external?: false)
|
401
|
-
)
|
402
|
-
alchemy_xhr :post, :create, {paste_from_clipboard: page_in_clipboard.id, page: {parent_id: parent.id, name: 'pasted Page'}}
|
403
|
-
end
|
404
|
-
end
|
405
|
-
end
|
406
|
-
|
407
|
-
describe '#copy_language_tree' do
|
408
|
-
let(:params) { {languages: {new_lang_id: '2', old_lang_id: '1'}} }
|
409
|
-
let(:language_root_to_copy_from) { build_stubbed(:alchemy_page, :language_root) }
|
410
|
-
let(:copy_of_language_root) { build_stubbed(:alchemy_page, :language_root) }
|
411
|
-
let(:root_page) { mock_model('Page') }
|
412
|
-
|
413
|
-
before do
|
414
|
-
allow(Page).to receive(:copy).and_return(copy_of_language_root)
|
415
|
-
allow(Page).to receive(:root).and_return(root_page)
|
416
|
-
allow(Page).to receive(:language_root_for).and_return(language_root_to_copy_from)
|
417
|
-
allow_any_instance_of(Page).to receive(:move_to_child_of)
|
418
|
-
allow_any_instance_of(Page).to receive(:copy_children_to)
|
419
|
-
allow(controller).to receive(:store_current_language)
|
420
|
-
allow(Language).to receive(:current).and_return(mock_model('Language', locale: 'de', code: 'de'))
|
421
|
-
end
|
422
|
-
|
423
|
-
it "should copy the language root page over to the other language" do
|
424
|
-
expect(Page).to receive(:copy).with(language_root_to_copy_from, {language_id: '2', language_code: 'de'})
|
425
|
-
alchemy_post :copy_language_tree, params
|
426
|
-
end
|
427
|
-
|
428
|
-
it "should move the newly created language-root-page below the absolute root page" do
|
429
|
-
expect(copy_of_language_root).to receive(:move_to_child_of).with(root_page)
|
430
|
-
alchemy_post :copy_language_tree, params
|
431
|
-
end
|
432
|
-
|
433
|
-
it "should copy all childs of the original page over to the new created one" do
|
434
|
-
expect(controller).to receive(:language_root_to_copy_from).and_return(language_root_to_copy_from)
|
435
|
-
expect(controller).to receive(:copy_of_language_root).and_return(copy_of_language_root)
|
436
|
-
expect(language_root_to_copy_from).to receive(:copy_children_to).with(copy_of_language_root)
|
437
|
-
alchemy_post :copy_language_tree, params
|
438
|
-
end
|
439
|
-
|
440
|
-
it "should redirect to admin_pages_path" do
|
441
|
-
allow(controller).to receive(:copy_of_language_root)
|
442
|
-
allow(controller).to receive(:language_root_to_copy_from).and_return(double(copy_children_to: nil))
|
443
|
-
alchemy_post :copy_language_tree, params
|
444
|
-
expect(response).to redirect_to(admin_pages_path)
|
445
|
-
end
|
446
|
-
end
|
447
|
-
|
448
|
-
describe '#edit' do
|
449
|
-
let!(:page) { create(:alchemy_page) }
|
450
|
-
let!(:other_user) { create(:alchemy_dummy_user, :as_author) }
|
451
|
-
|
452
|
-
context 'if page is locked by another user' do
|
453
|
-
before { page.lock_to!(other_user) }
|
454
|
-
|
455
|
-
context 'that is signed in' do
|
456
|
-
before do
|
457
|
-
expect_any_instance_of(DummyUser).to receive(:logged_in?).and_return(true)
|
458
|
-
end
|
459
|
-
|
460
|
-
it 'redirects to sitemap' do
|
461
|
-
alchemy_get :edit, id: page.id
|
462
|
-
expect(response).to redirect_to(admin_pages_path)
|
463
|
-
end
|
464
|
-
end
|
465
|
-
|
466
|
-
context 'that is not signed in' do
|
467
|
-
before do
|
468
|
-
expect_any_instance_of(DummyUser).to receive(:logged_in?).and_return(false)
|
469
|
-
end
|
470
|
-
|
471
|
-
it 'renders the edit view' do
|
472
|
-
alchemy_get :edit, id: page.id
|
473
|
-
expect(response).to render_template(:edit)
|
474
|
-
end
|
475
|
-
end
|
476
|
-
end
|
477
|
-
|
478
|
-
context 'if page is locked by myself' do
|
479
|
-
before do
|
480
|
-
expect_any_instance_of(Page).to receive(:locker).and_return(user)
|
481
|
-
expect(user).to receive(:logged_in?).and_return(true)
|
482
|
-
end
|
483
|
-
|
484
|
-
it 'renders the edit view' do
|
485
|
-
alchemy_get :edit, id: page.id
|
486
|
-
expect(response).to render_template(:edit)
|
487
|
-
end
|
488
|
-
end
|
489
|
-
|
490
|
-
context 'if page is not locked' do
|
491
|
-
before do
|
492
|
-
expect_any_instance_of(Page).to receive(:locker).and_return(nil)
|
493
|
-
end
|
494
|
-
|
495
|
-
it 'renders the edit view' do
|
496
|
-
alchemy_get :edit, id: page.id
|
497
|
-
expect(response).to render_template(:edit)
|
498
|
-
end
|
499
|
-
|
500
|
-
it "lockes the page to myself" do
|
501
|
-
expect_any_instance_of(Page).to receive(:lock_to!)
|
502
|
-
alchemy_get :edit, id: page.id
|
503
|
-
end
|
504
|
-
end
|
505
|
-
end
|
506
|
-
|
507
|
-
describe '#destroy' do
|
508
|
-
let(:clipboard) { session[:alchemy_clipboard] = {} }
|
509
|
-
let(:page) { create(:alchemy_page, :public) }
|
510
|
-
|
511
|
-
before { clipboard['pages'] = [{'id' => page.id.to_s}] }
|
512
|
-
|
513
|
-
it "should also remove the page from clipboard" do
|
514
|
-
alchemy_xhr :post, :destroy, {id: page.id, _method: :delete}
|
515
|
-
expect(clipboard['pages']).to be_empty
|
516
|
-
end
|
517
|
-
end
|
518
|
-
|
519
|
-
describe '#publish' do
|
520
|
-
let(:page) { stub_model(Page, published_at: nil, public: false, name: "page", parent_id: 1, urlname: "page", language: stub_model(Language), page_layout: "bla") }
|
521
|
-
|
522
|
-
before do
|
523
|
-
allow(@controller).to receive(:load_page).and_return(page)
|
524
|
-
@controller.instance_variable_set("@page", page)
|
525
|
-
end
|
526
|
-
|
527
|
-
it "should publish the page" do
|
528
|
-
expect(page).to receive(:publish!)
|
529
|
-
alchemy_post :publish, { id: page.id }
|
530
|
-
end
|
531
|
-
end
|
532
|
-
|
533
|
-
describe '#visit' do
|
534
|
-
let(:page) { mock_model(Alchemy::Page, urlname: 'home') }
|
535
|
-
|
536
|
-
before do
|
537
|
-
allow(Page).to receive(:find).with(page.id.to_s).and_return(page)
|
538
|
-
allow(page).to receive(:unlock!).and_return(true)
|
539
|
-
allow(@controller).to receive(:multi_language?).and_return(false)
|
540
|
-
end
|
541
|
-
|
542
|
-
it "should redirect to the page path" do
|
543
|
-
expect(alchemy_post(:visit, id: page.id)).to redirect_to(show_page_path(urlname: 'home'))
|
544
|
-
end
|
545
|
-
end
|
546
|
-
|
547
|
-
describe '#fold' do
|
548
|
-
let(:page) { mock_model(Alchemy::Page) }
|
549
|
-
before { allow(Page).to receive(:find).and_return(page) }
|
550
|
-
|
551
|
-
context "if page is currently not folded" do
|
552
|
-
before { allow(page).to receive(:folded?).and_return(false) }
|
553
|
-
|
554
|
-
it "should fold the page" do
|
555
|
-
expect(page).to receive(:fold!).with(user.id, true).and_return(true)
|
556
|
-
alchemy_xhr :post, :fold, id: page.id
|
557
|
-
end
|
558
|
-
end
|
559
|
-
|
560
|
-
context "if page is already folded" do
|
561
|
-
before { allow(page).to receive(:folded?).and_return(true) }
|
562
|
-
|
563
|
-
it "should unfold the page" do
|
564
|
-
expect(page).to receive(:fold!).with(user.id, false).and_return(true)
|
565
|
-
alchemy_xhr :post, :fold, id: page.id
|
566
|
-
end
|
567
|
-
end
|
568
|
-
end
|
569
|
-
|
570
|
-
describe '#sort' do
|
571
|
-
before { allow(Page).to receive(:language_root_for).and_return(mock_model(Alchemy::Page)) }
|
572
|
-
|
573
|
-
it "should assign @sorting with true" do
|
574
|
-
alchemy_xhr :get, :sort
|
575
|
-
expect(assigns(:sorting)).to eq(true)
|
576
|
-
end
|
577
|
-
end
|
578
|
-
|
579
|
-
describe '#unlock' do
|
580
|
-
let(:page) { mock_model(Alchemy::Page, name: 'Best practices') }
|
581
|
-
|
582
|
-
before do
|
583
|
-
allow(Page).to receive(:find).with(page.id.to_s).and_return(page)
|
584
|
-
allow(Page).to receive(:from_current_site).and_return(double(locked_by: nil))
|
585
|
-
expect(page).to receive(:unlock!).and_return(true)
|
586
|
-
end
|
587
|
-
|
588
|
-
it "should unlock the page" do
|
589
|
-
alchemy_xhr :post, :unlock, id: page.id.to_s
|
590
|
-
end
|
591
|
-
|
592
|
-
context 'requesting for html format' do
|
593
|
-
it "should redirect to admin_pages_path" do
|
594
|
-
expect(alchemy_post(:unlock, id: page.id)).to redirect_to(admin_pages_path)
|
595
|
-
end
|
596
|
-
|
597
|
-
context 'if passing :redirect_to through params' do
|
598
|
-
it "should redirect to the given path" do
|
599
|
-
expect(
|
600
|
-
alchemy_post(:unlock, id: page.id, redirect_to: 'this/path')
|
601
|
-
).to redirect_to('this/path')
|
602
|
-
end
|
603
|
-
end
|
604
|
-
end
|
605
|
-
end
|
606
|
-
|
607
|
-
describe "#switch_language" do
|
608
|
-
let(:language) { build_stubbed(:alchemy_language, :klingon) }
|
609
|
-
|
610
|
-
before do
|
611
|
-
allow(Language).to receive(:find_by).and_return(language)
|
612
|
-
end
|
613
|
-
|
614
|
-
it "should store the current language in session" do
|
615
|
-
alchemy_get :switch_language, {language_id: language.id}
|
616
|
-
expect(session[:alchemy_language_id]).to eq(language.id)
|
617
|
-
end
|
618
|
-
|
619
|
-
it "should redirect to sitemap" do
|
620
|
-
expect(
|
621
|
-
alchemy_get(:switch_language, language_id: language.id)
|
622
|
-
).to redirect_to(admin_pages_path)
|
623
|
-
end
|
624
|
-
|
625
|
-
context "coming from layoutpages" do
|
626
|
-
before {
|
627
|
-
allow(request).to receive(:referer).and_return('admin/layoutpages')
|
628
|
-
}
|
629
|
-
|
630
|
-
it "should redirect to layoutpages" do
|
631
|
-
expect(
|
632
|
-
alchemy_get(:switch_language, language_id: language.id)
|
633
|
-
).to redirect_to(admin_layoutpages_path)
|
634
|
-
end
|
635
|
-
end
|
636
|
-
end
|
637
|
-
end
|
638
|
-
end
|
639
|
-
end
|