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,496 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Alchemy
|
4
|
-
describe Admin::ElementsController do
|
5
|
-
let(:alchemy_page) { create(:alchemy_page) }
|
6
|
-
let(:element) { create(:alchemy_element, page_id: alchemy_page.id) }
|
7
|
-
let(:element_in_clipboard) { create(:alchemy_element, page_id: alchemy_page.id) }
|
8
|
-
let(:clipboard) { session[:alchemy_clipboard] = {} }
|
9
|
-
|
10
|
-
before { authorize_user(:as_author) }
|
11
|
-
|
12
|
-
describe '#index' do
|
13
|
-
let(:alchemy_page) { build_stubbed(:alchemy_page) }
|
14
|
-
|
15
|
-
before do
|
16
|
-
expect(Page).to receive(:find).and_return alchemy_page
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'with cells' do
|
20
|
-
let(:cell) { build_stubbed(:alchemy_cell, page: alchemy_page) }
|
21
|
-
|
22
|
-
before do
|
23
|
-
expect(alchemy_page).to receive(:cells).and_return [cell]
|
24
|
-
end
|
25
|
-
|
26
|
-
it "groups elements by cell" do
|
27
|
-
expect(alchemy_page).to receive(:elements_grouped_by_cells)
|
28
|
-
alchemy_get :index, {page_id: alchemy_page.id}
|
29
|
-
expect(assigns(:cells)).to eq([cell])
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'without cells' do
|
34
|
-
before do
|
35
|
-
expect(alchemy_page).to receive(:cells).and_return []
|
36
|
-
end
|
37
|
-
|
38
|
-
it "assigns page elements" do
|
39
|
-
expect(alchemy_page).to receive(:elements).and_return(double(not_trashed: []))
|
40
|
-
alchemy_get :index, {page_id: alchemy_page.id}
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#list' do
|
46
|
-
context 'without page_id, but with page_urlname' do
|
47
|
-
it "loads page from urlname" do
|
48
|
-
expect {
|
49
|
-
alchemy_xhr :get, :list, {page_urlname: alchemy_page.urlname}
|
50
|
-
}.to_not raise_error
|
51
|
-
end
|
52
|
-
|
53
|
-
describe 'view' do
|
54
|
-
render_views
|
55
|
-
|
56
|
-
it "should return a select tag with elements" do
|
57
|
-
alchemy_xhr :get, :list, {page_urlname: alchemy_page.urlname}
|
58
|
-
expect(response.body).to match(/select(.*)elements_from_page_selector(.*)option/)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'with page_id' do
|
64
|
-
it "loads page from urlname" do
|
65
|
-
alchemy_xhr :get, :list, {page_id: alchemy_page.id}
|
66
|
-
expect(assigns(:page_id)).to eq(alchemy_page.id.to_s)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe '#order' do
|
72
|
-
let(:element_1) { create(:alchemy_element) }
|
73
|
-
let(:element_2) { create(:alchemy_element) }
|
74
|
-
let(:element_3) { create(:alchemy_element) }
|
75
|
-
let(:element_ids) { [element_1.id, element_3.id, element_2.id] }
|
76
|
-
|
77
|
-
it "sets new position for given element ids" do
|
78
|
-
alchemy_xhr :post, :order, element_ids: element_ids
|
79
|
-
expect(Element.all.pluck(:id)).to eq(element_ids)
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'with missing [:element_ids] param' do
|
83
|
-
it 'does not raise any error and silently rejects to order' do
|
84
|
-
expect {
|
85
|
-
alchemy_xhr :post, :order
|
86
|
-
}.to_not raise_error
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context "untrashing" do
|
91
|
-
let(:trashed_element) { create(:alchemy_element, public: false, position: nil, page_id: 58, cell_id: 32) }
|
92
|
-
|
93
|
-
before do
|
94
|
-
# Because of a before_create filter it can not be created with a nil position and needs to be trashed here
|
95
|
-
trashed_element.trash!
|
96
|
-
end
|
97
|
-
|
98
|
-
it "sets a list of trashed element ids" do
|
99
|
-
alchemy_xhr :post, :order, element_ids: [trashed_element.id]
|
100
|
-
expect(assigns(:trashed_element_ids).to_a).to eq [trashed_element.id]
|
101
|
-
end
|
102
|
-
|
103
|
-
it "sets a new position to the element" do
|
104
|
-
alchemy_xhr :post, :order, element_ids: [trashed_element.id]
|
105
|
-
trashed_element.reload
|
106
|
-
expect(trashed_element.position).to_not be_nil
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should assign the (new) page_id to the element" do
|
110
|
-
alchemy_xhr :post, :order, element_ids: [trashed_element.id], page_id: 1, cell_id: nil
|
111
|
-
trashed_element.reload
|
112
|
-
expect(trashed_element.page_id).to be 1
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should assign the (new) cell_id to the element" do
|
116
|
-
alchemy_xhr :post, :order, element_ids: [trashed_element.id], page_id: 1, cell_id: 5
|
117
|
-
trashed_element.reload
|
118
|
-
expect(trashed_element.cell_id).to be 5
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe '#new' do
|
124
|
-
let(:alchemy_page) { build_stubbed(:alchemy_page) }
|
125
|
-
|
126
|
-
before do
|
127
|
-
expect(Page).to receive(:find).and_return(alchemy_page)
|
128
|
-
end
|
129
|
-
|
130
|
-
it "assign variable for all available element definitions" do
|
131
|
-
expect(alchemy_page).to receive(:available_element_definitions)
|
132
|
-
alchemy_get :new, {page_id: alchemy_page.id}
|
133
|
-
end
|
134
|
-
|
135
|
-
context "with elements in clipboard" do
|
136
|
-
let(:clipboard_items) { [{'id' => element.id.to_s, 'action' => 'copy'}] }
|
137
|
-
|
138
|
-
before { clipboard['elements'] = clipboard_items }
|
139
|
-
|
140
|
-
it "should load all elements from clipboard" do
|
141
|
-
expect(Element).to receive(:all_from_clipboard_for_page).and_return(clipboard_items)
|
142
|
-
alchemy_get :new, {page_id: alchemy_page.id}
|
143
|
-
expect(assigns(:clipboard_items)).to eq(clipboard_items)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
describe '#create' do
|
149
|
-
describe 'insertion position' do
|
150
|
-
before { element }
|
151
|
-
|
152
|
-
it "should insert the element at bottom of list" do
|
153
|
-
alchemy_xhr :post, :create, {element: {name: 'news', page_id: alchemy_page.id}}
|
154
|
-
expect(alchemy_page.elements.count).to eq(2)
|
155
|
-
expect(alchemy_page.elements.last.name).to eq('news')
|
156
|
-
end
|
157
|
-
|
158
|
-
context "on a page with a setting for insert_elements_at of top" do
|
159
|
-
before do
|
160
|
-
expect(PageLayout).to receive(:get).at_least(:once).and_return({
|
161
|
-
'name' => 'news',
|
162
|
-
'elements' => ['news'],
|
163
|
-
'insert_elements_at' => 'top'
|
164
|
-
})
|
165
|
-
end
|
166
|
-
|
167
|
-
it "should insert the element at top of list" do
|
168
|
-
alchemy_xhr :post, :create, {element: {name: 'news', page_id: alchemy_page.id}}
|
169
|
-
expect(alchemy_page.elements.count).to eq(2)
|
170
|
-
expect(alchemy_page.elements.first.name).to eq('news')
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
context "if page has cells" do
|
176
|
-
let(:page) { create(:alchemy_page, :public, do_not_autogenerate: false) }
|
177
|
-
let(:cell) { page.cells.first }
|
178
|
-
|
179
|
-
context "not pasting from clipboard" do
|
180
|
-
context "and cell name in element name" do
|
181
|
-
before do
|
182
|
-
expect(PageLayout).to receive(:get).at_least(:once).and_return({
|
183
|
-
'name' => 'standard',
|
184
|
-
'elements' => ['article'],
|
185
|
-
'cells' => ['header']
|
186
|
-
})
|
187
|
-
expect(Cell).to receive(:definition_for).and_return({
|
188
|
-
'name' => 'header',
|
189
|
-
'elements' => ['article']
|
190
|
-
})
|
191
|
-
end
|
192
|
-
|
193
|
-
it "should put the element in the correct cell" do
|
194
|
-
alchemy_xhr :post, :create, {element: {name: "article#header", page_id: page.id}}
|
195
|
-
expect(cell.elements.first).to be_an_instance_of(Element)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
context "and no cell name in element name" do
|
200
|
-
it "should put the element in the main cell" do
|
201
|
-
alchemy_xhr :post, :create, {element: {name: "article", page_id: page.id}}
|
202
|
-
expect(page.elements.not_in_cell.first).to be_an_instance_of(Element)
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
context "pasting from clipboard" do
|
208
|
-
context "with default element insert position" do
|
209
|
-
before do
|
210
|
-
expect(PageLayout).to receive(:get).at_least(:once).and_return({
|
211
|
-
'name' => 'standard',
|
212
|
-
'elements' => ['article'],
|
213
|
-
'cells' => ['header']
|
214
|
-
})
|
215
|
-
clipboard['elements'] = [{'id' => element_in_clipboard.id.to_s}]
|
216
|
-
end
|
217
|
-
|
218
|
-
context "and cell name in element name" do
|
219
|
-
before do
|
220
|
-
expect(Cell).to receive(:definition_for).at_least(:once).and_return({
|
221
|
-
'name' => 'header',
|
222
|
-
'elements' => ['article']
|
223
|
-
})
|
224
|
-
end
|
225
|
-
|
226
|
-
it "should create the element in the correct cell" do
|
227
|
-
alchemy_xhr :post, :create, {element: {page_id: page.id}, paste_from_clipboard: "#{element_in_clipboard.id}##{cell.name}"}
|
228
|
-
expect(cell.elements.first).to be_an_instance_of(Element)
|
229
|
-
end
|
230
|
-
|
231
|
-
context "with elements already in cell" do
|
232
|
-
before do
|
233
|
-
cell.elements.create(page_id: page.id, name: "article", create_contents_after_create: false)
|
234
|
-
end
|
235
|
-
|
236
|
-
it "should set the correct position for the element" do
|
237
|
-
alchemy_xhr :post, :create, {element: {page_id: page.id}, paste_from_clipboard: "#{element_in_clipboard.id}##{cell.name}"}
|
238
|
-
expect(cell.elements.last.position).to eq(cell.elements.count)
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
context "and no cell name in element name" do
|
244
|
-
it "should create the element in the nil cell" do
|
245
|
-
alchemy_xhr :post, :create, {element: {page_id: page.id}, paste_from_clipboard: element_in_clipboard.id.to_s}
|
246
|
-
expect(page.elements.first.cell).to eq(nil)
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
context "on a page with a setting for insert_elements_at of top" do
|
252
|
-
let!(:alchemy_page) { create(:alchemy_page, :public, name: 'News') }
|
253
|
-
let!(:element_in_clipboard) { create(:alchemy_element, page: alchemy_page, name: 'news') }
|
254
|
-
let!(:cell) { create(:alchemy_cell, name: 'news', page: alchemy_page) }
|
255
|
-
let!(:element) { create(:alchemy_element, name: 'news', page: alchemy_page, cell: cell) }
|
256
|
-
|
257
|
-
before do
|
258
|
-
expect(PageLayout).to receive(:get).at_least(:once).and_return({
|
259
|
-
'name' => 'news',
|
260
|
-
'elements' => ['news'],
|
261
|
-
'insert_elements_at' => 'top',
|
262
|
-
'cells' => ['news']
|
263
|
-
})
|
264
|
-
expect(Cell).to receive(:definition_for).and_return({
|
265
|
-
'name' => 'news',
|
266
|
-
'elements' => ['news']
|
267
|
-
})
|
268
|
-
clipboard['elements'] = [{'id' => element_in_clipboard.id.to_s}]
|
269
|
-
cell.elements << element
|
270
|
-
end
|
271
|
-
|
272
|
-
it "should insert the element at top of list" do
|
273
|
-
alchemy_xhr :post, :create, {element: {name: 'news', page_id: alchemy_page.id}, paste_from_clipboard: "#{element_in_clipboard.id}##{cell.name}"}
|
274
|
-
expect(cell.elements.count).to eq(2)
|
275
|
-
expect(cell.elements.first.name).to eq('news')
|
276
|
-
expect(cell.elements.first).not_to eq(element)
|
277
|
-
end
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
context "pasting from clipboard" do
|
283
|
-
render_views
|
284
|
-
|
285
|
-
before do
|
286
|
-
clipboard['elements'] = [{'id' => element_in_clipboard.id.to_s, 'action' => 'cut'}]
|
287
|
-
end
|
288
|
-
|
289
|
-
it "should create an element from clipboard" do
|
290
|
-
alchemy_xhr :post, :create, {paste_from_clipboard: element_in_clipboard.id, element: {page_id: alchemy_page.id}}
|
291
|
-
expect(response.status).to eq(200)
|
292
|
-
expect(response.body).to match(/Successfully added new element/)
|
293
|
-
end
|
294
|
-
|
295
|
-
context "and with cut as action parameter" do
|
296
|
-
it "should also remove the element id from clipboard" do
|
297
|
-
alchemy_xhr :post, :create, {paste_from_clipboard: element_in_clipboard.id, element: {page_id: alchemy_page.id}}
|
298
|
-
expect(session[:alchemy_clipboard]['elements'].detect { |item| item['id'] == element_in_clipboard.id.to_s }).to be_nil
|
299
|
-
end
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
context 'if element could not be saved' do
|
304
|
-
subject { alchemy_post :create, {element: {page_id: alchemy_page.id}} }
|
305
|
-
|
306
|
-
before do
|
307
|
-
expect_any_instance_of(Element).to receive(:save).and_return false
|
308
|
-
end
|
309
|
-
|
310
|
-
it "renders the new template" do
|
311
|
-
expect(subject).to render_template(:new)
|
312
|
-
end
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
describe '#find_or_create_cell' do
|
317
|
-
before do
|
318
|
-
controller.instance_variable_set(:@page, alchemy_page)
|
319
|
-
end
|
320
|
-
|
321
|
-
context "with element name and cell name in the params" do
|
322
|
-
before do
|
323
|
-
expect(Cell).to receive(:definition_for).and_return({
|
324
|
-
'name' => 'header',
|
325
|
-
'elements' => ['header']
|
326
|
-
})
|
327
|
-
expect(controller).to receive(:params).and_return({element: {name: 'header#header'}})
|
328
|
-
end
|
329
|
-
|
330
|
-
context "with cell not existing" do
|
331
|
-
it "should create the cell" do
|
332
|
-
expect {
|
333
|
-
controller.send(:find_or_create_cell)
|
334
|
-
}.to change(alchemy_page.cells, :count).from(0).to(1)
|
335
|
-
end
|
336
|
-
end
|
337
|
-
|
338
|
-
context "with the cell already present" do
|
339
|
-
before do
|
340
|
-
create(:alchemy_cell, page: alchemy_page, name: 'header')
|
341
|
-
end
|
342
|
-
|
343
|
-
it "should load the cell" do
|
344
|
-
expect {
|
345
|
-
controller.send(:find_or_create_cell)
|
346
|
-
}.to_not change(alchemy_page.cells, :count)
|
347
|
-
end
|
348
|
-
end
|
349
|
-
end
|
350
|
-
|
351
|
-
context "with only the element name in the params" do
|
352
|
-
before do
|
353
|
-
expect(controller).to receive(:params).and_return({element: {name: 'header'}})
|
354
|
-
end
|
355
|
-
|
356
|
-
it "should return nil" do
|
357
|
-
expect(controller.send(:find_or_create_cell)).to be_nil
|
358
|
-
end
|
359
|
-
end
|
360
|
-
|
361
|
-
context 'with cell definition not found' do
|
362
|
-
before do
|
363
|
-
expect(controller).to receive(:params).and_return({element: {name: 'header#header'}})
|
364
|
-
expect(Cell).to receive(:definition_for).and_return nil
|
365
|
-
end
|
366
|
-
|
367
|
-
it "raises error" do
|
368
|
-
expect { controller.send(:find_or_create_cell) }.to raise_error(CellDefinitionError)
|
369
|
-
end
|
370
|
-
end
|
371
|
-
end
|
372
|
-
|
373
|
-
describe '#update' do
|
374
|
-
let(:page) { build_stubbed(:alchemy_page) }
|
375
|
-
let(:element) { build_stubbed(:alchemy_element, page: page) }
|
376
|
-
let(:contents_parameters) { ActionController::Parameters.new(1 => {ingredient: 'Title'}) }
|
377
|
-
let(:element_parameters) { ActionController::Parameters.new(tag_list: 'Tag 1', public: false) }
|
378
|
-
|
379
|
-
before do
|
380
|
-
expect(Element).to receive(:find).and_return element
|
381
|
-
expect(controller).to receive(:contents_params).and_return(contents_parameters)
|
382
|
-
end
|
383
|
-
|
384
|
-
it "updates all contents in element" do
|
385
|
-
expect(element).to receive(:update_contents).with(contents_parameters)
|
386
|
-
alchemy_xhr :put, :update, {id: element.id}
|
387
|
-
end
|
388
|
-
|
389
|
-
it "updates the element" do
|
390
|
-
expect(controller).to receive(:element_params).and_return(element_parameters)
|
391
|
-
expect(element).to receive(:update_contents).and_return(true)
|
392
|
-
expect(element).to receive(:update_attributes!).with(element_parameters).and_return(true)
|
393
|
-
alchemy_xhr :put, :update, {id: element.id}
|
394
|
-
end
|
395
|
-
|
396
|
-
context "failed validations" do
|
397
|
-
it "displays validation failed notice" do
|
398
|
-
expect(element).to receive(:update_contents).and_return(false)
|
399
|
-
alchemy_xhr :put, :update, {id: element.id}
|
400
|
-
expect(assigns(:element_validated)).to be_falsey
|
401
|
-
end
|
402
|
-
end
|
403
|
-
end
|
404
|
-
|
405
|
-
describe 'params security' do
|
406
|
-
context "contents params" do
|
407
|
-
let(:parameters) { ActionController::Parameters.new(contents: {1 => {ingredient: 'Title'}}) }
|
408
|
-
|
409
|
-
specify ":contents is required" do
|
410
|
-
expect(controller.params).to receive(:fetch).and_return(parameters)
|
411
|
-
controller.send :contents_params
|
412
|
-
end
|
413
|
-
|
414
|
-
specify "everything is permitted" do
|
415
|
-
expect(controller).to receive(:params).and_return(parameters)
|
416
|
-
expect(parameters).to receive(:fetch).and_return(parameters)
|
417
|
-
expect(parameters).to receive(:permit!)
|
418
|
-
controller.send :contents_params
|
419
|
-
end
|
420
|
-
end
|
421
|
-
|
422
|
-
context "element params" do
|
423
|
-
let(:parameters) { ActionController::Parameters.new(element: {public: true}) }
|
424
|
-
|
425
|
-
before do
|
426
|
-
expect(controller).to receive(:params).and_return(parameters)
|
427
|
-
expect(parameters).to receive(:fetch).with(:element, {}).and_return(parameters)
|
428
|
-
end
|
429
|
-
|
430
|
-
context 'with taggable element' do
|
431
|
-
before do
|
432
|
-
controller.instance_variable_set(:'@element', mock_model(Element, taggable?: true))
|
433
|
-
end
|
434
|
-
|
435
|
-
specify ":tag_list is permitted" do
|
436
|
-
expect(parameters).to receive(:permit).with(:tag_list)
|
437
|
-
controller.send :element_params
|
438
|
-
end
|
439
|
-
end
|
440
|
-
|
441
|
-
context 'with not taggable element' do
|
442
|
-
before do
|
443
|
-
controller.instance_variable_set(:'@element', mock_model(Element, taggable?: false))
|
444
|
-
end
|
445
|
-
|
446
|
-
specify ":tag_list is not permitted" do
|
447
|
-
expect(parameters).to_not receive(:permit)
|
448
|
-
controller.send :element_params
|
449
|
-
end
|
450
|
-
end
|
451
|
-
end
|
452
|
-
end
|
453
|
-
|
454
|
-
describe '#trash' do
|
455
|
-
subject { alchemy_xhr :delete, :trash, {id: element.id} }
|
456
|
-
|
457
|
-
let(:element) { build_stubbed(:alchemy_element) }
|
458
|
-
|
459
|
-
before { expect(Element).to receive(:find).and_return element }
|
460
|
-
|
461
|
-
it "trashes the element instead of deleting it" do
|
462
|
-
expect(element).to receive(:trash!).and_return(true)
|
463
|
-
subject
|
464
|
-
end
|
465
|
-
end
|
466
|
-
|
467
|
-
describe '#fold' do
|
468
|
-
subject { alchemy_xhr :post, :fold, {id: element.id} }
|
469
|
-
|
470
|
-
let(:element) { build_stubbed(:alchemy_element) }
|
471
|
-
|
472
|
-
before do
|
473
|
-
expect(element).to receive(:save).and_return true
|
474
|
-
expect(Element).to receive(:find).and_return element
|
475
|
-
end
|
476
|
-
|
477
|
-
context 'if element is folded' do
|
478
|
-
before { expect(element).to receive(:folded).and_return true }
|
479
|
-
|
480
|
-
it "sets folded to false." do
|
481
|
-
expect(element).to receive(:folded=).with(false).and_return(false)
|
482
|
-
subject
|
483
|
-
end
|
484
|
-
end
|
485
|
-
|
486
|
-
context 'if element is not folded' do
|
487
|
-
before { expect(element).to receive(:folded).and_return false }
|
488
|
-
|
489
|
-
it "sets folded to true." do
|
490
|
-
expect(element).to receive(:folded=).with(true).and_return(true)
|
491
|
-
subject
|
492
|
-
end
|
493
|
-
end
|
494
|
-
end
|
495
|
-
end
|
496
|
-
end
|