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,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Alchemy
|
4
|
-
describe BaseHelper do
|
5
|
-
describe "#render_message" do
|
6
|
-
context "if no argument is passed" do
|
7
|
-
it "should render a div with an info icon and the given content" do
|
8
|
-
expect(helper.render_message{ content_tag(:p, "my notice") }).to match(/<div class="info message"><span class="icon info"><\/span><p>my notice/)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context "if an argument is passed" do
|
13
|
-
it "should render the passed argument as the css classname for the icon container" do
|
14
|
-
expect(helper.render_message(:error){ content_tag(:p, "my notice") }).to match(/<div class="error message"><span class="icon error">/)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#page_or_find' do
|
20
|
-
let(:page) { create(:alchemy_page, :public) }
|
21
|
-
|
22
|
-
context "passing a page_layout string" do
|
23
|
-
context "of a not existing page" do
|
24
|
-
it "should return nil" do
|
25
|
-
expect(helper.page_or_find('contact')).to be_nil
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'of an existing page' do
|
30
|
-
it "should return the page object" do
|
31
|
-
session[:alchemy_language_id] = page.language_id
|
32
|
-
expect(helper.page_or_find(page.page_layout)).to eq(page)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "passing a page object" do
|
38
|
-
it "should return the given page object" do
|
39
|
-
expect(helper.page_or_find(page)).to eq(page)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,135 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
include Alchemy::ElementsHelper
|
4
|
-
|
5
|
-
module Alchemy
|
6
|
-
describe 'ElementsBlockHelper' do
|
7
|
-
let(:page) { create(:alchemy_page, :public) }
|
8
|
-
let(:element) { create(:alchemy_element, page: page, tag_list: 'foo, bar') }
|
9
|
-
let(:expected_wrapper_tag) { "div.#{element.name}##{element_dom_id(element)}" }
|
10
|
-
|
11
|
-
describe '#element_view_for' do
|
12
|
-
it "should yield an instance of ElementViewHelper" do
|
13
|
-
expect { |b| element_view_for(element, &b) }.
|
14
|
-
to yield_with_args(ElementsBlockHelper::ElementViewHelper)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should wrap its output in a DOM element" do
|
18
|
-
expect(element_view_for(element)).
|
19
|
-
to have_css expected_wrapper_tag
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should change the wrapping DOM element according to parameters" do
|
23
|
-
expect(element_view_for(element, tag: 'span', class: 'some_class', id: 'some_id')).
|
24
|
-
to have_css 'span.some_class#some_id'
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should include the element's tags in the wrapper DOM element" do
|
28
|
-
expect(element_view_for(element)).
|
29
|
-
to have_css "#{expected_wrapper_tag}[data-element-tags='foo bar']"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should use the provided tags formatter to format tags" do
|
33
|
-
expect(element_view_for(element, tags_formatter: lambda { |tags| tags.join ", " })).
|
34
|
-
to have_css "#{expected_wrapper_tag}[data-element-tags='foo, bar']"
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should include the contents rendered by the block passed to it" do
|
38
|
-
expect(element_view_for(element) do
|
39
|
-
'view'
|
40
|
-
end).to have_content 'view'
|
41
|
-
end
|
42
|
-
|
43
|
-
context "when/if preview mode is not active" do
|
44
|
-
subject { element_view_for(element) }
|
45
|
-
it { is_expected.to have_css expected_wrapper_tag }
|
46
|
-
it { is_expected.not_to have_css "#{expected_wrapper_tag}[data-alchemy-element]" }
|
47
|
-
end
|
48
|
-
|
49
|
-
context "when/if preview mode is active" do
|
50
|
-
before do
|
51
|
-
assign(:preview_mode, true)
|
52
|
-
assign(:page, page)
|
53
|
-
end
|
54
|
-
|
55
|
-
subject { helper.element_view_for(element) }
|
56
|
-
it { is_expected.to have_css "#{expected_wrapper_tag}[data-alchemy-element='#{element.id}']" }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '#element_editor_for' do
|
61
|
-
it "should yield an instance of ElementEditorHelper" do
|
62
|
-
expect { |b| element_editor_for(element, &b) }.
|
63
|
-
to yield_with_args(ElementsBlockHelper::ElementEditorHelper)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should not add any extra elements" do
|
67
|
-
expect(element_editor_for(element) do
|
68
|
-
'view'
|
69
|
-
end).to eq('view')
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe 'ElementsBlockHelper::ElementViewHelper' do
|
74
|
-
let(:scope) { double }
|
75
|
-
subject { ElementsBlockHelper::ElementViewHelper.new(scope, element: element) }
|
76
|
-
|
77
|
-
it 'should have a reference to the specified element' do
|
78
|
-
subject.element == element
|
79
|
-
end
|
80
|
-
|
81
|
-
describe '#render' do
|
82
|
-
it 'should delegate to the render_essence_view_by_name helper' do
|
83
|
-
expect(scope).to receive(:render_essence_view_by_name).with(element, "title", foo: 'bar')
|
84
|
-
subject.render :title, foo: 'bar'
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '#content' do
|
89
|
-
it "should delegate to the element's #content_by_name method" do
|
90
|
-
expect(element).to receive(:content_by_name).with(:title)
|
91
|
-
subject.content :title
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe '#ingredient' do
|
96
|
-
it "should delegate to the element's #ingredient method" do
|
97
|
-
expect(element).to receive(:ingredient).with(:title)
|
98
|
-
subject.ingredient :title
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe '#has?' do
|
103
|
-
it "should delegate to the element's #has_ingredient? method" do
|
104
|
-
expect(element).to receive(:has_ingredient?).with(:title)
|
105
|
-
subject.has? :title
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe '#essence' do
|
110
|
-
it "should provide the specified content essence" do
|
111
|
-
expect(subject).to receive(:content).with(:title).
|
112
|
-
and_return(mock_model('Content', essence: mock_model('EssenceText')))
|
113
|
-
|
114
|
-
subject.essence :title
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe 'ElementsBlockHelper::ElementEditorHelper' do
|
120
|
-
let(:scope) { double }
|
121
|
-
subject { ElementsBlockHelper::ElementEditorHelper.new(scope, element: element) }
|
122
|
-
|
123
|
-
it 'should have a reference to the specified element' do
|
124
|
-
subject.element == element
|
125
|
-
end
|
126
|
-
|
127
|
-
describe '#edit' do
|
128
|
-
it "should delegate to the render_essence_editor_by_name helper" do
|
129
|
-
expect(scope).to receive(:render_essence_editor_by_name).with(element, "title", foo: 'bar')
|
130
|
-
subject.edit :title, foo: 'bar'
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
@@ -1,326 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
include Alchemy::BaseHelper
|
3
|
-
|
4
|
-
module Alchemy
|
5
|
-
describe ElementsHelper do
|
6
|
-
let(:page) { build_stubbed(:alchemy_page, :public) }
|
7
|
-
let(:element) { build_stubbed(:alchemy_element, name: 'headline', page: page) }
|
8
|
-
|
9
|
-
before do
|
10
|
-
assign(:page, page)
|
11
|
-
allow_any_instance_of(Element).to receive(:store_page).and_return(true)
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#render_element' do
|
15
|
-
subject { render_element(element, part) }
|
16
|
-
|
17
|
-
context 'with nil element' do
|
18
|
-
let(:element) { nil }
|
19
|
-
let(:part) { :view }
|
20
|
-
it { is_expected.to be_nil }
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'with view as part given' do
|
24
|
-
let(:part) { :view }
|
25
|
-
|
26
|
-
it "renders the element's view partial" do
|
27
|
-
is_expected.to have_selector("##{element.name}_#{element.id}")
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'with element view partial not found' do
|
31
|
-
let(:element) { build_stubbed(:alchemy_element, name: 'not_present') }
|
32
|
-
|
33
|
-
it "renders the view not found partial" do
|
34
|
-
is_expected.to match(/Missing view for not_present element/)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'with editor as part given' do
|
40
|
-
let(:part) { :editor }
|
41
|
-
|
42
|
-
it "renders the element's editor partial" do
|
43
|
-
expect(helper).to receive(:render_essence_editor_by_name)
|
44
|
-
subject
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'with element editor partial not found' do
|
48
|
-
let(:element) { build_stubbed(:alchemy_element, name: 'not_present') }
|
49
|
-
|
50
|
-
it "renders the editor not found partial" do
|
51
|
-
is_expected.to have_selector('div.error')
|
52
|
-
is_expected.to have_content('Element editor partial not found')
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#element_dom_id' do
|
59
|
-
subject { helper.element_dom_id(element) }
|
60
|
-
|
61
|
-
it "should render a unique dom id for element" do
|
62
|
-
is_expected.to eq("#{element.name}_#{element.id}")
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "#render_elements" do
|
67
|
-
subject { helper.render_elements(options) }
|
68
|
-
|
69
|
-
let(:another_element) { build_stubbed(:alchemy_element, page: page) }
|
70
|
-
let(:elements) { [element, another_element] }
|
71
|
-
|
72
|
-
context 'without any options' do
|
73
|
-
let(:options) { {} }
|
74
|
-
|
75
|
-
before do
|
76
|
-
expect(page).to receive(:find_elements).and_return(elements)
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should render all elements from page." do
|
80
|
-
is_expected.to have_selector("##{element.name}_#{element.id}")
|
81
|
-
is_expected.to have_selector("##{another_element.name}_#{another_element.id}")
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "with from_page option" do
|
86
|
-
context 'is a page object' do
|
87
|
-
let(:another_page) { build_stubbed(:alchemy_page, :public) }
|
88
|
-
let(:options) { {from_page: another_page} }
|
89
|
-
|
90
|
-
before do
|
91
|
-
expect(another_page).to receive(:find_elements).and_return(elements)
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should render all elements from that page." do
|
95
|
-
is_expected.to have_selector("##{element.name}_#{element.id}")
|
96
|
-
is_expected.to have_selector("##{another_element.name}_#{another_element.id}")
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'is a string' do
|
101
|
-
let(:another_page) { build_stubbed(:alchemy_page, :public) }
|
102
|
-
let(:another_element) { build_stubbed(:alchemy_element, page: another_page) }
|
103
|
-
let(:other_elements) { [another_element] }
|
104
|
-
let(:options) { {from_page: 'news'} }
|
105
|
-
|
106
|
-
before do
|
107
|
-
allow(Language).to receive(:current).and_return double(pages: double(where: pages))
|
108
|
-
expect(another_page).to receive(:find_elements).and_return(other_elements)
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'and one page can be found by page layout' do
|
112
|
-
let(:pages) { [another_page] }
|
113
|
-
|
114
|
-
it "it renders all elements from that page." do
|
115
|
-
is_expected.to have_selector("##{another_element.name}_#{another_element.id}")
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
context 'and an array of pages has been found' do
|
120
|
-
let(:pages) { [page, another_page] }
|
121
|
-
|
122
|
-
before do
|
123
|
-
expect(page).to receive(:find_elements).and_return(elements)
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'renders elements from these pages' do
|
127
|
-
is_expected.to have_selector("##{element.name}_#{element.id}")
|
128
|
-
is_expected.to have_selector("##{another_element.name}_#{another_element.id}")
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
context 'if page is nil' do
|
135
|
-
let(:options) { {from_page: nil} }
|
136
|
-
it { is_expected.to be_blank }
|
137
|
-
end
|
138
|
-
|
139
|
-
context 'with sort_by and reverse option given' do
|
140
|
-
let(:options) { {sort_by: true, reverse: true} }
|
141
|
-
let(:sorted_elements) { [another_element, element] }
|
142
|
-
|
143
|
-
before do
|
144
|
-
expect(elements).to receive(:sort_by).and_return(sorted_elements)
|
145
|
-
expect(sorted_elements).to receive(:reverse).and_return(elements)
|
146
|
-
expect(page).to receive(:find_elements).and_return(elements)
|
147
|
-
end
|
148
|
-
|
149
|
-
it "renders the sorted elements in reverse order" do
|
150
|
-
is_expected.not_to be_blank
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
context 'with sort_by option given' do
|
155
|
-
let(:options) { {sort_by: 'title'} }
|
156
|
-
let(:sorted_elements) { [another_element, element] }
|
157
|
-
|
158
|
-
before do
|
159
|
-
expect(elements).to receive(:sort_by).and_return(sorted_elements)
|
160
|
-
expect(elements).not_to receive(:reverse)
|
161
|
-
expect(page).to receive(:find_elements).and_return(elements)
|
162
|
-
end
|
163
|
-
|
164
|
-
it "renders the elements in the order of given content name" do
|
165
|
-
is_expected.not_to be_blank
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
context "with option fallback" do
|
170
|
-
let(:another_page) { build_stubbed(:alchemy_page, :public, name: 'Another Page', page_layout: 'news') }
|
171
|
-
let(:another_element) { build_stubbed(:alchemy_element, page: another_page, name: 'news') }
|
172
|
-
let(:elements) { [another_element] }
|
173
|
-
|
174
|
-
context 'with string given as :fallback_from' do
|
175
|
-
let(:options) { {fallback: {for: 'higgs', with: 'news', from: 'news'}} }
|
176
|
-
|
177
|
-
before do
|
178
|
-
allow(Language).to receive(:current).and_return double(pages: double(find_by: another_page))
|
179
|
-
allow(another_page).to receive(:elements).and_return double(not_trashed: double(named: elements))
|
180
|
-
end
|
181
|
-
|
182
|
-
it "renders the fallback element" do
|
183
|
-
is_expected.to have_selector("#news_#{another_element.id}")
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
context 'with page given as :fallback_from' do
|
188
|
-
let(:options) { {fallback: {for: 'higgs', with: 'news', from: another_page}} }
|
189
|
-
|
190
|
-
before do
|
191
|
-
allow(another_page).to receive(:elements).and_return double(not_trashed: double(named: elements))
|
192
|
-
end
|
193
|
-
|
194
|
-
it "renders the fallback element" do
|
195
|
-
is_expected.to have_selector("#news_#{another_element.id}")
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
context 'with option separator given' do
|
201
|
-
let(:options) { {separator: '<hr>'} }
|
202
|
-
|
203
|
-
before do
|
204
|
-
expect(page).to receive(:find_elements).and_return(elements)
|
205
|
-
end
|
206
|
-
|
207
|
-
it "joins element partials with given string" do
|
208
|
-
is_expected.to have_selector('hr')
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
describe '#element_preview_code_attributes' do
|
214
|
-
subject { helper.element_preview_code_attributes(element) }
|
215
|
-
|
216
|
-
context 'in preview_mode' do
|
217
|
-
before { assign(:preview_mode, true) }
|
218
|
-
|
219
|
-
it "should return the data-alchemy-element HTML attribute for element" do
|
220
|
-
is_expected.to eq({:'data-alchemy-element' => element.id})
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
context 'not in preview_mode' do
|
225
|
-
it "should return an empty hash" do
|
226
|
-
is_expected.to eq({})
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
describe '#element_preview_code' do
|
232
|
-
subject { helper.element_preview_code(element) }
|
233
|
-
|
234
|
-
context 'in preview_mode' do
|
235
|
-
before { assign(:preview_mode, true) }
|
236
|
-
|
237
|
-
it "should return the data-alchemy-element HTML attribute for element" do
|
238
|
-
is_expected.to eq(" data-alchemy-element=\"#{element.id}\"")
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
context 'not in preview_mode' do
|
243
|
-
it "should not return the data-alchemy-element HTML attribute" do
|
244
|
-
is_expected.not_to eq(" data-alchemy-element=\"#{element.id}\"")
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
describe '#element_tags' do
|
250
|
-
subject { element_tags(element, options) }
|
251
|
-
|
252
|
-
let(:element) { build_stubbed(:alchemy_element) }
|
253
|
-
let(:options) { {} }
|
254
|
-
|
255
|
-
context "element having tags" do
|
256
|
-
before { element.tag_list = "peter, lustig" }
|
257
|
-
|
258
|
-
context "with no formatter lambda given" do
|
259
|
-
it "should return tag list as HTML data attribute" do
|
260
|
-
is_expected.to eq(" data-element-tags=\"peter lustig\"")
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
context "with a formatter lambda given" do
|
265
|
-
let(:options) { {formatter: ->(tags) { tags.join ", " }} }
|
266
|
-
|
267
|
-
it "should return a properly formatted HTML data attribute" do
|
268
|
-
is_expected.to eq(" data-element-tags=\"peter, lustig\"")
|
269
|
-
end
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
context "element not having tags" do
|
274
|
-
it { is_expected.to be_blank }
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
describe '#sort_elements_by_content' do
|
279
|
-
subject { sort_elements_by_content(elements, 'headline') }
|
280
|
-
|
281
|
-
let(:element_1) { build_stubbed(:alchemy_element) }
|
282
|
-
let(:element_2) { build_stubbed(:alchemy_element) }
|
283
|
-
let(:element_3) { build_stubbed(:alchemy_element) }
|
284
|
-
let(:ingredient_a) { double(ingredient: 'a') }
|
285
|
-
let(:ingredient_b) { double(ingredient: 'b') }
|
286
|
-
let(:ingredient_c) { double(ingredient: 'c') }
|
287
|
-
let(:elements) { [element_1, element_2, element_3] }
|
288
|
-
|
289
|
-
before do
|
290
|
-
expect(element_1).to receive(:content_by_name).and_return(ingredient_b)
|
291
|
-
expect(element_2).to receive(:content_by_name).and_return(ingredient_c)
|
292
|
-
expect(element_3).to receive(:content_by_name).and_return(ingredient_a)
|
293
|
-
end
|
294
|
-
|
295
|
-
it "sorts the elements by content" do
|
296
|
-
is_expected.to eq [element_3, element_1, element_2]
|
297
|
-
end
|
298
|
-
|
299
|
-
context 'with element not having this content' do
|
300
|
-
let(:element_4) { build_stubbed(:alchemy_element) }
|
301
|
-
let(:elements) { [element_1, element_2, element_3, element_4] }
|
302
|
-
|
303
|
-
before do
|
304
|
-
expect(element_4).to receive(:content_by_name).and_return(nil)
|
305
|
-
end
|
306
|
-
|
307
|
-
it "puts it at first place" do
|
308
|
-
is_expected.to eq [element_4, element_3, element_1, element_2]
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
context 'with element having content with nil as ingredient' do
|
313
|
-
let(:element_4) { build_stubbed(:alchemy_element) }
|
314
|
-
let(:elements) { [element_1, element_2, element_3, element_4] }
|
315
|
-
|
316
|
-
before do
|
317
|
-
expect(element_4).to receive(:content_by_name).and_return(double(ingredient: nil))
|
318
|
-
end
|
319
|
-
|
320
|
-
it "puts it at first place" do
|
321
|
-
is_expected.to eq [element_4, element_3, element_1, element_2]
|
322
|
-
end
|
323
|
-
end
|
324
|
-
end
|
325
|
-
end
|
326
|
-
end
|