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,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Alchemy::EssencesHelper do
|
4
|
-
let(:element) { build_stubbed(:alchemy_element) }
|
5
|
-
let(:content) { build_stubbed(:alchemy_content, element: element, ingredient: 'hello!') }
|
6
|
-
let(:essence) { mock_model('EssenceText', link: nil, partial_name: 'essence_text', ingredient: 'hello!') }
|
7
|
-
|
8
|
-
before do
|
9
|
-
allow_message_expectations_on_nil
|
10
|
-
allow(content).to receive(:essence).and_return(essence)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'render_essence' do
|
14
|
-
subject { render_essence(content) }
|
15
|
-
|
16
|
-
it "renders an essence view partial" do
|
17
|
-
is_expected.to have_content 'hello!'
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'with editor given as view part' do
|
21
|
-
subject { helper.render_essence(content, :editor) }
|
22
|
-
|
23
|
-
before do
|
24
|
-
allow(helper).to receive(:content_label)
|
25
|
-
allow(content).to receive(:settings).and_return({})
|
26
|
-
end
|
27
|
-
|
28
|
-
it "renders an essence editor partial" do
|
29
|
-
expect(content).to receive(:form_field_name)
|
30
|
-
is_expected.to have_selector 'input[type="text"]'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'if content is nil' do
|
35
|
-
let(:content) { nil }
|
36
|
-
|
37
|
-
it "returns empty string" do
|
38
|
-
is_expected.to eq('')
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'editor given as part' do
|
42
|
-
subject { helper.render_essence(content, :editor) }
|
43
|
-
|
44
|
-
before { allow(Alchemy).to receive(:t).and_return('') }
|
45
|
-
|
46
|
-
it "displays warning" do
|
47
|
-
expect(helper).to receive(:warning).and_return('')
|
48
|
-
is_expected.to eq('')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'if essence is nil' do
|
54
|
-
let(:essence) { nil }
|
55
|
-
|
56
|
-
it "returns empty string" do
|
57
|
-
is_expected.to eq('')
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'editor given as part' do
|
61
|
-
subject { helper.render_essence(content, :editor) }
|
62
|
-
|
63
|
-
before { allow(Alchemy).to receive(:t).and_return('') }
|
64
|
-
|
65
|
-
it "displays warning" do
|
66
|
-
expect(helper).to receive(:warning).and_return('')
|
67
|
-
is_expected.to eq('')
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe 'render_essence_view' do
|
74
|
-
it "renders an essence view partial" do
|
75
|
-
expect(render_essence_view(content)).to have_content 'hello!'
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "render_essence_view_by_name" do
|
80
|
-
it "renders an essence view partial by content name" do
|
81
|
-
expect(element).to receive(:content_by_name).and_return(content)
|
82
|
-
expect(render_essence_view_by_name(element, 'intro')).to have_content 'hello!'
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,499 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
module Alchemy
|
5
|
-
describe PagesHelper do
|
6
|
-
# Fixtures
|
7
|
-
let(:language) { mock_model('Language', code: 'en') }
|
8
|
-
let(:default_language) { Language.default }
|
9
|
-
let(:language_root) { create(:alchemy_page, :language_root) }
|
10
|
-
let(:public_page) { create(:alchemy_page, :public) }
|
11
|
-
let(:visible_page) { create(:alchemy_page, :public, visible: true) }
|
12
|
-
let(:restricted_page) { create(:alchemy_page, :public, visible: true, restricted: true) }
|
13
|
-
let(:level_2_page) { create(:alchemy_page, :public, parent_id: visible_page.id, visible: true, name: 'Level 2') }
|
14
|
-
let(:level_3_page) { create(:alchemy_page, :public, parent_id: level_2_page.id, visible: true, name: 'Level 3') }
|
15
|
-
let(:level_4_page) { create(:alchemy_page, :public, parent_id: level_3_page.id, visible: true, name: 'Level 4') }
|
16
|
-
let(:klingon) { create(:alchemy_language, :klingon) }
|
17
|
-
let(:klingon_language_root) { create(:alchemy_page, :language_root, language: klingon) }
|
18
|
-
let(:klingon_public_page) { create(:alchemy_page, :public, language: klingon, parent_id: klingon_language_root.id) }
|
19
|
-
|
20
|
-
before do
|
21
|
-
helper.controller.class_eval { include Alchemy::ConfigurationMethods }
|
22
|
-
allow(Config).to receive(:get) { |arg| arg == :url_nesting ? true : Config.parameter(arg) }
|
23
|
-
@root_page = language_root # We need this instance variable in the helpers
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#render_page_layout" do
|
27
|
-
it "should render the current page layout" do
|
28
|
-
@page = public_page
|
29
|
-
expect(helper.render_page_layout).to have_selector('div#content')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#render_site_layout' do
|
34
|
-
let(:default_site) { Alchemy::Site.default }
|
35
|
-
|
36
|
-
it "renders the partial for current site" do
|
37
|
-
expect(helper).to receive(:current_alchemy_site).and_return(default_site)
|
38
|
-
expect(helper).to receive(:render).with(default_site)
|
39
|
-
helper.render_site_layout
|
40
|
-
end
|
41
|
-
|
42
|
-
context "with missing partial" do
|
43
|
-
it "returns empty string and logges warning" do
|
44
|
-
expect(helper).to receive(:current_alchemy_site).twice.and_return(default_site)
|
45
|
-
expect(helper.render_site_layout).to eq("")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#render_navigation" do
|
51
|
-
let(:user) { nil }
|
52
|
-
|
53
|
-
before do
|
54
|
-
visible_page
|
55
|
-
allow(helper).to receive(:current_ability).and_return(Alchemy::Permissions.new(user))
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should render only visible pages" do
|
59
|
-
not_visible_page = create(:alchemy_page, visible: false)
|
60
|
-
expect(helper.render_navigation).not_to match(/#{not_visible_page.name}/)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should render visible unpublished pages" do
|
64
|
-
unpublished_visible_page = create(:alchemy_page, visible: true, public: false)
|
65
|
-
expect(helper.render_navigation).to match(/#{unpublished_visible_page.name}/)
|
66
|
-
end
|
67
|
-
|
68
|
-
context "not in multi_language mode" do
|
69
|
-
before { allow(helper).to receive(:multi_language?).and_return(false) }
|
70
|
-
|
71
|
-
it "should render the page navigation" do
|
72
|
-
expect(helper.render_navigation).to have_selector("ul.navigation.level_1 li.#{visible_page.urlname} a[href=\"/#{visible_page.urlname}\"]")
|
73
|
-
end
|
74
|
-
|
75
|
-
context "as guest user" do
|
76
|
-
before { restricted_page }
|
77
|
-
|
78
|
-
it "should not render restricted pages" do
|
79
|
-
expect(helper.render_navigation).not_to have_selector("ul.navigation.level_1 li a[href=\"/#{restricted_page.urlname}\"]")
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context "as member user" do
|
84
|
-
let(:user) { build(:alchemy_dummy_user) }
|
85
|
-
|
86
|
-
before { restricted_page }
|
87
|
-
|
88
|
-
it "should render also restricted pages" do
|
89
|
-
not_restricted_page = create(:alchemy_page, :public, restricted: false, visible: true)
|
90
|
-
expect(helper.render_navigation).to match(/#{restricted_page.name}/)
|
91
|
-
expect(helper.render_navigation).to match(/#{not_restricted_page.name}/)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context "with enabled url nesting" do
|
96
|
-
before do
|
97
|
-
allow(helper).to receive(:configuration).and_return(true)
|
98
|
-
level_3_page
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should render nested page links" do
|
102
|
-
expect(helper.render_navigation(all_sub_menues: true)).to have_selector("ul li a[href=\"/#{level_3_page.urlname}\"]")
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context "with id and class in the html options" do
|
108
|
-
it "should append id to the generated ul tag" do
|
109
|
-
expect(helper.render_navigation({}, {id: 'foobar_id'})).to have_selector("ul[id='foobar_id']")
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should replace the default css class from the generated ul tag" do
|
113
|
-
expect(helper.render_navigation({}, {class: 'foobar_class'})).to have_selector("ul[class='foobar_class']")
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context "with options[:deepness] set" do
|
118
|
-
before { level_3_page }
|
119
|
-
|
120
|
-
it "shows only pages up to this depth" do
|
121
|
-
output = helper.render_navigation(deepness: 3, all_sub_menues: true)
|
122
|
-
expect(output).to have_selector("ul li a[href=\"/#{level_2_page.urlname}\"]")
|
123
|
-
expect(output).not_to have_selector("ul li a[href=\"/#{level_3_page.urlname}\"]")
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
context "with options[:spacer] set" do
|
128
|
-
before { visible_page }
|
129
|
-
|
130
|
-
context "with two pages on same level" do
|
131
|
-
before { create(:alchemy_page, :public, visible: true) }
|
132
|
-
|
133
|
-
it "should render the given spacer" do
|
134
|
-
expect(helper.render_navigation(spacer: '•')).to match(/•/)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context "only one page in current level" do
|
139
|
-
it "should not render the spacer" do
|
140
|
-
expect(helper.render_navigation(spacer: '•')).not_to match(/•/)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context "with options[:from_page] set" do
|
146
|
-
before { level_2_page }
|
147
|
-
|
148
|
-
context "passing a page object" do
|
149
|
-
it "should render the pages underneath the given one" do
|
150
|
-
output = helper.render_navigation(from_page: visible_page)
|
151
|
-
expect(output).not_to have_selector("ul li a[href=\"/#{visible_page.urlname}\"]")
|
152
|
-
expect(output).to have_selector("ul li a[href=\"/#{level_2_page.urlname}\"]")
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
context "passing a page_layout" do
|
157
|
-
it "should render the pages underneath the page with the given page_layout" do
|
158
|
-
allow(helper).to receive(:page_or_find).with('contact').and_return(visible_page)
|
159
|
-
output = helper.render_navigation(from_page: 'contact')
|
160
|
-
expect(output).not_to have_selector("ul li a[href=\"/#{visible_page.urlname}\"]")
|
161
|
-
expect(output).to have_selector("ul li a[href=\"/#{level_2_page.urlname}\"]")
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
context "passing a page_layout of a not existing page" do
|
166
|
-
it "should render nothing" do
|
167
|
-
expect(helper.render_navigation(from_page: 'news')).to be_nil
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
describe '#render_subnavigation' do
|
174
|
-
let(:user) { nil }
|
175
|
-
|
176
|
-
before {
|
177
|
-
allow(helper).to receive(:multi_language?).and_return(false)
|
178
|
-
allow(helper).to receive(:current_ability).and_return(Alchemy::Permissions.new(user))
|
179
|
-
}
|
180
|
-
|
181
|
-
it "should return nil if no @page is set" do
|
182
|
-
expect(helper.render_subnavigation).to be(nil)
|
183
|
-
end
|
184
|
-
|
185
|
-
context "showing a page with level 2" do
|
186
|
-
before { @page = level_2_page }
|
187
|
-
|
188
|
-
it "should render the navigation from current page" do
|
189
|
-
expect(helper.render_subnavigation).to have_selector("ul > li > a[href='/#{level_2_page.urlname}']")
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should set current page active" do
|
193
|
-
expect(helper.render_subnavigation).to have_selector("a[href='/#{level_2_page.urlname}'].active")
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
context "showing a page with level 3" do
|
198
|
-
before { @page = level_3_page }
|
199
|
-
|
200
|
-
it "should render the navigation from current pages parent" do
|
201
|
-
expect(helper.render_subnavigation).to have_selector("ul > li > ul > li > a[href='/#{level_3_page.urlname}']")
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should set current page active" do
|
205
|
-
expect(helper.render_subnavigation).to have_selector("a[href='/#{level_3_page.urlname}'].active")
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
context "showing a page with level 4" do
|
210
|
-
before { @page = level_4_page }
|
211
|
-
|
212
|
-
it "should render the navigation from current pages parents parent" do
|
213
|
-
expect(helper.render_subnavigation).to have_selector("ul > li > ul > li > ul > li > a[href='/#{level_4_page.urlname}']")
|
214
|
-
end
|
215
|
-
|
216
|
-
it "should set current page active" do
|
217
|
-
expect(helper.render_subnavigation).to have_selector("a[href='/#{level_4_page.urlname}'].active")
|
218
|
-
end
|
219
|
-
|
220
|
-
context "beginning with level 3" do
|
221
|
-
it "should render the navigation beginning from its parent" do
|
222
|
-
expect(helper.render_subnavigation(level: 3)).to have_selector("ul > li > ul > li > a[href='/#{level_4_page.urlname}']")
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
describe "#render_breadcrumb" do
|
229
|
-
let(:parent) { create(:alchemy_page, :public, visible: true) }
|
230
|
-
let(:page) { create(:alchemy_page, :public, parent_id: parent.id, visible: true) }
|
231
|
-
let(:user) { nil }
|
232
|
-
|
233
|
-
before do
|
234
|
-
allow(helper).to receive(:multi_language?).and_return(false)
|
235
|
-
allow(helper).to receive(:current_ability).and_return(Alchemy::Permissions.new(user))
|
236
|
-
end
|
237
|
-
|
238
|
-
it "should render a breadcrumb to current page" do
|
239
|
-
expect(helper.render_breadcrumb(page: page)).to have_selector(".active.last[contains('#{page.name}')]")
|
240
|
-
end
|
241
|
-
|
242
|
-
context "with options[:separator] given" do
|
243
|
-
it "should render a breadcrumb with an alternative separator" do
|
244
|
-
expect(helper.render_breadcrumb(page: page, separator: '<span>###</span>')).to have_selector('span[contains("###")]')
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
context "with options[:reverse] set to true" do
|
249
|
-
it "should render a breadcrumb in reversed order" do
|
250
|
-
expect(helper.render_breadcrumb(page: page, reverse: true)).to have_selector('.active.first[contains("A Public Page")]')
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
context "with options[:restricted_only] set to true" do
|
255
|
-
let(:user) { build(:alchemy_dummy_user) }
|
256
|
-
|
257
|
-
it "should render a breadcrumb of restricted pages only" do
|
258
|
-
page.update_attributes!(restricted: true, urlname: 'a-restricted-public-page', name: 'A restricted Public Page', title: 'A restricted Public Page')
|
259
|
-
result = helper.render_breadcrumb(page: page, restricted_only: true).strip
|
260
|
-
expect(result).to have_selector("*[contains(\"#{page.name}\")]")
|
261
|
-
expect(result).to_not have_selector("*[contains(\"#{parent.name}\")]")
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
it "should render a breadcrumb of visible pages only" do
|
266
|
-
page.update_attributes!(visible: false, urlname: 'a-invisible-page', name: 'A Invisible Page', title: 'A Invisible Page')
|
267
|
-
expect(helper.render_breadcrumb(page: page)).not_to match(/A Invisible Page/)
|
268
|
-
end
|
269
|
-
|
270
|
-
it "should render a breadcrumb of visible and unpublished pages" do
|
271
|
-
page.update_attributes!(public: false, urlname: 'a-unpublic-page', name: 'A Unpublic Page', title: 'A Unpublic Page')
|
272
|
-
expect(helper.render_breadcrumb(page: page)).to match(/A Unpublic Page/)
|
273
|
-
end
|
274
|
-
|
275
|
-
context "with options[:without]" do
|
276
|
-
it "should render a breadcrumb without this page" do
|
277
|
-
page.update_attributes!(urlname: 'not-me', name: 'Not Me', title: 'Not Me')
|
278
|
-
expect(helper.render_breadcrumb(page: page, without: page)).not_to match(/Not Me/)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
context "with options[:without] as array" do
|
283
|
-
it "should render a breadcrumb without these pages." do
|
284
|
-
page.update_attributes!(urlname: 'not-me', name: 'Not Me', title: 'Not Me')
|
285
|
-
expect(helper.render_breadcrumb(page: page, without: [page])).not_to match(/Not Me/)
|
286
|
-
end
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
describe "#render_meta_data" do
|
291
|
-
let(:page) do
|
292
|
-
mock_model('Page',
|
293
|
-
language: language,
|
294
|
-
title: 'A Public Page',
|
295
|
-
meta_keywords: '',
|
296
|
-
meta_description: '',
|
297
|
-
robot_index?: false,
|
298
|
-
robot_follow?: false,
|
299
|
-
contains_feed?: false,
|
300
|
-
updated_at: '2011-11-29-23:00:00'
|
301
|
-
)
|
302
|
-
end
|
303
|
-
|
304
|
-
let(:root_page) { Page.new }
|
305
|
-
|
306
|
-
before { helper.instance_variable_set('@page', page) }
|
307
|
-
|
308
|
-
subject { helper.render_meta_data }
|
309
|
-
|
310
|
-
context "@page is not set" do
|
311
|
-
before { helper.instance_variable_set('@page', nil) }
|
312
|
-
|
313
|
-
it "should return nil" do
|
314
|
-
expect(helper.render_meta_data).to eq(nil)
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
|
-
context "when the current page's meta keywords are set" do
|
319
|
-
before { allow(page).to receive_messages(meta_keywords: 'keyword1, keyword2') }
|
320
|
-
|
321
|
-
it "should render them" do
|
322
|
-
is_expected.to match /meta name="keywords" content="keyword1, keyword2"/
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
context "when the current page's meta description is set" do
|
327
|
-
before { allow(page).to receive_messages(meta_description: 'blah blah') }
|
328
|
-
|
329
|
-
it "should render it" do
|
330
|
-
is_expected.to match /meta name="description" content="blah blah"/
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
|
-
context 'when the current page is missing its meta description' do
|
335
|
-
before { allow(Language).to receive(:current_root_page).and_return(root_page) }
|
336
|
-
|
337
|
-
it "should use the the one from the language root's page" do
|
338
|
-
root_page.meta_description = "root page's description"
|
339
|
-
is_expected.to match /meta name="description" content="root page's description"/
|
340
|
-
end
|
341
|
-
|
342
|
-
it "should not be set when language root's page is also missing one" do
|
343
|
-
is_expected.not_to match /meta name="description"/
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
context 'when the current page is missing its meta keywords' do
|
348
|
-
before { allow(Language).to receive(:current_root_page).and_return(root_page) }
|
349
|
-
|
350
|
-
it "should use the the one from the language root's page" do
|
351
|
-
root_page.meta_keywords = "root page's keywords"
|
352
|
-
is_expected.to match /meta name="keywords" content="root page's keywords"/
|
353
|
-
end
|
354
|
-
|
355
|
-
it "should not be set when language root's page is also missing one" do
|
356
|
-
is_expected.not_to match /meta name="keywords"/
|
357
|
-
end
|
358
|
-
end
|
359
|
-
end
|
360
|
-
|
361
|
-
describe "#render_title_tag" do
|
362
|
-
let(:page) { mock_model('Page', title: 'A Public Page') }
|
363
|
-
|
364
|
-
before { helper.instance_variable_set('@page', page) }
|
365
|
-
|
366
|
-
it "should render a title tag for current page" do
|
367
|
-
expect(helper.render_title_tag).to match /<title>A Public Page<\/title>/
|
368
|
-
end
|
369
|
-
|
370
|
-
it "should render a title tag for current page with a prefix and a separator" do
|
371
|
-
expect(helper.render_title_tag(prefix: 'Peters Petshop', separator: ' ### ')).to match /<title>Peters Petshop ### A Public Page<\/title>/
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
describe "#language_links" do
|
376
|
-
context "with two public languages" do
|
377
|
-
# Always create second language
|
378
|
-
before { klingon }
|
379
|
-
|
380
|
-
context "with only one language root page" do
|
381
|
-
it "should return nil" do
|
382
|
-
expect(helper.language_links).to be_nil
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
context "with two language root pages" do
|
387
|
-
# Always create a language root page for klingon
|
388
|
-
before { klingon_language_root }
|
389
|
-
|
390
|
-
it "should render two language links" do
|
391
|
-
expect(helper.language_links).to have_selector('a', count: 2)
|
392
|
-
end
|
393
|
-
|
394
|
-
it "should render language links referring to their language root page" do
|
395
|
-
code = klingon_language_root.language_code
|
396
|
-
urlname = klingon_language_root.urlname
|
397
|
-
expect(helper.language_links).to have_selector("a.#{code}[href='/#{code}/#{urlname}']")
|
398
|
-
end
|
399
|
-
|
400
|
-
context "with options[:linkname]" do
|
401
|
-
context "set to 'name'" do
|
402
|
-
it "should render the name of the language" do
|
403
|
-
expect(helper.language_links(linkname: 'name')).to have_selector("span[contains('#{klingon_language_root.language.name}')]")
|
404
|
-
end
|
405
|
-
end
|
406
|
-
|
407
|
-
context "set to 'code'" do
|
408
|
-
it "should render the code of the language" do
|
409
|
-
expect(helper.language_links(linkname: 'code')).to have_selector("span[contains('#{klingon_language_root.language.code}')]")
|
410
|
-
end
|
411
|
-
end
|
412
|
-
end
|
413
|
-
|
414
|
-
context "spacer set to '\o/'" do
|
415
|
-
it "should render the given string as a spacer" do
|
416
|
-
expect(helper.language_links(spacer: '<span>\o/</span>')).to have_selector('span[contains("\o/")]', count: 1)
|
417
|
-
end
|
418
|
-
end
|
419
|
-
|
420
|
-
context "with options[:reverse]" do
|
421
|
-
context "set to false" do
|
422
|
-
it "should render the language links in an ascending order" do
|
423
|
-
expect(helper.language_links(reverse: false)).to have_selector("a.en + a.kl")
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
context "set to true" do
|
428
|
-
it "should render the language links in a descending order" do
|
429
|
-
expect(helper.language_links(reverse: true)).to have_selector("a.kl + a.en")
|
430
|
-
end
|
431
|
-
end
|
432
|
-
end
|
433
|
-
|
434
|
-
context "with options[:show_title]" do
|
435
|
-
context "set to true" do
|
436
|
-
it "should render the language links with titles" do
|
437
|
-
allow(Alchemy).to receive(:t).and_return("my title")
|
438
|
-
expect(helper.language_links(show_title: true)).to have_selector('a[title="my title"]')
|
439
|
-
end
|
440
|
-
end
|
441
|
-
|
442
|
-
context "set to false" do
|
443
|
-
it "should render the language links without titles" do
|
444
|
-
expect(helper.language_links(show_title: false)).to_not have_selector('a[title]')
|
445
|
-
end
|
446
|
-
end
|
447
|
-
end
|
448
|
-
end
|
449
|
-
end
|
450
|
-
end
|
451
|
-
|
452
|
-
describe "#cell_empty" do
|
453
|
-
let(:cell) { create(:alchemy_cell, name: 'test_cell', page: public_page) }
|
454
|
-
let(:element) { create(:alchemy_element) }
|
455
|
-
|
456
|
-
before { @page = public_page }
|
457
|
-
|
458
|
-
context "with elements" do
|
459
|
-
before do
|
460
|
-
cell.elements << element
|
461
|
-
cell.save!
|
462
|
-
end
|
463
|
-
|
464
|
-
it "should return true" do
|
465
|
-
expect(helper.cell_empty?('test_cell')).to eq(false)
|
466
|
-
end
|
467
|
-
end
|
468
|
-
|
469
|
-
context "with zero elements" do
|
470
|
-
it "should return true" do
|
471
|
-
expect(helper.cell_empty?('test_cell')).to eq(true)
|
472
|
-
end
|
473
|
-
end
|
474
|
-
|
475
|
-
context "with trashed elements" do
|
476
|
-
before do
|
477
|
-
cell.elements << element
|
478
|
-
cell.save!
|
479
|
-
|
480
|
-
element.trash!
|
481
|
-
element.save!
|
482
|
-
end
|
483
|
-
|
484
|
-
it "should return true" do
|
485
|
-
expect(helper.cell_empty?('test_cell')).to eq(true)
|
486
|
-
end
|
487
|
-
end
|
488
|
-
end
|
489
|
-
|
490
|
-
describe "#picture_essence_caption" do
|
491
|
-
let(:essence) { mock_model('EssencePicture', caption: 'my caption') }
|
492
|
-
let(:content) { mock_model('Content', essence: essence) }
|
493
|
-
|
494
|
-
it "should return the caption of the contents essence" do
|
495
|
-
expect(helper.picture_essence_caption(content)).to eq "my caption"
|
496
|
-
end
|
497
|
-
end
|
498
|
-
end
|
499
|
-
end
|