alchemy_cms 2.2.4 → 2.3.rc5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/.travis.yml +3 -4
- data/Gemfile +1 -0
- data/README.md +10 -6
- data/alchemy_cms.gemspec +5 -2
- data/app/assets/images/alchemy/icons.png +0 -0
- data/app/assets/images/sassy-ie-overlay.png +0 -0
- data/app/assets/javascripts/alchemy/alchemy.base.js +50 -59
- data/app/assets/javascripts/alchemy/alchemy.buttons.js +14 -4
- data/app/assets/javascripts/alchemy/alchemy.datepicker.js +8 -2
- data/app/assets/javascripts/alchemy/alchemy.elements_window.js +11 -3
- data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +1 -1
- data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +14 -1
- data/app/assets/javascripts/alchemy/alchemy.preview.js +1 -1
- data/app/assets/javascripts/alchemy/alchemy.preview_window.js +12 -4
- data/app/assets/javascripts/alchemy/alchemy.uploader.js +4 -1
- data/app/assets/javascripts/alchemy/alchemy.windows.js +18 -8
- data/app/assets/stylesheets/alchemy/_defaults.scss +84 -120
- data/app/assets/stylesheets/alchemy/alchemy.css +2 -2
- data/app/assets/stylesheets/alchemy/archive.css.scss +288 -0
- data/app/assets/stylesheets/alchemy/base.css.scss +95 -390
- data/app/assets/stylesheets/alchemy/dashboard.css.scss +4 -4
- data/app/assets/stylesheets/alchemy/elements.css.scss +83 -118
- data/app/assets/stylesheets/alchemy/flash.css.scss +1 -1
- data/app/assets/stylesheets/alchemy/form_elements.css.scss +528 -0
- data/app/assets/stylesheets/alchemy/frame.css.scss +13 -39
- data/app/assets/stylesheets/alchemy/icons.css.scss +217 -228
- data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +48 -50
- data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
- data/app/assets/stylesheets/alchemy/login.css.scss +1 -5
- data/app/assets/stylesheets/alchemy/menubar.css.scss +19 -29
- data/app/assets/stylesheets/alchemy/pagination.css.scss +3 -4
- data/app/assets/stylesheets/alchemy/sitemap.css.scss +81 -81
- data/app/assets/stylesheets/alchemy/tables.css.scss +63 -57
- data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +57 -57
- data/app/assets/stylesheets/alchemy/upload.css.scss +6 -6
- data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.scss +6 -10
- data/app/controllers/alchemy/admin/attachments_controller.rb +5 -4
- data/app/controllers/alchemy/admin/base_controller.rb +1 -9
- data/app/controllers/alchemy/admin/contents_controller.rb +4 -6
- data/app/controllers/alchemy/admin/elements_controller.rb +2 -2
- data/app/controllers/alchemy/admin/pages_controller.rb +2 -2
- data/app/controllers/alchemy/admin/pictures_controller.rb +74 -15
- data/app/controllers/alchemy/attachments_controller.rb +8 -2
- data/app/controllers/alchemy/base_controller.rb +47 -5
- data/app/controllers/alchemy/elements_controller.rb +1 -1
- data/app/controllers/alchemy/messages_controller.rb +12 -12
- data/app/controllers/alchemy/pages_controller.rb +5 -1
- data/app/controllers/alchemy/pictures_controller.rb +9 -4
- data/app/controllers/alchemy/user_sessions_controller.rb +2 -4
- data/app/helpers/alchemy/admin/base_helper.rb +98 -19
- data/app/helpers/alchemy/admin/contents_helper.rb +2 -2
- data/app/helpers/alchemy/admin/elements_helper.rb +2 -3
- data/app/helpers/alchemy/base_helper.rb +6 -5
- data/app/helpers/alchemy/elements_helper.rb +2 -2
- data/app/helpers/alchemy/essences_helper.rb +4 -5
- data/app/helpers/alchemy/pages_helper.rb +15 -79
- data/app/helpers/alchemy/url_helper.rb +67 -0
- data/app/mailers/alchemy/messages.rb +1 -1
- data/app/mailers/alchemy/notifications.rb +1 -1
- data/app/models/alchemy/attachment.rb +11 -2
- data/app/models/alchemy/cell.rb +20 -10
- data/app/models/alchemy/content.rb +4 -3
- data/app/models/alchemy/element.rb +170 -178
- data/app/models/alchemy/language/code.rb +4 -1
- data/app/models/alchemy/message.rb +19 -3
- data/app/models/alchemy/page.rb +45 -40
- data/app/models/alchemy/picture.rb +24 -2
- data/app/models/alchemy/user.rb +2 -3
- data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +12 -12
- data/app/views/alchemy/admin/attachments/_attachment.html.erb +1 -1
- data/app/views/alchemy/admin/attachments/create.js.erb +1 -0
- data/app/views/alchemy/admin/attachments/edit.html.erb +9 -3
- data/app/views/alchemy/admin/attachments/index.html.erb +3 -2
- data/app/views/alchemy/admin/contents/_missing.html.erb +1 -1
- data/app/views/alchemy/admin/contents/create.js.erb +54 -0
- data/app/views/alchemy/admin/contents/new.html.erb +9 -4
- data/app/views/alchemy/admin/elements/{_add_content.html.erb → _add_picture.html.erb} +4 -4
- data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -1
- data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -1
- data/app/views/alchemy/admin/elements/{_picture_editor.html.erb → _picture_gallery_editor.html.erb} +7 -11
- data/app/views/alchemy/admin/elements/fold.js.erb +46 -0
- data/app/views/alchemy/admin/elements/index.html.erb +24 -24
- data/app/views/alchemy/admin/elements/list.js.erb +11 -9
- data/app/views/alchemy/admin/essence_files/assign.js.erb +3 -1
- data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +28 -0
- data/app/views/alchemy/admin/pages/_contactform_links.html.erb +8 -6
- data/app/views/alchemy/admin/pages/_external_link.html.erb +11 -9
- data/app/views/alchemy/admin/pages/_file_link.html.erb +10 -8
- data/app/views/alchemy/admin/pages/_internal_link.html.erb +14 -10
- data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_page_for_links.html.erb +32 -21
- data/app/views/alchemy/admin/pages/configure.html.erb +2 -2
- data/app/views/alchemy/admin/pages/configure_external.html.erb +13 -13
- data/app/views/alchemy/admin/pages/edit.html.erb +2 -2
- data/app/views/alchemy/admin/pages/index.html.erb +26 -24
- data/app/views/alchemy/admin/pages/link.html.erb +2 -5
- data/app/views/alchemy/admin/partials/_upload_form.html.erb +28 -12
- data/app/views/alchemy/admin/pictures/_archive.html.erb +54 -0
- data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +10 -7
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +21 -22
- data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +31 -0
- data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +9 -0
- data/app/views/alchemy/admin/pictures/_picture.html.erb +36 -6
- data/app/views/alchemy/admin/pictures/_tag_list.html.erb +27 -0
- data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +3 -1
- data/app/views/alchemy/admin/pictures/create.js.erb +4 -5
- data/app/views/alchemy/admin/pictures/edit.html.erb +26 -0
- data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +39 -0
- data/app/views/alchemy/admin/pictures/index.html.erb +81 -70
- data/app/views/alchemy/admin/pictures/index.js.erb +3 -0
- data/app/views/alchemy/admin/pictures/new.html.erb +1 -0
- data/app/views/alchemy/admin/resources/index.html.erb +3 -1
- data/app/views/alchemy/admin/users/_table.html.erb +1 -1
- data/app/views/alchemy/admin/users/index.html.erb +27 -23
- data/app/views/alchemy/elements/_article_editor.html.erb +7 -2
- data/app/views/alchemy/elements/_bild_editor.html.erb +1 -1
- data/app/views/alchemy/elements/_bild_text_editor.html.erb +6 -1
- data/app/views/alchemy/elements/_bild_text_view.html.erb +3 -3
- data/app/views/alchemy/elements/_image_mosaic_editor.html.erb +1 -1
- data/app/views/alchemy/elements/_image_mosaic_view.html.erb +2 -2
- data/app/views/alchemy/elements/_intro_image_text_view.html.erb +4 -4
- data/app/views/alchemy/elements/_searchresult_editor.html.erb +4 -1
- data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_picture_editor.html.erb +2 -3
- data/app/views/alchemy/essences/_essence_picture_tools.html.erb +1 -1
- data/app/views/alchemy/search/_form.html.erb +8 -0
- data/app/views/alchemy/search/_result.html.erb +3 -2
- data/app/views/alchemy/search/_results.html.erb +28 -0
- data/app/views/alchemy/user_sessions/leave.html.erb +4 -4
- data/app/views/alchemy/user_sessions/login.html.erb +1 -2
- data/app/views/layouts/alchemy/admin.html.erb +30 -10
- data/app/views/layouts/alchemy/login.html.erb +2 -39
- data/config/alchemy/elements.yml +1 -2
- data/config/alchemy/page_layouts.yml +8 -5
- data/config/authorization_rules.rb +27 -18
- data/config/initializers/localeapp.rb +9 -0
- data/config/locales/alchemy.de.yml +93 -56
- data/config/locales/alchemy.en.yml +73 -50
- data/config/routes.rb +3 -1
- data/db/migrate/20120704181529_add_upload_hash_to_alchemy_picture.rb +5 -0
- data/db/migrate/20120705214247_acts_as_taggable_on_migration.rb +28 -0
- data/db/migrate/20120728185830_add_cached_tag_list_to_alchemy_pictures.rb +5 -0
- data/db/migrate/20120831135441_set_alchemy_languages_country_code_default_to_empty_string.rb +9 -0
- data/lib/alchemy/capistrano.rb +2 -2
- data/lib/alchemy/essence.rb +14 -0
- data/lib/alchemy/page_layout.rb +0 -6
- data/lib/alchemy/resource.rb +9 -15
- data/lib/alchemy/upgrader.rb +18 -3
- data/lib/alchemy/version.rb +5 -1
- data/lib/alchemy_cms.rb +4 -1
- data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +16 -6
- data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +17 -3
- data/lib/rails/generators/alchemy/elements/elements_generator.rb +6 -1
- data/lib/rails/generators/alchemy/elements/templates/editor.html.erb +10 -1
- data/lib/rails/generators/alchemy/elements/templates/view.html.erb +17 -18
- data/lib/rails/generators/alchemy/scaffold/files/pages.html.erb +4 -2
- data/lib/tasks/fleximage.rake +2 -2
- data/spec/controllers/admin/contents_controller_spec.rb +2 -2
- data/spec/controllers/admin/elements_controller_spec.rb +30 -1
- data/spec/controllers/admin/pages_controller_spec.rb +35 -18
- data/spec/controllers/admin/trash_controller_spec.rb +40 -16
- data/spec/controllers/attachments_controller_spec.rb +62 -0
- data/spec/controllers/base_controller_spec.rb +43 -42
- data/spec/controllers/elements_controller_spec.rb +30 -0
- data/spec/controllers/pages_controller_spec.rb +22 -5
- data/spec/controllers/pictures_controller_spec.rb +82 -0
- data/spec/dummy/app/models/event.rb +2 -1
- data/spec/dummy/config/database.yml +3 -2
- data/spec/dummy/db/schema.rb +51 -27
- data/spec/factories.rb +29 -8
- data/spec/helpers/admin/base_helper_spec.rb +134 -21
- data/spec/helpers/admin/contents_helper_spec.rb +2 -2
- data/spec/helpers/admin/elements_helper_spec.rb +17 -9
- data/spec/helpers/admin/essences_helper_spec.rb +7 -6
- data/spec/helpers/essences_helper_spec.rb +8 -7
- data/spec/helpers/pages_helper_spec.rb +208 -325
- data/spec/helpers/url_helper_spec.rb +171 -0
- data/spec/integration/admin/link_overlay_spec.rb +53 -0
- data/spec/integration/admin/modules_integration_spec.rb +22 -26
- data/spec/integration/admin/pages_controller_spec.rb +10 -19
- data/spec/integration/admin/picture_library_integration_spec.rb +52 -0
- data/spec/integration/admin/resources_integration_spec.rb +68 -75
- data/spec/integration/pages_controller_spec.rb +70 -61
- data/spec/integration/security_spec.rb +3 -5
- data/spec/integration/translation_integration_spec.rb +56 -0
- data/spec/libraries/essence_spec.rb +18 -0
- data/spec/libraries/resource_spec.rb +101 -79
- data/spec/libraries/resources_helper_spec.rb +3 -0
- data/spec/models/content_spec.rb +63 -60
- data/spec/models/element_spec.rb +203 -93
- data/spec/models/language_spec.rb +90 -65
- data/spec/models/page_layout_spec.rb +37 -0
- data/spec/models/page_spec.rb +181 -113
- data/spec/models/picture_spec.rb +73 -26
- data/spec/models/resource_spec.rb +52 -23
- data/spec/support/alchemy/specs_helpers.rb +2 -0
- data/spec/support/image.png +0 -0
- data/spec/{helpers/url_helpers_spec.rb → url_helpers_spec.rb} +0 -0
- data/vendor/assets/javascripts/jquery_plugins/jquery.selectBoxIt.js +1909 -0
- data/vendor/assets/javascripts/jquery_plugins/preloadCssImages.jQuery_v5.js +152 -0
- metadata +106 -33
- data/app/assets/stylesheets/alchemy/buttons.css.scss +0 -361
- data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +0 -260
- data/app/views/alchemy/admin/contents/create.js.coffee +0 -49
- data/app/views/alchemy/admin/elements/fold.js.coffee +0 -37
- data/app/views/alchemy/admin/essence_pictures/destroy.js.coffee +0 -19
- data/app/views/alchemy/admin/pictures/_pictures_list.html.erb +0 -16
- data/app/views/alchemy/admin/pictures/update.js.erb +0 -3
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/locales/fo.yml +0 -5
- data/spec/page_layout_spec.rb +0 -35
- data/vendor/assets/javascripts/jquery_plugins/jquery.in-place-edit.js +0 -172
- data/vendor/assets/javascripts/jquery_plugins/jquery.sb.min.js +0 -14
@@ -1,41 +1,154 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
module Alchemy
|
4
|
+
module Admin
|
4
5
|
|
5
|
-
|
6
|
+
describe BaseHelper do
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
context "maximum amount of images option" do
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
@options = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
context "with max_images option" do
|
15
|
+
|
16
|
+
it "should return nil for empty string" do
|
17
|
+
@options[:max_images] = ""
|
18
|
+
max_image_count.should be(nil)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return an integer for string number" do
|
22
|
+
@options[:max_images] = "1"
|
23
|
+
max_image_count.should be(1)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with maximum_amount_of_images option" do
|
29
|
+
|
30
|
+
it "should return nil for empty string" do
|
31
|
+
@options[:maximum_amount_of_images] = ""
|
32
|
+
max_image_count.should be(nil)
|
33
|
+
end
|
10
34
|
|
11
|
-
|
35
|
+
it "should return an integer for string number" do
|
36
|
+
@options[:maximum_amount_of_images] = "1"
|
37
|
+
max_image_count.should be(1)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
12
41
|
|
13
|
-
it "should return nil for empty string" do
|
14
|
-
@options[:max_images] = ""
|
15
|
-
max_image_count.should be(nil)
|
16
42
|
end
|
17
43
|
|
18
|
-
|
19
|
-
|
20
|
-
|
44
|
+
describe "#merge_params" do
|
45
|
+
before(:each) do
|
46
|
+
controller.stub!(:params).and_return({:first => '1', :second => '2'})
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns a hash that contains the current params and additional params given as attributes" do
|
50
|
+
helper.merge_params(:third => '3', :fourth => '4').should == {:first => '1', :second => '2', :third => '3', :fourth => '4'}
|
51
|
+
end
|
21
52
|
end
|
22
53
|
|
23
|
-
|
54
|
+
describe "#merge_params_without" do
|
55
|
+
before(:each) do
|
56
|
+
controller.stub!(:params).and_return({:first => '1', :second => '2'})
|
57
|
+
end
|
58
|
+
it "can delete a single param" do
|
59
|
+
helper.merge_params_without(:second).should == {:first => '1'}
|
60
|
+
end
|
61
|
+
|
62
|
+
it "can delete several params" do
|
63
|
+
helper.merge_params_without([:first, :second]).should == {}
|
64
|
+
end
|
24
65
|
|
25
|
-
|
66
|
+
it "can delete a param and add new params at the same time" do
|
67
|
+
helper.merge_params_without([:first], {:third => '3'}).should == {:second => '2', :third => '3'}
|
68
|
+
end
|
26
69
|
|
27
|
-
|
28
|
-
|
29
|
-
|
70
|
+
it "should not change params" do
|
71
|
+
helper.merge_params_without([:first])
|
72
|
+
controller.params.should == {:first => '1', :second => '2'}
|
73
|
+
end
|
30
74
|
end
|
31
75
|
|
32
|
-
|
33
|
-
|
34
|
-
|
76
|
+
describe "#merge_params_only" do
|
77
|
+
|
78
|
+
before(:each) do
|
79
|
+
controller.stub!(:params).and_return({:first => '1', :second => '2', :third => '3'})
|
80
|
+
end
|
81
|
+
|
82
|
+
it "can keep a single param" do
|
83
|
+
helper.merge_params_only(:second).should == {:second => '2'}
|
84
|
+
end
|
85
|
+
|
86
|
+
it "can keep several params" do
|
87
|
+
helper.merge_params_only([:first, :second]).should == {:first => '1', :second => '2'}
|
88
|
+
end
|
89
|
+
|
90
|
+
it "can keep a param and add new params at the same time" do
|
91
|
+
helper.merge_params_only([:first], {:third => '3'}).should == {:first => '1', :third => '3'}
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should not change params" do
|
95
|
+
helper.merge_params_only([:first])
|
96
|
+
controller.params.should == {:first => '1', :second => '2', :third => '3'}
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
context "Filtering pictures depending on tags from params" do
|
102
|
+
|
103
|
+
let(:tag) do
|
104
|
+
mock_model(ActsAsTaggableOn::Tag, :name => "foo")
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#pictures_filtered_by_tag?" do
|
108
|
+
it "should return true if the filterlist contains the given tag" do
|
109
|
+
controller.params[:tagged_with] = "foo,bar,baz"
|
110
|
+
helper.pictures_filtered_by_tag?(tag).should == true
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should return false if the filterlist does not contain the given tag" do
|
114
|
+
controller.params[:tagged_with] = "bar,baz"
|
115
|
+
helper.pictures_filtered_by_tag?(tag).should == false
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#add_to_picture_tag_filter" do
|
120
|
+
context "if params[:tagged_with] is not present" do
|
121
|
+
it "should return an Array with the given tag name" do
|
122
|
+
helper.add_to_picture_tag_filter(tag).should == ["foo"]
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "if params[:tagged_with] contains some tag names" do
|
127
|
+
it "should return an Array of tag names including the given one" do
|
128
|
+
controller.params[:tagged_with] = "bar,baz"
|
129
|
+
helper.add_to_picture_tag_filter(tag).should == ["bar", "baz", "foo"]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "#remove_from_picture_tag_filter" do
|
135
|
+
context "if params[:tagged_with] is not present" do
|
136
|
+
it "should return an empty Array" do
|
137
|
+
helper.remove_from_picture_tag_filter(tag).should be_empty
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context "if params[:tagged_with] contains some tag names" do
|
142
|
+
it "should return an Array of tag names without the given one" do
|
143
|
+
controller.params[:tagged_with] = "bar,baz,foo"
|
144
|
+
helper.remove_from_picture_tag_filter(tag).should == ["bar", "baz"]
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
35
149
|
end
|
36
150
|
|
37
151
|
end
|
38
152
|
|
39
153
|
end
|
40
|
-
|
41
154
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Alchemy::Admin::ContentsHelper do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@element = FactoryGirl.create(:element, :name => 'article')
|
6
|
+
@element = FactoryGirl.create(:element, :name => 'article', :create_contents_after_create => true)
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should render a dom id" do
|
@@ -21,7 +21,7 @@ describe Alchemy::Admin::ContentsHelper do
|
|
21
21
|
|
22
22
|
it "should render a link to create a content in element" do
|
23
23
|
helper.stub!(:render_icon).and_return('')
|
24
|
-
helper.render_create_content_link(@element, 'headline').should match(/a.+href.*admin\/contents.+class.+
|
24
|
+
helper.render_create_content_link(@element, 'headline').should match(/a.+href.*admin\/contents.+class.+new_content_link.*data-method.+post/)
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -4,21 +4,29 @@ include Alchemy::BaseHelper
|
|
4
4
|
|
5
5
|
describe Alchemy::Admin::ElementsHelper do
|
6
6
|
|
7
|
-
|
8
|
-
@page = FactoryGirl.create(:public_page)
|
9
|
-
@element = FactoryGirl.create(:element, :page => @page)
|
10
|
-
end
|
7
|
+
context "partial rendering" do
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
before do
|
10
|
+
@page = FactoryGirl.create(:public_page)
|
11
|
+
@element = FactoryGirl.create(:element, :page => @page, :create_contents_after_create => true)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should render an element editor partial" do
|
15
|
+
helper.render_editor(@element).should match(/class="content_editor".+id="essence_text_\d{1,}"/)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should render a picture gallery editor partial" do
|
19
|
+
helper.render_picture_gallery_editor(@element).should match(/class=".+picture_gallery_editor"/)
|
20
|
+
end
|
15
21
|
|
16
|
-
it "should render a picture editor partial" do
|
17
|
-
helper.render_picture_editor(@element).should match(/class="essence_picture_editor"/)
|
18
22
|
end
|
19
23
|
|
20
24
|
describe "#grouped_elements_for_select" do
|
21
25
|
|
26
|
+
before do
|
27
|
+
@page = FactoryGirl.create(:public_page)
|
28
|
+
end
|
29
|
+
|
22
30
|
before(:each) do
|
23
31
|
@page.stub!(:layout_description).and_return({'name' => "foo", 'cells' => ["foo_cell"]})
|
24
32
|
cell_descriptions = [{'name' => "foo_cell", 'elements' => ["1", "2"]}]
|
@@ -2,22 +2,23 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Alchemy::Admin::EssencesHelper do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
let(:element) { FactoryGirl.create(:element, :name => 'article', :create_contents_after_create => true) }
|
6
|
+
|
7
|
+
before do
|
8
|
+
element.content_by_name('intro').essence.update_attributes(:body => 'hello!')
|
8
9
|
end
|
9
10
|
|
10
11
|
it "should render an essence editor" do
|
11
|
-
content =
|
12
|
+
content = element.content_by_name('intro')
|
12
13
|
helper.render_essence_editor(content).should match(/input.+type="text".+value="hello!/)
|
13
14
|
end
|
14
15
|
|
15
16
|
it "should render an essence editor by name" do
|
16
|
-
helper.render_essence_editor_by_name(
|
17
|
+
helper.render_essence_editor_by_name(element, 'intro').should match(/input.+type="text".+value="hello!/)
|
17
18
|
end
|
18
19
|
|
19
20
|
it "should render an essence editor by type" do
|
20
|
-
helper.render_essence_editor_by_type(
|
21
|
+
helper.render_essence_editor_by_type(element, 'EssenceText').should match(/input.+type="text".+value="hello!/)
|
21
22
|
end
|
22
23
|
|
23
24
|
end
|
@@ -2,27 +2,28 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Alchemy::EssencesHelper do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
let(:element) { FactoryGirl.create(:element, :create_contents_after_create => true) }
|
6
|
+
|
7
|
+
before do
|
8
|
+
element.content_by_name('intro').essence.update_attributes(:body => 'hello!')
|
8
9
|
end
|
9
10
|
|
10
11
|
it "should render an essence" do
|
11
|
-
content =
|
12
|
+
content = element.content_by_name('intro')
|
12
13
|
render_essence(content).should match(/hello!/)
|
13
14
|
end
|
14
15
|
|
15
16
|
it "should render an essence view" do
|
16
|
-
content =
|
17
|
+
content = element.content_by_name('intro')
|
17
18
|
render_essence_view(content).should match(/hello!/)
|
18
19
|
end
|
19
20
|
|
20
21
|
it "should render an essence view by name" do
|
21
|
-
render_essence_view_by_name(
|
22
|
+
render_essence_view_by_name(element, 'intro').should match(/hello!/)
|
22
23
|
end
|
23
24
|
|
24
25
|
it "should render an essence view by type" do
|
25
|
-
render_essence_view_by_type(
|
26
|
+
render_essence_view_by_type(element, 'EssenceText').should match(/hello!/)
|
26
27
|
end
|
27
28
|
|
28
29
|
end
|
@@ -2,424 +2,308 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
include Alchemy::BaseHelper
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
5
|
+
module Alchemy
|
6
|
+
describe PagesHelper do
|
7
|
+
|
8
|
+
# Fixtures
|
9
|
+
let(:language) { mock_model('Language', :code => 'en') }
|
10
|
+
let(:default_language) { Language.get_default }
|
11
|
+
let(:language_root) { FactoryGirl.create(:language_root_page) }
|
12
|
+
let(:public_page) { FactoryGirl.create(:public_page) }
|
13
|
+
let(:visible_page) { FactoryGirl.create(:public_page, :visible => true) }
|
14
|
+
let(:level_2_page) { FactoryGirl.create(:public_page, :parent_id => visible_page.id, :visible => true, :name => 'Level 2') }
|
15
|
+
let(:level_3_page) { FactoryGirl.create(:public_page, :parent_id => level_2_page.id, :visible => true, :name => 'Level 3') }
|
16
|
+
let(:level_4_page) { FactoryGirl.create(:public_page, :parent_id => level_3_page.id, :visible => true, :name => 'Level 4') }
|
17
|
+
let(:klingonian) { FactoryGirl.create(:klingonian) }
|
18
|
+
let(:klingonian_language_root) { FactoryGirl.create(:language_root_page, :language => klingonian) }
|
19
|
+
let(:klingonian_public_page) { FactoryGirl.create(:public_page, :language => klingonian, :parent_id => klingonian_language_root.id) }
|
20
|
+
|
21
|
+
before do
|
22
|
+
@root_page = language_root # We need this instance variable in the helpers
|
23
|
+
helper.stub(:configuration).and_return(false)
|
22
24
|
end
|
23
25
|
|
24
|
-
|
26
|
+
it "should render the current page layout" do
|
27
|
+
@page = public_page
|
28
|
+
helper.render_page_layout.should have_selector('div#content')
|
29
|
+
end
|
25
30
|
|
26
|
-
|
27
|
-
helper.stub(:multi_language?).and_return(false)
|
28
|
-
end
|
31
|
+
describe "#render_navigation" do
|
29
32
|
|
30
|
-
|
31
|
-
|
33
|
+
before do
|
34
|
+
visible_page
|
32
35
|
end
|
33
36
|
|
34
|
-
context "
|
37
|
+
context "not in multi_language mode" do
|
35
38
|
|
36
|
-
before
|
37
|
-
helper.stub
|
38
|
-
@level2 = FactoryGirl.create(:public_page, :parent_id => @page.id, :language => @language, :visible => true)
|
39
|
-
@level3 = FactoryGirl.create(:public_page, :parent_id => @level2.id, :language => @language, :visible => true)
|
39
|
+
before do
|
40
|
+
helper.stub(:multi_language?).and_return(false)
|
40
41
|
end
|
41
42
|
|
42
|
-
it "should render
|
43
|
-
helper.render_navigation
|
43
|
+
it "should render the page navigation" do
|
44
|
+
helper.render_navigation.should have_selector("ul.navigation.level_1 li.#{visible_page.urlname} a[href=\"/alchemy/#{visible_page.urlname}\"]")
|
44
45
|
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
context "with id and class in the html options" do
|
51
|
-
it "should append id to the generated ul tag" do
|
52
|
-
helper.render_navigation({}, {:id => 'foobar_id'}).should have_selector("ul[id='foobar_id']")
|
53
|
-
end
|
54
|
-
it "should replace the default css class from the generated ul tag" do
|
55
|
-
helper.render_navigation({}, {:class => 'foobar_class'}).should have_selector("ul[class='foobar_class']")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
describe '#render_subnavigation' do
|
62
|
-
|
63
|
-
before(:each) do
|
64
|
-
@language = Alchemy::Language.get_default
|
65
|
-
@language_root = FactoryGirl.create(:language_root_page, :language => @language, :name => 'Intro')
|
66
|
-
@level_1 = FactoryGirl.create(:public_page, :language => @language, :parent_id => @language_root.id, :visible => true, :name => 'Level 1')
|
67
|
-
@level_2 = FactoryGirl.create(:public_page, :language => @language, :parent_id => @level_1.id, :visible => true, :name => 'Level 2')
|
68
|
-
@level_3 = FactoryGirl.create(:public_page, :language => @language, :parent_id => @level_2.id, :visible => true, :name => 'Level 3')
|
69
|
-
@level_4 = FactoryGirl.create(:public_page, :language => @language, :parent_id => @level_3.id, :visible => true, :name => 'Level 4')
|
70
|
-
helper.stub(:multi_language?).and_return(false)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should return nil if no @page is set" do
|
74
|
-
helper.render_subnavigation.should be(nil)
|
75
|
-
end
|
47
|
+
context "with enabled url nesting" do
|
76
48
|
|
77
|
-
|
49
|
+
before do
|
50
|
+
helper.stub!(:configuration).and_return(true)
|
51
|
+
level_3_page
|
52
|
+
end
|
78
53
|
|
79
|
-
|
80
|
-
|
81
|
-
|
54
|
+
it "should render nested page links" do
|
55
|
+
helper.render_navigation(:all_sub_menues => true).should have_selector("ul li a[href=\"/alchemy/#{visible_page.urlname}/#{level_2_page.urlname}/#{level_3_page.urlname}\"]")
|
56
|
+
end
|
82
57
|
|
83
|
-
|
84
|
-
helper.render_subnavigation.should have_selector('ul > li > a[href="/alchemy/level-2"]')
|
85
|
-
end
|
58
|
+
end
|
86
59
|
|
87
|
-
it "should set current page active" do
|
88
|
-
helper.render_subnavigation.should have_selector('a[href="/alchemy/level-2"].active')
|
89
60
|
end
|
90
61
|
|
91
|
-
|
92
|
-
|
93
|
-
context "showing a page with level 3" do
|
62
|
+
context "with id and class in the html options" do
|
94
63
|
|
95
|
-
|
96
|
-
|
97
|
-
|
64
|
+
it "should append id to the generated ul tag" do
|
65
|
+
helper.render_navigation({}, {:id => 'foobar_id'}).should have_selector("ul[id='foobar_id']")
|
66
|
+
end
|
98
67
|
|
99
|
-
|
100
|
-
|
101
|
-
|
68
|
+
it "should replace the default css class from the generated ul tag" do
|
69
|
+
helper.render_navigation({}, {:class => 'foobar_class'}).should have_selector("ul[class='foobar_class']")
|
70
|
+
end
|
102
71
|
|
103
|
-
it "should set current page active" do
|
104
|
-
helper.render_subnavigation.should have_selector('a[href="/alchemy/level-3"].active')
|
105
72
|
end
|
106
73
|
|
107
74
|
end
|
108
75
|
|
109
|
-
|
76
|
+
describe '#render_subnavigation' do
|
110
77
|
|
111
|
-
before
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should render the navigation from current pages parents parent" do
|
116
|
-
helper.render_subnavigation.should have_selector('ul > li > ul > li > ul > li > a[href="/alchemy/level-4"]')
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should set current page active" do
|
120
|
-
helper.render_subnavigation.should have_selector('a[href="/alchemy/level-4"].active')
|
78
|
+
before do
|
79
|
+
helper.stub(:multi_language?).and_return(false)
|
121
80
|
end
|
122
81
|
|
123
|
-
|
124
|
-
|
125
|
-
it "should render the navigation beginning from its parent" do
|
126
|
-
helper.render_subnavigation(:level => 3).should have_selector('ul > li > ul > li > a[href="/alchemy/level-4"]')
|
127
|
-
end
|
128
|
-
|
82
|
+
it "should return nil if no @page is set" do
|
83
|
+
helper.render_subnavigation.should be(nil)
|
129
84
|
end
|
130
85
|
|
131
|
-
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
describe "#render_breadcrumb" do
|
136
|
-
|
137
|
-
before(:each) do
|
138
|
-
helper.stub(:multi_language?).and_return(false)
|
139
|
-
@root = mock_model('Page', :urlname => 'root', :name => 'Root', :title => 'Root', :visible? => false, :public? => false, :restricted? => false, :parent => nil)
|
140
|
-
@language_root = mock_model('Page', :urlname => 'language_root', :name => 'Language Root', :title => 'Language Root', :visible? => true, :public? => true, :restricted? => false, :parent => @root)
|
141
|
-
@page = mock_model('Page', :urlname => 'a-public-page', :name => 'A Public Page', :title => 'A Public Page', :visible? => true, :public? => true, :restricted? => false, :parent => @language_root)
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should render a breadcrumb to current page" do
|
145
|
-
helper.render_breadcrumb.should have_selector('a.active.last[href="/alchemy/a-public-page"]')
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should render a breadcrumb with a alternative seperator" do
|
149
|
-
helper.render_breadcrumb(:seperator => '<span>###</span>').should have_selector('span[contains("###")]')
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should render a breadcrumb in reversed order" do
|
153
|
-
helper.render_breadcrumb(:reverse => true).should have_selector('a.active.first[href="/alchemy/a-public-page"]')
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should render a breadcrumb of restricted pages only" do
|
157
|
-
@page.stub!(:restricted? => true, :urlname => 'a-restricted-public-page', :name => 'A restricted Public Page', :title => 'A restricted Public Page')
|
158
|
-
helper.render_breadcrumb(:restricted_only => true).should match(/^(<a(.[^>]+)>)A restricted Public Page/)
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should render a breadcrumb of visible pages only" do
|
162
|
-
@page.stub!(:visible? => false, :urlname => 'a-invisible-public-page', :name => 'A invisible Public Page', :title => 'A invisible Public Page')
|
163
|
-
helper.render_breadcrumb(:visible_only => true).should_not match(/A invisible Public Page/)
|
164
|
-
end
|
165
|
-
|
166
|
-
it "should render a breadcrumb of visible and invisible pages" do
|
167
|
-
@page.stub!(:visible? => false, :urlname => 'a-invisible-public-page', :name => 'A invisible Public Page', :title => 'A invisible Public Page')
|
168
|
-
helper.render_breadcrumb(:visible_only => false).should match(/A invisible Public Page/)
|
169
|
-
end
|
170
|
-
|
171
|
-
it "should render a breadcrumb of published pages only" do
|
172
|
-
@page.stub!(:public => false, :public? => false, :urlname => 'a-unpublic-page', :name => 'A Unpublic Page', :title => 'A Unpublic Page')
|
173
|
-
helper.render_breadcrumb(:public_only => true).should_not match(/A Unpublic Page/)
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should render a breadcrumb of published and unpublished pages" do
|
177
|
-
@page.stub!(:public => false, :public? => false, :urlname => 'a-unpublic-page', :name => 'A Unpublic Page', :title => 'A Unpublic Page')
|
178
|
-
helper.render_breadcrumb(:public_only => false).should match(/A Unpublic Page/)
|
179
|
-
end
|
180
|
-
|
181
|
-
it "should render a breadcrumb without the page named 'Not Me'" do
|
182
|
-
@page.stub!(:urlname => 'not-me', :name => 'Not Me', :title => 'Not Me')
|
183
|
-
helper.render_breadcrumb(:without => @page).should_not match(/Not Me/)
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
187
|
-
|
188
|
-
describe "using own url helpers" do
|
189
|
-
|
190
|
-
before(:each) do
|
191
|
-
@page = mock_model(Alchemy::Page, :urlname => 'testpage', :language_code => 'en')
|
192
|
-
end
|
193
|
-
|
194
|
-
describe "#show_page_path_params" do
|
195
|
-
|
196
|
-
context "when multi_language" do
|
86
|
+
context "showing a page with level 2" do
|
197
87
|
|
198
|
-
before
|
199
|
-
helper.stub!(:multi_language?).and_return(true)
|
200
|
-
end
|
88
|
+
before { @page = level_2_page }
|
201
89
|
|
202
|
-
it "should
|
203
|
-
helper.
|
204
|
-
helper.show_page_path_params(@page).should include(:urlname => 'testpage', :lang => 'en')
|
90
|
+
it "should render the navigation from current page" do
|
91
|
+
helper.render_subnavigation.should have_selector("ul > li > a[href='/alchemy/#{level_2_page.urlname}']")
|
205
92
|
end
|
206
93
|
|
207
|
-
it "should
|
208
|
-
helper.
|
209
|
-
helper.show_page_path_params(@page, {:query => 'test'}).should include(:urlname => 'testpage', :lang => 'en', :query => 'test')
|
94
|
+
it "should set current page active" do
|
95
|
+
helper.render_subnavigation.should have_selector("a[href='/alchemy/#{level_2_page.urlname}'].active")
|
210
96
|
end
|
211
97
|
|
212
98
|
end
|
213
99
|
|
214
|
-
context "
|
100
|
+
context "showing a page with level 3" do
|
215
101
|
|
216
|
-
before
|
217
|
-
helper.stub!(:multi_language?).and_return(false)
|
218
|
-
end
|
102
|
+
before { @page = level_3_page }
|
219
103
|
|
220
|
-
it "should
|
221
|
-
helper.
|
222
|
-
helper.show_page_path_params(@page).should_not include(:lang => 'en')
|
104
|
+
it "should render the navigation from current pages parent" do
|
105
|
+
helper.render_subnavigation.should have_selector("ul > li > ul > li > a[href='/alchemy/#{level_3_page.urlname}']")
|
223
106
|
end
|
224
107
|
|
225
|
-
it "should
|
226
|
-
helper.
|
227
|
-
helper.show_page_path_params(@page).should_not include(:lang => 'en')
|
108
|
+
it "should set current page active" do
|
109
|
+
helper.render_subnavigation.should have_selector("a[href='/alchemy/#{level_3_page.urlname}'].active")
|
228
110
|
end
|
229
111
|
|
230
112
|
end
|
231
113
|
|
232
|
-
|
233
|
-
|
234
|
-
describe "#show_alchemy_page_path" do
|
114
|
+
context "showing a page with level 4" do
|
235
115
|
|
236
|
-
|
116
|
+
before { @page = level_4_page }
|
237
117
|
|
238
|
-
|
239
|
-
helper.
|
118
|
+
it "should render the navigation from current pages parents parent" do
|
119
|
+
helper.render_subnavigation.should have_selector("ul > li > ul > li > ul > li > a[href='/alchemy/#{level_4_page.urlname}']")
|
240
120
|
end
|
241
121
|
|
242
|
-
it "should
|
243
|
-
helper.
|
122
|
+
it "should set current page active" do
|
123
|
+
helper.render_subnavigation.should have_selector("a[href='/alchemy/#{level_4_page.urlname}'].active")
|
244
124
|
end
|
245
125
|
|
246
|
-
|
247
|
-
helper.show_alchemy_page_path(@page, {:query => 'test'}).should == "/alchemy/#{@page.language_code}/testpage?query=test"
|
248
|
-
end
|
249
|
-
|
250
|
-
end
|
251
|
-
|
252
|
-
context "not multi_language" do
|
126
|
+
context "beginning with level 3" do
|
253
127
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
it "should return the correct relative path string" do
|
259
|
-
helper.show_alchemy_page_path(@page).should == "/alchemy/testpage"
|
260
|
-
end
|
128
|
+
it "should render the navigation beginning from its parent" do
|
129
|
+
helper.render_subnavigation(:level => 3).should have_selector("ul > li > ul > li > a[href='/alchemy/#{level_4_page.urlname}']")
|
130
|
+
end
|
261
131
|
|
262
|
-
it "should return the correct relative path string with additional parameter" do
|
263
|
-
helper.show_alchemy_page_path(@page, {:query => 'test'}).should == "/alchemy/testpage?query=test"
|
264
132
|
end
|
265
133
|
|
266
134
|
end
|
267
135
|
|
268
136
|
end
|
269
137
|
|
270
|
-
describe "#
|
271
|
-
|
272
|
-
context "when multi_language" do
|
138
|
+
describe "#render_breadcrumb" do
|
273
139
|
|
274
|
-
|
275
|
-
|
276
|
-
|
140
|
+
before do
|
141
|
+
helper.stub(:multi_language?).and_return(false)
|
142
|
+
@root = mock_model('Page', :urlname => 'root', :name => 'Root', :title => 'Root', :visible? => false, :public? => false, :restricted? => false, :parent => nil)
|
143
|
+
@language_root = mock_model('Page', :urlname => 'language_root', :name => 'Language Root', :title => 'Language Root', :visible? => true, :public? => true, :restricted? => false, :parent => @root)
|
144
|
+
@page = mock_model('Page', :urlname => 'a-public-page', :name => 'A Public Page', :title => 'A Public Page', :visible? => true, :public? => true, :restricted? => false, :parent => @language_root)
|
145
|
+
end
|
277
146
|
|
278
|
-
|
279
|
-
|
280
|
-
|
147
|
+
it "should render a breadcrumb to current page" do
|
148
|
+
helper.render_breadcrumb.should have_selector('.active.last[contains("A Public Page")]')
|
149
|
+
end
|
281
150
|
|
282
|
-
|
283
|
-
|
284
|
-
|
151
|
+
it "should render a breadcrumb with a alternative seperator" do
|
152
|
+
helper.render_breadcrumb(:seperator => '<span>###</span>').should have_selector('span[contains("###")]')
|
153
|
+
end
|
285
154
|
|
155
|
+
it "should render a breadcrumb in reversed order" do
|
156
|
+
helper.render_breadcrumb(:reverse => true).should have_selector('.active.first[contains("A Public Page")]')
|
286
157
|
end
|
287
158
|
|
288
|
-
|
159
|
+
it "should render a breadcrumb of restricted pages only" do
|
160
|
+
@page.stub!(:restricted? => true, :urlname => 'a-restricted-public-page', :name => 'A restricted Public Page', :title => 'A restricted Public Page')
|
161
|
+
helper.render_breadcrumb(:restricted_only => true).should match(/^(<span(.[^>]+)>)A restricted Public Page/)
|
162
|
+
end
|
289
163
|
|
290
|
-
|
291
|
-
|
292
|
-
|
164
|
+
it "should render a breadcrumb of visible pages only" do
|
165
|
+
@page.stub!(:visible? => false, :urlname => 'a-invisible-public-page', :name => 'A invisible Public Page', :title => 'A invisible Public Page')
|
166
|
+
helper.render_breadcrumb(:visible_only => true).should_not match(/A invisible Public Page/)
|
167
|
+
end
|
293
168
|
|
294
|
-
|
295
|
-
|
296
|
-
|
169
|
+
it "should render a breadcrumb of visible and invisible pages" do
|
170
|
+
@page.stub!(:visible? => false, :urlname => 'a-invisible-public-page', :name => 'A invisible Public Page', :title => 'A invisible Public Page')
|
171
|
+
helper.render_breadcrumb(:visible_only => false).should match(/A invisible Public Page/)
|
172
|
+
end
|
297
173
|
|
298
|
-
|
299
|
-
|
300
|
-
|
174
|
+
it "should render a breadcrumb of published pages only" do
|
175
|
+
@page.stub!(:public => false, :public? => false, :urlname => 'a-unpublic-page', :name => 'A Unpublic Page', :title => 'A Unpublic Page')
|
176
|
+
helper.render_breadcrumb(:public_only => true).should_not match(/A Unpublic Page/)
|
177
|
+
end
|
301
178
|
|
179
|
+
it "should render a breadcrumb of published and unpublished pages" do
|
180
|
+
@page.stub!(:public => false, :public? => false, :urlname => 'a-unpublic-page', :name => 'A Unpublic Page', :title => 'A Unpublic Page')
|
181
|
+
helper.render_breadcrumb(:public_only => false).should match(/A Unpublic Page/)
|
302
182
|
end
|
303
|
-
end
|
304
|
-
end
|
305
183
|
|
306
|
-
|
184
|
+
it "should render a breadcrumb without the page named 'Not Me'" do
|
185
|
+
@page.stub!(:urlname => 'not-me', :name => 'Not Me', :title => 'Not Me')
|
186
|
+
helper.render_breadcrumb(:without => @page).should_not match(/Not Me/)
|
187
|
+
end
|
307
188
|
|
308
|
-
let(:language) do
|
309
|
-
mock_model('Language', :code => 'en')
|
310
189
|
end
|
311
190
|
|
312
|
-
|
313
|
-
@page = mock_model('Page', :language => language, :title => 'A Public Page', :meta_description => '', :meta_keywords => 'keyword1, keyword2', :robot_index? => false, :robot_follow? => false, :contains_feed? => false, :updated_at => '2011-11-29-23:00:00')
|
314
|
-
helper.render_meta_data.should have_selector('meta[name="keywords"][content="keyword1, keyword2"]')
|
315
|
-
end
|
191
|
+
describe "#render_meta_data" do
|
316
192
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
end
|
193
|
+
it "should render meta keywords of current page" do
|
194
|
+
@page = mock_model('Page', :language => language, :title => 'A Public Page', :meta_description => '', :meta_keywords => 'keyword1, keyword2', :robot_index? => false, :robot_follow? => false, :contains_feed? => false, :updated_at => '2011-11-29-23:00:00')
|
195
|
+
helper.render_meta_data.should have_selector('meta[name="keywords"][content="keyword1, keyword2"]')
|
196
|
+
end
|
322
197
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
198
|
+
it "should render meta description 'blah blah' of current page" do
|
199
|
+
@page = mock_model('Page', :language => language, :title => 'A Public Page', :meta_description => 'blah blah', :meta_keywords => '', :robot_index? => false, :robot_follow? => false, :contains_feed? => false, :updated_at => '2011-11-29-23:00:00')
|
200
|
+
helper.render_meta_data.should have_selector('meta[name="description"][content="blah blah"]')
|
201
|
+
end
|
327
202
|
end
|
328
203
|
|
329
|
-
|
330
|
-
@page = mock_model('Page', :title => 'A Public Page')
|
331
|
-
helper.render_title_tag(:prefix => 'Peters Petshop', :seperator => ' ### ').should have_selector('title[contains("Peters Petshop ### A Public Page")]')
|
332
|
-
end
|
333
|
-
end
|
204
|
+
describe "#render_title_tag" do
|
334
205
|
|
335
|
-
|
206
|
+
it "should render a title tag for current page" do
|
207
|
+
@page = mock_model('Page', :title => 'A Public Page')
|
208
|
+
helper.render_title_tag.should have_selector('title[contains("A Public Page")]')
|
209
|
+
end
|
336
210
|
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
helper.stub(:multi_language?).and_return(true)
|
342
|
-
helper.stub(:configuration) { |arg| arg == :redirect_to_public_child ? true : false }
|
343
|
-
end
|
211
|
+
it "should render a title tag for current page with a prefix and a seperator" do
|
212
|
+
@page = mock_model('Page', :title => 'A Public Page')
|
213
|
+
helper.render_title_tag(:prefix => 'Peters Petshop', :seperator => ' ### ').should have_selector('title[contains("Peters Petshop ### A Public Page")]')
|
214
|
+
end
|
344
215
|
|
345
|
-
it "should return nil when having only one public language" do
|
346
|
-
helper.language_switcher.should be nil
|
347
216
|
end
|
348
217
|
|
349
|
-
|
218
|
+
describe "#language_switcher" do
|
350
219
|
|
351
|
-
before
|
352
|
-
|
353
|
-
|
220
|
+
before do
|
221
|
+
# simulates link_to_public_child = true
|
222
|
+
helper.stub(:multi_language?).and_return(true)
|
223
|
+
helper.stub(:configuration) { |arg| arg == :redirect_to_public_child ? true : false }
|
354
224
|
end
|
355
225
|
|
356
|
-
|
357
|
-
|
358
|
-
it "should return nil if only one language_root is public and both do not have children" do
|
359
|
-
@klingonian_language_root.update_attributes(:public => false)
|
360
|
-
helper.language_switcher.should == nil
|
361
|
-
end
|
362
|
-
|
363
|
-
it "should return nil if only one language_root is public and both have none public children" do
|
364
|
-
@klingonian_language_root.update_attributes(:public => false)
|
365
|
-
@default_first_public_child = FactoryGirl.create(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => false, :name => "child1")
|
366
|
-
@klingonian_first_public_child = FactoryGirl.create(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => false, :name => "child1")
|
367
|
-
helper.language_switcher.should == nil
|
368
|
-
end
|
369
|
-
|
370
|
-
it "should render two links when having two public language_root pages" do
|
371
|
-
helper.language_switcher.should have_selector('a', :count => 2)
|
372
|
-
end
|
373
|
-
|
374
|
-
it "should render two links when having just one public language_root but a public children in both language_roots" do
|
375
|
-
@klingonian_language_root.update_attributes(:public => false)
|
376
|
-
@default_first_public_child = FactoryGirl.create(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => true, :name => "child1")
|
377
|
-
@klingonian_first_public_child = FactoryGirl.create(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
|
378
|
-
helper.language_switcher.should have_selector('a', :count => 2)
|
379
|
-
end
|
380
|
-
|
381
|
-
it "should render two links when having two not public language_roots but a public children in both" do
|
382
|
-
@default_language_root.update_attributes(:public => false)
|
383
|
-
@klingonian_language_root.update_attributes(:public => false)
|
384
|
-
@default_first_public_child = FactoryGirl.create(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => true, :name => "child1")
|
385
|
-
@klingonian_first_public_child = FactoryGirl.create(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
|
386
|
-
helper.language_switcher.should have_selector('a', :count => 2)
|
387
|
-
end
|
388
|
-
|
389
|
-
it "should return nil when having two not public language_roots and a public children in only one of them" do
|
390
|
-
@default_language_root.update_attributes(:public => false)
|
391
|
-
@klingonian_language_root.update_attributes(:public => false)
|
392
|
-
@default_first_public_child = FactoryGirl.create(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => false, :name => "child1")
|
393
|
-
@klingonian_first_public_child = FactoryGirl.create(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
|
394
|
-
helper.language_switcher.should == nil
|
395
|
-
end
|
396
|
-
|
226
|
+
it "should return nil when having only one public language" do
|
227
|
+
helper.language_switcher.should be nil
|
397
228
|
end
|
398
229
|
|
399
|
-
context "
|
230
|
+
context "with two public languages and two language_roots" do
|
400
231
|
|
401
|
-
before
|
402
|
-
|
403
|
-
helper.stub(:configuration).and_return(false)
|
232
|
+
before do
|
233
|
+
language_root
|
404
234
|
end
|
405
235
|
|
406
|
-
|
407
|
-
|
408
|
-
|
236
|
+
context "and config redirect_to_public_child is set to TRUE" do
|
237
|
+
|
238
|
+
it "should return nil if only one language_root is public and both do not have children" do
|
239
|
+
klingonian_language_root.update_attributes(:public => false)
|
240
|
+
helper.language_switcher.should == nil
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should return nil if only one language_root is public and both have none public children" do
|
244
|
+
klingonian_language_root.update_attributes(:public => false)
|
245
|
+
FactoryGirl.create(:page)
|
246
|
+
FactoryGirl.create(:page, :language => klingonian, :parent_id => klingonian_language_root.id)
|
247
|
+
helper.language_switcher.should == nil
|
248
|
+
end
|
249
|
+
|
250
|
+
it "should render two links when having two public language_root pages" do
|
251
|
+
klingonian_language_root
|
252
|
+
helper.language_switcher.should have_selector('a', :count => 2)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should render two links when having just one public language_root but a public children in both language_roots" do
|
256
|
+
klingonian_language_root.update_attributes(:public => false)
|
257
|
+
public_page
|
258
|
+
klingonian_public_page
|
259
|
+
helper.language_switcher.should have_selector('a', :count => 2)
|
260
|
+
end
|
261
|
+
|
262
|
+
it "should render two links when having two not public language_roots but a public children in both" do
|
263
|
+
language_root.update_attributes(:public => false)
|
264
|
+
klingonian_language_root.update_attributes(:public => false)
|
265
|
+
public_page
|
266
|
+
klingonian_public_page
|
267
|
+
helper.language_switcher.should have_selector('a', :count => 2)
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should return nil when having two not public language_roots and a public children in only one of them" do
|
271
|
+
language_root.update_attributes(:public => false)
|
272
|
+
klingonian_language_root.update_attributes(:public => false)
|
273
|
+
FactoryGirl.create(:page)
|
274
|
+
klingonian_public_page
|
275
|
+
helper.language_switcher.should == nil
|
276
|
+
end
|
409
277
|
|
410
|
-
it "should render nil when having just one public language_root but a public children in both language_roots" do
|
411
|
-
@klingonian_language_root.update_attributes(:public => false)
|
412
|
-
@default_first_public_child = FactoryGirl.create(:page, :language => @default_language, :parent_id => @default_language_root.id, :public => true, :name => "child1")
|
413
|
-
@klingonian_first_public_child = FactoryGirl.create(:page, :language => @klingonian, :parent_id => @klingonian_language_root.id, :public => true, :name => "child1")
|
414
|
-
helper.language_switcher.should == nil
|
415
278
|
end
|
416
279
|
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
280
|
+
context "and config redirect_to_public_child is set to FALSE" do
|
281
|
+
|
282
|
+
before do
|
283
|
+
klingonian_language_root
|
284
|
+
# simulates link_to_public_child = false
|
285
|
+
helper.stub(:configuration).and_return(false)
|
286
|
+
end
|
287
|
+
|
288
|
+
it "should render two links when having two public language_root pages" do
|
289
|
+
helper.language_switcher.should have_selector('a', :count => 2)
|
290
|
+
end
|
291
|
+
|
292
|
+
it "should render nil when having just one public language_root but a public children in both language_roots" do
|
293
|
+
klingonian_language_root.update_attributes(:public => false)
|
294
|
+
public_page
|
295
|
+
klingonian_public_page
|
296
|
+
helper.language_switcher.should == nil
|
297
|
+
end
|
298
|
+
|
299
|
+
it "should render nil when having two not public language_roots but a public children in both" do
|
300
|
+
language_root.update_attributes(:public => false)
|
301
|
+
klingonian_language_root.update_attributes(:public => false)
|
302
|
+
public_page
|
303
|
+
klingonian_public_page
|
304
|
+
helper.language_switcher.should == nil
|
305
|
+
end
|
306
|
+
|
423
307
|
end
|
424
308
|
|
425
309
|
end
|
@@ -427,5 +311,4 @@ describe Alchemy::PagesHelper do
|
|
427
311
|
end
|
428
312
|
|
429
313
|
end
|
430
|
-
|
431
314
|
end
|