alchemy_cms 2.2.4 → 2.3.rc5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,96 +1,121 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
require 'spec_helper'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
module Alchemy
|
|
5
|
+
describe Language do
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
end
|
|
7
|
+
let(:language) { FactoryGirl.create(:klingonian) }
|
|
8
|
+
let(:page) { FactoryGirl.create(:page, :language => language) }
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
it "should return a label for code" do
|
|
11
|
+
language.label(:code).should == 'kl'
|
|
12
|
+
end
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
it "should return a label for name" do
|
|
15
|
+
language.label(:name).should == 'Klingonian'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context "with language_code and empty country_code" do
|
|
19
|
+
|
|
20
|
+
it "#code should return language locale only" do
|
|
21
|
+
language.country_code = ''
|
|
22
|
+
language.code.should == 'kl'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context "adding a value for country code" do
|
|
17
26
|
|
|
18
|
-
|
|
27
|
+
it "#code should return a joined locale" do
|
|
28
|
+
language.country_code = 'cr'
|
|
29
|
+
language.code.should == 'kl-cr'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should update all associated Pages with self.code as value for Page#language_code" do
|
|
33
|
+
page = FactoryGirl.create(:page, :language => language)
|
|
34
|
+
language.country_code = 'cr'
|
|
35
|
+
language.save
|
|
36
|
+
page.reload; page.language_code.should == 'kl-cr'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
19
39
|
|
|
20
|
-
it "#code should return language locale only" do
|
|
21
|
-
@language.country_code = ''
|
|
22
|
-
@language.code.should == 'kl'
|
|
23
40
|
end
|
|
24
41
|
|
|
25
|
-
context "
|
|
42
|
+
context "with country_code and_language_code" do
|
|
43
|
+
|
|
44
|
+
context "removing the country_code" do
|
|
45
|
+
|
|
46
|
+
it "should update all associated Pages´s language_code with Language#code" do
|
|
47
|
+
language = FactoryGirl.create(:language, :country_code => 'kl')
|
|
48
|
+
|
|
49
|
+
language.country_code = ''
|
|
50
|
+
language.save
|
|
51
|
+
page.reload; page.language_code.should == "kl"
|
|
52
|
+
end
|
|
26
53
|
|
|
27
|
-
it "#code should return a joined locale" do
|
|
28
|
-
@language.country_code = 'cr'
|
|
29
|
-
@language.code.should == 'kl-cr'
|
|
30
54
|
end
|
|
31
55
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should not be deletable if it is the default language" do
|
|
59
|
+
@default_language = Alchemy::Language.find_by_default(true)
|
|
60
|
+
if !@default_language
|
|
61
|
+
@default_language = FactoryGirl.create(:language, :name => "default", :code => "aa", :frontpage_name => "intro", :default => true)
|
|
37
62
|
end
|
|
63
|
+
expect { @default_language.destroy }.to raise_error
|
|
38
64
|
end
|
|
39
65
|
|
|
40
|
-
|
|
66
|
+
describe "before save" do
|
|
41
67
|
|
|
42
|
-
|
|
68
|
+
describe "#remove_old_default if default attribute has changed to true" do
|
|
69
|
+
|
|
70
|
+
it "should unset the default status of the old default-language" do
|
|
71
|
+
@default_language = Alchemy::Language.get_default
|
|
72
|
+
language.update_attributes(:default => true)
|
|
73
|
+
@default_language.reload
|
|
74
|
+
@default_language.default.should be(false)
|
|
75
|
+
end
|
|
43
76
|
|
|
44
|
-
context "removing the country_code" do
|
|
45
|
-
it "should update all associated Pages´s language_code with Language#code" do
|
|
46
|
-
language = FactoryGirl.create(:language_with_country_code)
|
|
47
|
-
@page = FactoryGirl.create(:page, :language => language)
|
|
48
|
-
language.country_code = ''
|
|
49
|
-
language.save
|
|
50
|
-
@page.reload; @page.language_code.should == "kl"
|
|
51
77
|
end
|
|
78
|
+
|
|
52
79
|
end
|
|
53
80
|
|
|
54
|
-
|
|
81
|
+
context "after_update" do
|
|
55
82
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
83
|
+
describe "#set_pages_language if language´s code has changed" do
|
|
84
|
+
|
|
85
|
+
it "should update all its pages with the new code" do
|
|
86
|
+
@other_page = FactoryGirl.create(:page, :language => language)
|
|
87
|
+
language.update_attributes(:code => "fo")
|
|
88
|
+
language.reload; page.reload; @other_page.reload
|
|
89
|
+
[page.language_code, @other_page.language_code].should == [language.code, language.code]
|
|
90
|
+
end
|
|
63
91
|
|
|
64
|
-
describe "before save" do
|
|
65
|
-
describe "#remove_old_default if default attribute has changed to true" do
|
|
66
|
-
it "should unset the default status of the old default-language" do
|
|
67
|
-
@default_language = Alchemy::Language.get_default
|
|
68
|
-
@language.update_attributes(:default => true)
|
|
69
|
-
@default_language.reload
|
|
70
|
-
@default_language.default.should be(false)
|
|
71
92
|
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
93
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
94
|
+
describe "#unpublish_pages" do
|
|
95
|
+
|
|
96
|
+
it "should set all pages to unpublic if it gets set to unpublic" do
|
|
97
|
+
page = FactoryGirl.create(:page, :language => language)
|
|
98
|
+
@other_page = FactoryGirl.create(:page, :language => language)
|
|
99
|
+
language.update_attributes(:public => false)
|
|
100
|
+
language.reload; page.reload; @other_page.reload
|
|
101
|
+
[page.public?, @other_page.public?].should == [false, false]
|
|
102
|
+
end
|
|
103
|
+
|
|
83
104
|
end
|
|
105
|
+
|
|
84
106
|
end
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
107
|
+
|
|
108
|
+
describe '.find_by_code' do
|
|
109
|
+
|
|
110
|
+
context "with only the language code given" do
|
|
111
|
+
|
|
112
|
+
it "should find the language" do
|
|
113
|
+
Language.find_by_code(language.code).should == language
|
|
114
|
+
end
|
|
115
|
+
|
|
92
116
|
end
|
|
117
|
+
|
|
93
118
|
end
|
|
94
|
-
end
|
|
95
119
|
|
|
120
|
+
end
|
|
96
121
|
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Alchemy
|
|
4
|
+
describe PageLayout do
|
|
5
|
+
|
|
6
|
+
context "method get_layouts" do
|
|
7
|
+
|
|
8
|
+
it "should generally return page_layouts, nothing else!" do
|
|
9
|
+
PageLayout.read_layouts_file.should be_instance_of(Array)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "with custom page layouts" do
|
|
15
|
+
|
|
16
|
+
it "should return the users page_layouts if exists in the application" do
|
|
17
|
+
@config_path = Rails.root.join("config/alchemy")
|
|
18
|
+
FileUtils.mv(File.join(@config_path, 'page_layouts.yml'), File.join(@config_path, 'page_layouts.bak'))
|
|
19
|
+
layouts_file = File.join(@config_path, 'page_layouts.yml')
|
|
20
|
+
File.open(layouts_file, 'w') do |page_layouts|
|
|
21
|
+
page_layouts.puts "- name: testlayout\n elements:"
|
|
22
|
+
end
|
|
23
|
+
PageLayout.read_layouts_file.first.values.should include("testlayout")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
after(:each) do
|
|
27
|
+
FileUtils.mv(File.join(@config_path, 'page_layouts.bak'), File.join(@config_path, 'page_layouts.yml'))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should not display hidden page layouts" do
|
|
33
|
+
PageLayout.selectable_layouts(Language.get_default).each { |e| e["hide"].should_not == true }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
data/spec/models/page_spec.rb
CHANGED
|
@@ -5,30 +5,30 @@ require 'spec_helper'
|
|
|
5
5
|
module Alchemy
|
|
6
6
|
describe Page do
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
let(:rootpage) { Page.root }
|
|
9
|
+
let(:language) { Language.get_default }
|
|
10
|
+
let(:klingonian) { FactoryGirl.create(:klingonian) }
|
|
11
|
+
let(:language_root) { FactoryGirl.create(:language_root_page) }
|
|
12
|
+
let(:page) { mock(:page, :page_layout => 'foo') }
|
|
13
|
+
let(:public_page) { FactoryGirl.create(:public_page) }
|
|
14
|
+
let(:news_page) { FactoryGirl.create(:public_page, :page_layout => 'news', :do_not_autogenerate => false) }
|
|
14
15
|
|
|
15
16
|
describe ".layout_description" do
|
|
16
17
|
|
|
17
18
|
context "for a language root page" do
|
|
18
19
|
|
|
19
20
|
it "should return the page layout description as hash" do
|
|
20
|
-
|
|
21
|
+
language_root.layout_description['name'].should == 'intro'
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
it "should return an empty hash for root page" do
|
|
24
|
-
|
|
25
|
+
rootpage.layout_description.should == {}
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
it "should raise Exception if the page_layout could not be found in the definition file" do
|
|
30
|
-
|
|
31
|
-
expect { @page.layout_description }.to raise_error
|
|
31
|
+
expect { page.layout_description }.to raise_error
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
end
|
|
@@ -38,45 +38,42 @@ module Alchemy
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "should return all rss feed elements" do
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
news_page.feed_elements.should_not be_empty
|
|
42
|
+
news_page.feed_elements.should == Element.find_all_by_name('news')
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
context "finding elements" do
|
|
46
46
|
|
|
47
|
-
before
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
FactoryGirl.create(:element, :public => false, :page => @page),
|
|
51
|
-
FactoryGirl.create(:element, :public => false, :page => @page)
|
|
52
|
-
]
|
|
47
|
+
before do
|
|
48
|
+
FactoryGirl.create(:element, :public => false, :page => public_page)
|
|
49
|
+
FactoryGirl.create(:element, :public => false, :page => public_page)
|
|
53
50
|
end
|
|
54
51
|
|
|
55
52
|
it "should return the collection of elements if passed an array into options[:collection]" do
|
|
56
|
-
options = {:collection =>
|
|
57
|
-
|
|
53
|
+
options = {:collection => public_page.elements}
|
|
54
|
+
public_page.find_elements(options).all.should == public_page.elements.all
|
|
58
55
|
end
|
|
59
56
|
|
|
60
57
|
context "with show_non_public argument TRUE" do
|
|
61
58
|
|
|
62
59
|
it "should return all elements from empty options" do
|
|
63
|
-
|
|
60
|
+
public_page.find_elements({}, true).all.should == public_page.elements.all
|
|
64
61
|
end
|
|
65
62
|
|
|
66
63
|
it "should only return the elements passed as options[:only]" do
|
|
67
|
-
|
|
64
|
+
public_page.find_elements({:only => ['article']}, true).all.should == public_page.elements.named('article').all
|
|
68
65
|
end
|
|
69
66
|
|
|
70
67
|
it "should not return the elements passed as options[:except]" do
|
|
71
|
-
|
|
68
|
+
public_page.find_elements({:except => ['article']}, true).all.should == public_page.elements - public_page.elements.named('article').all
|
|
72
69
|
end
|
|
73
70
|
|
|
74
71
|
it "should return elements offsetted" do
|
|
75
|
-
|
|
72
|
+
public_page.find_elements({:offset => 2}, true).all.should == public_page.elements.offset(2)
|
|
76
73
|
end
|
|
77
74
|
|
|
78
75
|
it "should return elements limitted in count" do
|
|
79
|
-
|
|
76
|
+
public_page.find_elements({:count => 1}, true).all.should == public_page.elements.limit(1)
|
|
80
77
|
end
|
|
81
78
|
|
|
82
79
|
end
|
|
@@ -84,23 +81,23 @@ module Alchemy
|
|
|
84
81
|
context "with show_non_public argument FALSE" do
|
|
85
82
|
|
|
86
83
|
it "should return all elements from empty arguments" do
|
|
87
|
-
|
|
84
|
+
public_page.find_elements().all.should == public_page.elements.published.all
|
|
88
85
|
end
|
|
89
86
|
|
|
90
87
|
it "should only return the public elements passed as options[:only]" do
|
|
91
|
-
|
|
88
|
+
public_page.find_elements(:only => ['article']).all.should == public_page.elements.published.named('article').all
|
|
92
89
|
end
|
|
93
90
|
|
|
94
91
|
it "should return all public elements except the ones passed as options[:except]" do
|
|
95
|
-
|
|
92
|
+
public_page.find_elements(:except => ['article']).all.should == public_page.elements.published.all - public_page.elements.published.named('article').all
|
|
96
93
|
end
|
|
97
94
|
|
|
98
95
|
it "should return elements offsetted" do
|
|
99
|
-
|
|
96
|
+
public_page.find_elements({:offset => 2}).all.should == public_page.elements.published.offset(2)
|
|
100
97
|
end
|
|
101
98
|
|
|
102
99
|
it "should return elements limitted in count" do
|
|
103
|
-
|
|
100
|
+
public_page.find_elements({:count => 1}).all.should == public_page.elements.published.limit(1)
|
|
104
101
|
end
|
|
105
102
|
|
|
106
103
|
end
|
|
@@ -112,32 +109,32 @@ module Alchemy
|
|
|
112
109
|
context "before/after filter" do
|
|
113
110
|
|
|
114
111
|
it "should automatically set the title from its name" do
|
|
115
|
-
page = FactoryGirl.create(:page, :name => 'My Testpage', :language =>
|
|
112
|
+
page = FactoryGirl.create(:page, :name => 'My Testpage', :language => language, :parent_id => language_root.id)
|
|
116
113
|
page.title.should == 'My Testpage'
|
|
117
114
|
end
|
|
118
115
|
|
|
119
116
|
it "should get a webfriendly urlname" do
|
|
120
|
-
page = FactoryGirl.create(:page, :name => 'klingon$&stößel ', :language =>
|
|
117
|
+
page = FactoryGirl.create(:page, :name => 'klingon$&stößel ', :language => language, :parent_id => language_root.id)
|
|
121
118
|
page.urlname.should == 'klingon-stoessel'
|
|
122
119
|
end
|
|
123
120
|
|
|
124
121
|
it "should generate a three letter urlname from two letter name" do
|
|
125
|
-
page = FactoryGirl.create(:page, :name => 'Au', :language =>
|
|
122
|
+
page = FactoryGirl.create(:page, :name => 'Au', :language => language, :parent_id => language_root.id)
|
|
126
123
|
page.urlname.should == '-au'
|
|
127
124
|
end
|
|
128
125
|
|
|
129
126
|
it "should generate a three letter urlname from two letter name with umlaut" do
|
|
130
|
-
page = FactoryGirl.create(:page, :name => 'Aü', :language =>
|
|
127
|
+
page = FactoryGirl.create(:page, :name => 'Aü', :language => language, :parent_id => language_root.id)
|
|
131
128
|
page.urlname.should == 'aue'
|
|
132
129
|
end
|
|
133
130
|
|
|
134
131
|
it "should generate a three letter urlname from one letter name" do
|
|
135
|
-
page = FactoryGirl.create(:page, :name => 'A', :language =>
|
|
132
|
+
page = FactoryGirl.create(:page, :name => 'A', :language => language, :parent_id => language_root.id)
|
|
136
133
|
page.urlname.should == '--a'
|
|
137
134
|
end
|
|
138
135
|
|
|
139
136
|
it "should add a user stamper" do
|
|
140
|
-
page = FactoryGirl.create(:page, :name => 'A', :language =>
|
|
137
|
+
page = FactoryGirl.create(:page, :name => 'A', :language => language, :parent_id => language_root.id)
|
|
141
138
|
page.class.stamper_class.to_s.should == 'Alchemy::User'
|
|
142
139
|
end
|
|
143
140
|
|
|
@@ -150,14 +147,14 @@ module Alchemy
|
|
|
150
147
|
context "before/after filter" do
|
|
151
148
|
|
|
152
149
|
it "should not set the title automatically if the name changed but title is not blank" do
|
|
153
|
-
page = FactoryGirl.create(:page, :name => 'My Testpage', :language =>
|
|
150
|
+
page = FactoryGirl.create(:page, :name => 'My Testpage', :language => language, :parent_id => language_root.id)
|
|
154
151
|
page.name = "My Renaming Test"
|
|
155
152
|
page.save; page.reload
|
|
156
153
|
page.title.should == "My Testpage"
|
|
157
154
|
end
|
|
158
155
|
|
|
159
156
|
it "should not automatically set the title if it changed its value" do
|
|
160
|
-
page = FactoryGirl.create(:page, :name => 'My Testpage', :language =>
|
|
157
|
+
page = FactoryGirl.create(:page, :name => 'My Testpage', :language => language, :parent_id => language_root.id)
|
|
161
158
|
page.title = "I like SEO"
|
|
162
159
|
page.save; page.reload
|
|
163
160
|
page.title.should == "I like SEO"
|
|
@@ -167,38 +164,34 @@ module Alchemy
|
|
|
167
164
|
|
|
168
165
|
end
|
|
169
166
|
|
|
170
|
-
|
|
167
|
+
describe '#first_public_child' do
|
|
171
168
|
|
|
172
|
-
before
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
before do
|
|
170
|
+
FactoryGirl.create(:page, :name => "First child", :language => language, :public => false, :parent_id => language_root.id)
|
|
171
|
+
end
|
|
175
172
|
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
it "should return first_public_child" do
|
|
174
|
+
first_public_child = FactoryGirl.create(:public_page, :name => "First public child", :language => language, :parent_id => language_root.id)
|
|
175
|
+
language_root.first_public_child.should == first_public_child
|
|
178
176
|
end
|
|
179
177
|
|
|
180
|
-
it "should return
|
|
181
|
-
|
|
182
|
-
@language_root.first_public_child.should == @first_public_child
|
|
183
|
-
else
|
|
184
|
-
@language_root.first_public_child.should == nil
|
|
185
|
-
end
|
|
178
|
+
it "should return nil if no public child exists" do
|
|
179
|
+
language_root.first_public_child.should == nil
|
|
186
180
|
end
|
|
187
181
|
|
|
188
182
|
end
|
|
189
183
|
|
|
190
184
|
context ".contentpages" do
|
|
191
185
|
|
|
192
|
-
before
|
|
193
|
-
|
|
194
|
-
@
|
|
195
|
-
@
|
|
196
|
-
@
|
|
197
|
-
@contentpage = FactoryGirl.create(:public_page, :name => 'contentpage', :parent_id => @language_root.id, :language => @language)
|
|
186
|
+
before do
|
|
187
|
+
layoutroot = Page.find_or_create_layout_root_for(klingonian.id)
|
|
188
|
+
@layoutpage = FactoryGirl.create(:public_page, :name => 'layoutpage', :layoutpage => true, :parent_id => layoutroot.id, :language => klingonian)
|
|
189
|
+
@klingonian_lang_root = FactoryGirl.create(:language_root_page, :name => 'klingonian_lang_root', :layoutpage => nil, :language => klingonian)
|
|
190
|
+
@contentpage = FactoryGirl.create(:public_page, :name => 'contentpage', :parent_id => language_root.id, :language => language)
|
|
198
191
|
end
|
|
199
192
|
|
|
200
193
|
it "should return a collection of contentpages" do
|
|
201
|
-
Page.contentpages.to_a.should include(
|
|
194
|
+
Page.contentpages.to_a.should include(language_root, @klingonian_lang_root, @contentpage)
|
|
202
195
|
end
|
|
203
196
|
|
|
204
197
|
it "should not contain pages with attribute :layoutpage set to true" do
|
|
@@ -214,8 +207,8 @@ module Alchemy
|
|
|
214
207
|
context ".public" do
|
|
215
208
|
|
|
216
209
|
it "should return pages that are public" do
|
|
217
|
-
FactoryGirl.create(:public_page, :name => 'First Public Child', :parent_id =>
|
|
218
|
-
FactoryGirl.create(:public_page, :name => 'Second Public Child', :parent_id =>
|
|
210
|
+
FactoryGirl.create(:public_page, :name => 'First Public Child', :parent_id => language_root.id, :language => language)
|
|
211
|
+
FactoryGirl.create(:public_page, :name => 'Second Public Child', :parent_id => language_root.id, :language => language)
|
|
219
212
|
Page.published.should have(3).pages
|
|
220
213
|
end
|
|
221
214
|
|
|
@@ -224,22 +217,22 @@ module Alchemy
|
|
|
224
217
|
context ".not_locked" do
|
|
225
218
|
|
|
226
219
|
it "should return pages that are not blocked by a user at the moment" do
|
|
227
|
-
FactoryGirl.create(:public_page, :locked => true, :name => 'First Public Child', :parent_id =>
|
|
228
|
-
FactoryGirl.create(:public_page, :name => 'Second Public Child', :parent_id =>
|
|
220
|
+
FactoryGirl.create(:public_page, :locked => true, :name => 'First Public Child', :parent_id => language_root.id, :language => language)
|
|
221
|
+
FactoryGirl.create(:public_page, :name => 'Second Public Child', :parent_id => language_root.id, :language => language)
|
|
229
222
|
Page.not_locked.should have(3).pages
|
|
230
223
|
end
|
|
231
224
|
end
|
|
232
225
|
|
|
233
226
|
context ".all_locked" do
|
|
234
227
|
it "should return 1 page that is blocked by a user at the moment" do
|
|
235
|
-
FactoryGirl.create(:public_page, :locked => true, :name => 'First Public Child', :parent_id =>
|
|
228
|
+
FactoryGirl.create(:public_page, :locked => true, :name => 'First Public Child', :parent_id => language_root.id, :language => language)
|
|
236
229
|
Page.all_locked.should have(1).pages
|
|
237
230
|
end
|
|
238
231
|
end
|
|
239
232
|
|
|
240
233
|
context ".language_roots" do
|
|
241
234
|
it "should return 1 language_root" do
|
|
242
|
-
FactoryGirl.create(:public_page, :name => 'First Public Child', :parent_id =>
|
|
235
|
+
FactoryGirl.create(:public_page, :name => 'First Public Child', :parent_id => language_root.id, :language => language)
|
|
243
236
|
Page.language_roots.should have(1).pages
|
|
244
237
|
end
|
|
245
238
|
end
|
|
@@ -247,43 +240,43 @@ module Alchemy
|
|
|
247
240
|
|
|
248
241
|
context ".layoutpages" do
|
|
249
242
|
it "should return 1 layoutpage" do
|
|
250
|
-
FactoryGirl.create(:public_page, :layoutpage => true, :name => 'Layoutpage', :parent_id =>
|
|
243
|
+
FactoryGirl.create(:public_page, :layoutpage => true, :name => 'Layoutpage', :parent_id => rootpage.id, :language => language)
|
|
251
244
|
Page.layoutpages.should have(1).pages
|
|
252
245
|
end
|
|
253
246
|
end
|
|
254
247
|
|
|
255
248
|
context ".visible" do
|
|
256
249
|
it "should return 1 visible page" do
|
|
257
|
-
FactoryGirl.create(:public_page, :name => 'First Public Child', :visible => true, :parent_id =>
|
|
250
|
+
FactoryGirl.create(:public_page, :name => 'First Public Child', :visible => true, :parent_id => language_root.id, :language => language)
|
|
258
251
|
Page.visible.should have(1).pages
|
|
259
252
|
end
|
|
260
253
|
end
|
|
261
254
|
|
|
262
255
|
context ".accessible" do
|
|
263
256
|
it "should return 2 accessible pages" do
|
|
264
|
-
FactoryGirl.create(:public_page, :name => 'First Public Child', :restricted => true, :parent_id =>
|
|
257
|
+
FactoryGirl.create(:public_page, :name => 'First Public Child', :restricted => true, :parent_id => language_root.id, :language => language)
|
|
265
258
|
Page.accessible.should have(2).pages
|
|
266
259
|
end
|
|
267
260
|
end
|
|
268
261
|
|
|
269
262
|
context ".restricted" do
|
|
270
263
|
it "should return 1 restricted page" do
|
|
271
|
-
FactoryGirl.create(:public_page, :name => 'First Public Child', :restricted => true, :parent_id =>
|
|
264
|
+
FactoryGirl.create(:public_page, :name => 'First Public Child', :restricted => true, :parent_id => language_root.id, :language => language)
|
|
272
265
|
Page.restricted.should have(1).pages
|
|
273
266
|
end
|
|
274
267
|
end
|
|
275
268
|
|
|
276
269
|
context "#unlock" do
|
|
277
270
|
it "should set the locked status to false" do
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
271
|
+
page = FactoryGirl.create(:public_page, :locked => true)
|
|
272
|
+
page.unlock
|
|
273
|
+
page.locked.should == false
|
|
281
274
|
end
|
|
282
275
|
end
|
|
283
276
|
|
|
284
277
|
describe "#cell_definitions" do
|
|
285
278
|
|
|
286
|
-
before
|
|
279
|
+
before do
|
|
287
280
|
@page = FactoryGirl.build(:page, :page_layout => 'foo')
|
|
288
281
|
@page.stub!(:layout_description).and_return({'name' => "foo", 'cells' => ["foo_cell"]})
|
|
289
282
|
@cell_descriptions = [{'name' => "foo_cell", 'elements' => ["1", "2"]}]
|
|
@@ -303,24 +296,27 @@ module Alchemy
|
|
|
303
296
|
|
|
304
297
|
describe "#elements_grouped_by_cells" do
|
|
305
298
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
299
|
+
before do
|
|
300
|
+
PageLayout.stub(:get).and_return({
|
|
301
|
+
'name' => 'standard',
|
|
302
|
+
'cells' => ['header'],
|
|
303
|
+
'elements' => ['header', 'text'],
|
|
304
|
+
'autogenerate' => ['header', 'text']
|
|
305
|
+
})
|
|
306
|
+
Cell.stub!(:definitions).and_return([{
|
|
307
|
+
'name' => "header",
|
|
308
|
+
'elements' => ["header"]
|
|
309
|
+
}])
|
|
310
|
+
@page = FactoryGirl.create(:public_page, :do_not_autogenerate => false)
|
|
314
311
|
end
|
|
315
312
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
end
|
|
313
|
+
it "should return elements grouped by cell" do
|
|
314
|
+
@page.elements_grouped_by_cells.keys.first.should be_instance_of(Cell)
|
|
315
|
+
@page.elements_grouped_by_cells.values.first.first.should be_instance_of(Element)
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
it "should only include elements beeing in a cell " do
|
|
319
|
+
@page.elements_grouped_by_cells.keys.should_not include(nil)
|
|
324
320
|
end
|
|
325
321
|
|
|
326
322
|
end
|
|
@@ -330,13 +326,13 @@ module Alchemy
|
|
|
330
326
|
context "with clipboard holding pages having non unique page layout" do
|
|
331
327
|
|
|
332
328
|
it "should return the pages" do
|
|
333
|
-
page_1 = FactoryGirl.create(:page, :language =>
|
|
334
|
-
page_2 = FactoryGirl.create(:page, :language =>
|
|
329
|
+
page_1 = FactoryGirl.create(:page, :language => language)
|
|
330
|
+
page_2 = FactoryGirl.create(:page, :language => language, :name => 'Another page')
|
|
335
331
|
clipboard = [
|
|
336
332
|
{:id => page_1.id, :action => "copy"},
|
|
337
333
|
{:id => page_2.id, :action => "copy"}
|
|
338
334
|
]
|
|
339
|
-
Page.all_from_clipboard_for_select(clipboard,
|
|
335
|
+
Page.all_from_clipboard_for_select(clipboard, language.id).should include(page_1, page_2)
|
|
340
336
|
end
|
|
341
337
|
|
|
342
338
|
end
|
|
@@ -344,11 +340,11 @@ module Alchemy
|
|
|
344
340
|
context "with clipboard holding a page having unique page layout" do
|
|
345
341
|
|
|
346
342
|
it "should not return any pages" do
|
|
347
|
-
page_1 = FactoryGirl.create(:page, :language =>
|
|
343
|
+
page_1 = FactoryGirl.create(:page, :language => language, :page_layout => 'contact')
|
|
348
344
|
clipboard = [
|
|
349
345
|
{:id => page_1.id, :action => "copy"}
|
|
350
346
|
]
|
|
351
|
-
Page.all_from_clipboard_for_select(clipboard,
|
|
347
|
+
Page.all_from_clipboard_for_select(clipboard, language.id).should == []
|
|
352
348
|
end
|
|
353
349
|
|
|
354
350
|
end
|
|
@@ -356,13 +352,13 @@ module Alchemy
|
|
|
356
352
|
context "with clipboard holding two pages. One having a unique page layout." do
|
|
357
353
|
|
|
358
354
|
it "should return one page" do
|
|
359
|
-
page_1 = FactoryGirl.create(:page, :language =>
|
|
360
|
-
page_2 = FactoryGirl.create(:page, :name => 'Another page', :language =>
|
|
355
|
+
page_1 = FactoryGirl.create(:page, :language => language, :page_layout => 'standard')
|
|
356
|
+
page_2 = FactoryGirl.create(:page, :name => 'Another page', :language => language, :page_layout => 'contact')
|
|
361
357
|
clipboard = [
|
|
362
358
|
{:id => page_1.id, :action => "copy"},
|
|
363
359
|
{:id => page_2.id, :action => "copy"}
|
|
364
360
|
]
|
|
365
|
-
Page.all_from_clipboard_for_select(clipboard,
|
|
361
|
+
Page.all_from_clipboard_for_select(clipboard, language.id).should == [page_1]
|
|
366
362
|
end
|
|
367
363
|
|
|
368
364
|
end
|
|
@@ -372,26 +368,30 @@ module Alchemy
|
|
|
372
368
|
describe "validations" do
|
|
373
369
|
|
|
374
370
|
context "saving a normal content page" do
|
|
371
|
+
|
|
375
372
|
it "should be possible to save when its urlname already exists in the scope of global pages" do
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
373
|
+
contentpage = FactoryGirl.create(:page, :urlname => "existing_twice")
|
|
374
|
+
global_with_same_urlname = FactoryGirl.create(:page, :urlname => "existing_twice", :layoutpage => true)
|
|
375
|
+
contentpage.title = "new Title"
|
|
376
|
+
contentpage.save.should == true
|
|
380
377
|
end
|
|
378
|
+
|
|
381
379
|
end
|
|
382
380
|
|
|
383
381
|
context "creating a normal content page" do
|
|
384
382
|
|
|
385
|
-
before
|
|
386
|
-
@contentpage = FactoryGirl.build(:page
|
|
383
|
+
before do
|
|
384
|
+
@contentpage = FactoryGirl.build(:page)
|
|
387
385
|
end
|
|
388
386
|
|
|
389
387
|
it "should validate the page_layout" do
|
|
388
|
+
@contentpage.page_layout = nil
|
|
390
389
|
@contentpage.save
|
|
391
390
|
@contentpage.should have(1).error_on(:page_layout)
|
|
392
391
|
end
|
|
393
392
|
|
|
394
393
|
it "should validate the parent_id" do
|
|
394
|
+
@contentpage.parent_id = nil
|
|
395
395
|
@contentpage.save
|
|
396
396
|
@contentpage.should have(1).error_on(:parent_id)
|
|
397
397
|
end
|
|
@@ -400,7 +400,7 @@ module Alchemy
|
|
|
400
400
|
|
|
401
401
|
context "creating the rootpage without parent_id and page_layout" do
|
|
402
402
|
|
|
403
|
-
before
|
|
403
|
+
before do
|
|
404
404
|
Page.delete_all
|
|
405
405
|
@rootpage = FactoryGirl.build(:page, :parent_id => nil, :page_layout => nil, :name => 'Rootpage')
|
|
406
406
|
end
|
|
@@ -414,7 +414,7 @@ module Alchemy
|
|
|
414
414
|
|
|
415
415
|
context "saving a systempage" do
|
|
416
416
|
|
|
417
|
-
before
|
|
417
|
+
before do
|
|
418
418
|
@systempage = FactoryGirl.build(:systempage)
|
|
419
419
|
end
|
|
420
420
|
|
|
@@ -431,8 +431,8 @@ module Alchemy
|
|
|
431
431
|
|
|
432
432
|
context "a normal page" do
|
|
433
433
|
|
|
434
|
-
before
|
|
435
|
-
@page = FactoryGirl.build(:page, :language_code => nil, :language =>
|
|
434
|
+
before do
|
|
435
|
+
@page = FactoryGirl.build(:page, :language_code => nil, :language => klingonian, :do_not_autogenerate => false)
|
|
436
436
|
end
|
|
437
437
|
|
|
438
438
|
it "should get the language code for language" do
|
|
@@ -445,9 +445,33 @@ module Alchemy
|
|
|
445
445
|
@page.elements.should_not be_empty
|
|
446
446
|
end
|
|
447
447
|
|
|
448
|
+
context "with cells" do
|
|
449
|
+
|
|
450
|
+
before do
|
|
451
|
+
@page.stub!(:definition).and_return({'name' => 'with_cells', 'cells' => ['header', 'main']})
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
it "should have the generated elements in their cells" do
|
|
455
|
+
@page.stub!(:cell_definitions).and_return([{'name' => 'header', 'elements' => ['article']}])
|
|
456
|
+
@page.save
|
|
457
|
+
@page.cells.where(:name => 'header').first.elements.should_not be_empty
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
context "and no elements in cell definitions" do
|
|
461
|
+
|
|
462
|
+
it "should have the elements in the nil cell" do
|
|
463
|
+
@page.stub!(:cell_definitions).and_return([{'name' => 'header', 'elements' => []}])
|
|
464
|
+
@page.save
|
|
465
|
+
@page.cells.collect(&:elements).flatten.should be_empty
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
end
|
|
471
|
+
|
|
448
472
|
context "with children getting restricted set to true" do
|
|
449
473
|
|
|
450
|
-
before
|
|
474
|
+
before do
|
|
451
475
|
@page.save
|
|
452
476
|
@child1 = FactoryGirl.create(:page, :name => 'Child 1', :parent_id => @page.id)
|
|
453
477
|
@page.reload
|
|
@@ -464,7 +488,7 @@ module Alchemy
|
|
|
464
488
|
|
|
465
489
|
context "with restricted parent gets created" do
|
|
466
490
|
|
|
467
|
-
before
|
|
491
|
+
before do
|
|
468
492
|
@page.save
|
|
469
493
|
@page.parent.update_attributes(:restricted => true)
|
|
470
494
|
@new_page = FactoryGirl.create(:page, :name => 'New Page', :parent_id => @page.id)
|
|
@@ -478,7 +502,7 @@ module Alchemy
|
|
|
478
502
|
|
|
479
503
|
context "with do_not_autogenerate set to true" do
|
|
480
504
|
|
|
481
|
-
before
|
|
505
|
+
before do
|
|
482
506
|
@page.do_not_autogenerate = true
|
|
483
507
|
end
|
|
484
508
|
|
|
@@ -493,7 +517,7 @@ module Alchemy
|
|
|
493
517
|
|
|
494
518
|
context "a systempage" do
|
|
495
519
|
|
|
496
|
-
before
|
|
520
|
+
before do
|
|
497
521
|
@page = FactoryGirl.create(:systempage)
|
|
498
522
|
end
|
|
499
523
|
|
|
@@ -511,16 +535,60 @@ module Alchemy
|
|
|
511
535
|
|
|
512
536
|
describe '#fold' do
|
|
513
537
|
|
|
514
|
-
before
|
|
515
|
-
@page = FactoryGirl.create(:public_page)
|
|
538
|
+
before do
|
|
516
539
|
@user = FactoryGirl.create(:admin_user, :email => 'faz@baz.com', :login => 'foo_baz')
|
|
517
540
|
end
|
|
518
541
|
|
|
519
542
|
context "with folded status set to true" do
|
|
520
543
|
|
|
521
544
|
it "should create a folded page for user" do
|
|
522
|
-
|
|
523
|
-
FoldedPage.find_or_create_by_user_id_and_page_id(@user.id,
|
|
545
|
+
public_page.fold(@user.id, true)
|
|
546
|
+
FoldedPage.find_or_create_by_user_id_and_page_id(@user.id, public_page.id).should_not be_nil
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
describe 'previous and next. ' do
|
|
554
|
+
|
|
555
|
+
let(:center_page) { FactoryGirl.create(:public_page, :name => 'Center Page') }
|
|
556
|
+
let(:next_page) { FactoryGirl.create(:public_page, :name => 'Next Page') }
|
|
557
|
+
|
|
558
|
+
before do
|
|
559
|
+
public_page
|
|
560
|
+
center_page
|
|
561
|
+
next_page
|
|
562
|
+
end
|
|
563
|
+
|
|
564
|
+
describe '#previous' do
|
|
565
|
+
|
|
566
|
+
it "should return the previous page on the same level" do
|
|
567
|
+
center_page.previous.should == public_page
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
context "no previous page on same level present" do
|
|
571
|
+
|
|
572
|
+
it "should return nil" do
|
|
573
|
+
public_page.previous.should be_nil
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
describe '#next' do
|
|
581
|
+
|
|
582
|
+
it "should return the next page on the same level" do
|
|
583
|
+
center_page.next.should == next_page
|
|
584
|
+
end
|
|
585
|
+
|
|
586
|
+
context "no next page on same level present" do
|
|
587
|
+
|
|
588
|
+
it "should return nil" do
|
|
589
|
+
next_page.next.should be_nil
|
|
590
|
+
end
|
|
591
|
+
|
|
524
592
|
end
|
|
525
593
|
|
|
526
594
|
end
|