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
@@ -4,15 +4,19 @@ require 'spec_helper'
|
|
4
4
|
module Alchemy
|
5
5
|
describe PagesController do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
let(:default_language) { Language.get_default }
|
8
|
+
let(:default_language_root) { FactoryGirl.create(:language_root_page, :language => default_language, :name => 'Home') }
|
9
|
+
let(:public_page_1) { FactoryGirl.create(:public_page, :visible => true, :name => 'Page 1') }
|
10
|
+
let(:public_child) { FactoryGirl.create(:public_page, :name => 'Public Child', :parent_id => public_page_1.id) }
|
11
|
+
let(:search_page) { FactoryGirl.create(:public_page, :name => 'Suche', :page_layout => 'search', :do_not_autogenerate => false) }
|
12
|
+
let(:element) { FactoryGirl.create(:element, :page => public_page_1, :create_contents_after_create => true) }
|
13
|
+
|
14
|
+
before { default_language_root }
|
11
15
|
|
12
16
|
describe "#show" do
|
13
17
|
|
14
18
|
it "should include all its elements and contents" do
|
15
|
-
p = FactoryGirl.create(:public_page, :
|
19
|
+
p = FactoryGirl.create(:public_page, :do_not_autogenerate => false)
|
16
20
|
article = p.elements.find_by_name('article')
|
17
21
|
article.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
|
18
22
|
visit "/alchemy/#{p.urlname}"
|
@@ -21,8 +25,8 @@ module Alchemy
|
|
21
25
|
|
22
26
|
it "should show the navigation with all visible pages" do
|
23
27
|
pages = [
|
24
|
-
FactoryGirl.create(:public_page, :
|
25
|
-
FactoryGirl.create(:public_page, :
|
28
|
+
FactoryGirl.create(:public_page, :visible => true, :name => 'Page 1'),
|
29
|
+
FactoryGirl.create(:public_page, :visible => true, :name => 'Page 2')
|
26
30
|
]
|
27
31
|
visit '/alchemy/'
|
28
32
|
within('div#navigation ul') { page.should have_selector('li a[href="/alchemy/page-1"], li a[href="/alchemy/page-2"]') }
|
@@ -32,11 +36,7 @@ module Alchemy
|
|
32
36
|
|
33
37
|
describe "fulltext search" do
|
34
38
|
|
35
|
-
before
|
36
|
-
@page = FactoryGirl.create(:public_page, :language => @default_language, :visible => true, :name => 'Page 1', :parent_id => @default_language_root.id)
|
37
|
-
@element = FactoryGirl.create(:element, :name => 'article', :page => @page)
|
38
|
-
FactoryGirl.create(:public_page, :language => @default_language, :name => 'Suche', :page_layout => 'search', :parent_id => @default_language_root.id)
|
39
|
-
end
|
39
|
+
before { search_page }
|
40
40
|
|
41
41
|
it "should have a correct path in the form tag" do
|
42
42
|
visit('/alchemy/suche')
|
@@ -46,34 +46,34 @@ module Alchemy
|
|
46
46
|
context "performing the search" do
|
47
47
|
|
48
48
|
it "should display search results for richtext essences" do
|
49
|
-
|
49
|
+
element.content_by_name('text').essence.update_attributes(:body => '<p>Welcome to Peters Petshop</p>', :public => true)
|
50
50
|
visit('/alchemy/suche?query=Petshop')
|
51
51
|
within('div#content .search_result') { page.should have_content('Petshop') }
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should display search results for text essences" do
|
55
|
-
|
55
|
+
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
|
56
56
|
visit('/alchemy/suche?query=Petshop')
|
57
57
|
within('div#content .search_result') { page.should have_content('Petshop') }
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should not find contents placed on global-pages (layoutpage => true)" do
|
61
|
-
|
62
|
-
|
61
|
+
public_page_1.update_attributes(:layoutpage => true)
|
62
|
+
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
|
63
63
|
visit('/alchemy/suche?query=Petshop')
|
64
64
|
within('div#content') { page.should have_css('h2.no_search_results') }
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should not find contents placed on unpublished pages (public => false)" do
|
68
|
-
|
69
|
-
|
68
|
+
public_page_1.update_attributes(:public => false)
|
69
|
+
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
|
70
70
|
visit('/alchemy/suche?query=Petshop')
|
71
71
|
within('div#content') { page.should have_css('h2.no_search_results') }
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should not find contents placed on restricted pages (restricted => true)" do
|
75
|
-
|
76
|
-
|
75
|
+
public_page_1.update_attributes(:restricted => true)
|
76
|
+
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
|
77
77
|
visit('/alchemy/suche?query=Petshop')
|
78
78
|
within('div#content') { page.should have_css('h2.no_search_results') }
|
79
79
|
end
|
@@ -86,44 +86,44 @@ module Alchemy
|
|
86
86
|
|
87
87
|
context "in multi language mode" do
|
88
88
|
|
89
|
-
before
|
90
|
-
@page = FactoryGirl.create(:public_page)
|
89
|
+
before do
|
91
90
|
Config.stub!(:get) { |arg| arg == :url_nesting ? true : Config.parameter(arg) }
|
91
|
+
PagesController.any_instance.stub(:multi_language?).and_return(true)
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should redirect to url with nested language code if no language params are given" do
|
95
|
-
visit "/alchemy/#{
|
96
|
-
page.current_path.should == "/alchemy/#{
|
95
|
+
visit "/alchemy/#{public_page_1.urlname}"
|
96
|
+
page.current_path.should == "/alchemy/#{public_page_1.language_code}/#{public_page_1.urlname}"
|
97
97
|
end
|
98
98
|
|
99
99
|
context "should redirect to public child" do
|
100
100
|
|
101
|
-
before
|
102
|
-
|
103
|
-
|
101
|
+
before do
|
102
|
+
public_page_1.update_attributes(:public => false, :name => 'Not Public', :urlname => '')
|
103
|
+
public_child
|
104
104
|
Config.stub!(:get) { |arg| arg == :url_nesting ? false : Config.parameter(arg) }
|
105
105
|
end
|
106
106
|
|
107
107
|
it "if requested page is unpublished" do
|
108
|
-
visit
|
109
|
-
page.current_path.should ==
|
108
|
+
visit "/alchemy/#{default_language.code}/not-public"
|
109
|
+
page.current_path.should == "/alchemy/#{default_language.code}/public-child"
|
110
110
|
end
|
111
111
|
|
112
112
|
it "with nested language code, if requested page is unpublished and url has no language code" do
|
113
113
|
visit '/alchemy/not-public'
|
114
|
-
page.current_path.should ==
|
114
|
+
page.current_path.should == "/alchemy/#{default_language.code}/public-child"
|
115
115
|
end
|
116
116
|
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should redirect to pages url with default language, if requested url is index url" do
|
120
120
|
visit '/alchemy/'
|
121
|
-
page.current_path.should ==
|
121
|
+
page.current_path.should == "/alchemy/#{default_language.code}/home"
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should redirect to pages url with default language, if requested url is only the language code" do
|
125
|
-
visit
|
126
|
-
page.current_path.should ==
|
125
|
+
visit "/alchemy/#{default_language.code}"
|
126
|
+
page.current_path.should == "/alchemy/#{default_language.code}/home"
|
127
127
|
end
|
128
128
|
|
129
129
|
context "requested url is only the urlname" do
|
@@ -134,22 +134,33 @@ module Alchemy
|
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should keep additional params" do
|
137
|
-
visit "/alchemy/#{
|
137
|
+
visit "/alchemy/#{public_page_1.urlname}?query=Peter"
|
138
138
|
page.current_url.should match(/\?query=Peter/)
|
139
139
|
end
|
140
140
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
141
|
+
context "wrong language requested" do
|
142
|
+
|
143
|
+
before { User.stub!(:admins).and_return([1, 2]) }
|
144
|
+
|
145
|
+
it "should render 404 if urlname and lang parameter do not belong to same page" do
|
146
|
+
FactoryGirl.create(:english)
|
147
|
+
visit "/alchemy/en/#{public_page_1.urlname}"
|
148
|
+
page.status_code.should == 404
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should render 404 if requested language does not exist" do
|
152
|
+
visit "/alchemy/fo/#{public_page_1.urlname}"
|
153
|
+
page.status_code.should == 404
|
154
|
+
end
|
155
|
+
|
145
156
|
end
|
146
157
|
|
147
158
|
context "with url nesting" do
|
148
159
|
|
149
|
-
before
|
150
|
-
|
151
|
-
|
152
|
-
|
160
|
+
before do
|
161
|
+
level1 = FactoryGirl.create(:public_page, :name => 'catalog')
|
162
|
+
level2 = FactoryGirl.create(:public_page, :parent_id => level1.id, :name => 'products')
|
163
|
+
level3 = FactoryGirl.create(:public_page, :parent_id => level2.id, :name => 'screwdriver')
|
153
164
|
end
|
154
165
|
|
155
166
|
context "enabled" do
|
@@ -198,14 +209,14 @@ module Alchemy
|
|
198
209
|
|
199
210
|
context "not in multi language mode" do
|
200
211
|
|
201
|
-
before
|
202
|
-
|
212
|
+
before do
|
213
|
+
PagesController.any_instance.stub(:multi_language?).and_return(false)
|
203
214
|
Config.stub!(:get) { |arg| arg == :url_nesting ? false : Config.parameter(arg) }
|
204
215
|
end
|
205
216
|
|
206
217
|
it "should redirect from nested language code url to normal url" do
|
207
|
-
visit "/alchemy/de/#{
|
208
|
-
page.current_path.should == "/alchemy/#{
|
218
|
+
visit "/alchemy/de/#{public_page_1.urlname}"
|
219
|
+
page.current_path.should == "/alchemy/#{public_page_1.urlname}"
|
209
220
|
end
|
210
221
|
|
211
222
|
context "with no lang parameter" do
|
@@ -224,9 +235,9 @@ module Alchemy
|
|
224
235
|
|
225
236
|
context "should redirect to public child" do
|
226
237
|
|
227
|
-
before
|
228
|
-
|
229
|
-
|
238
|
+
before do
|
239
|
+
public_page_1.update_attributes(:public => false, :name => 'Not Public', :urlname => '')
|
240
|
+
public_child
|
230
241
|
end
|
231
242
|
|
232
243
|
it "if requested page is unpublished" do
|
@@ -247,7 +258,7 @@ module Alchemy
|
|
247
258
|
end
|
248
259
|
|
249
260
|
it "should keep additional params" do
|
250
|
-
visit "/alchemy/de/#{
|
261
|
+
visit "/alchemy/de/#{public_page_1.urlname}?query=Peter"
|
251
262
|
page.current_url.should match(/\?query=Peter/)
|
252
263
|
end
|
253
264
|
|
@@ -257,12 +268,12 @@ module Alchemy
|
|
257
268
|
|
258
269
|
describe "Handling of non-existing pages" do
|
259
270
|
|
260
|
-
|
271
|
+
before do
|
272
|
+
User.stub!(:admins).and_return([1, 2]) # We need a admin user or the signup page will show up
|
273
|
+
visit "/alchemy/non-existing-page"
|
274
|
+
end
|
261
275
|
|
262
|
-
|
263
|
-
User.stub!(:admins).and_return([1, 2]) # We need a admin user or the signup page will show up
|
264
|
-
visit "/alchemy/non-existing-page"
|
265
|
-
end
|
276
|
+
context "if a language root page exists" do
|
266
277
|
|
267
278
|
it "should render the status code in the title tag" do
|
268
279
|
within("title") { page.should have_content("404") }
|
@@ -274,14 +285,12 @@ module Alchemy
|
|
274
285
|
|
275
286
|
end
|
276
287
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
it "should render public/404.html when it exists"
|
281
|
-
it "can be handled by matching /404 and routing it to a controller of choice when no public/404.html exists"
|
282
|
-
|
288
|
+
it "should render public/404.html when it exists" do
|
289
|
+
within("title") { page.should have_content("404") }
|
283
290
|
end
|
284
291
|
|
292
|
+
it "can be handled by matching /404 and routing it to a controller of choice when no public/404.html exists"
|
293
|
+
|
285
294
|
end
|
286
295
|
end
|
287
296
|
end
|
@@ -2,11 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Security: " do
|
4
4
|
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
Alchemy::Page.root.children.destroy_all
|
7
7
|
Alchemy::User.delete_all
|
8
|
-
# ensuring that we have the correct locale here
|
9
|
-
::I18n.locale = :en
|
10
8
|
end
|
11
9
|
|
12
10
|
context "If no user is present" do
|
@@ -19,7 +17,7 @@ describe "Security: " do
|
|
19
17
|
|
20
18
|
context "If user is present" do
|
21
19
|
|
22
|
-
before
|
20
|
+
before do
|
23
21
|
create_admin_user
|
24
22
|
end
|
25
23
|
|
@@ -37,7 +35,7 @@ describe "Security: " do
|
|
37
35
|
|
38
36
|
context "that is already logged in" do
|
39
37
|
|
40
|
-
before
|
38
|
+
before do
|
41
39
|
login_into_alchemy
|
42
40
|
end
|
43
41
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Translation integration" do
|
4
|
+
|
5
|
+
context "in admin backend" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
authorize_as_admin
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be possible to set the locale of the admin backend via params" do
|
12
|
+
visit admin_dashboard_path(:locale => :de)
|
13
|
+
page.should have_content('Willkommen')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should store the current locale in the session" do
|
17
|
+
visit admin_dashboard_path(:locale => :de)
|
18
|
+
visit admin_dashboard_path
|
19
|
+
page.should have_content('Willkommen')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be possible to change the current locale in the session" do
|
23
|
+
visit admin_dashboard_path(:locale => :de)
|
24
|
+
visit admin_dashboard_path(:locale => :en)
|
25
|
+
page.should have_content('Welcome')
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not be possible to switch the locale of the admin backend to an unknown locale" do
|
29
|
+
visit admin_dashboard_path(:locale => :ko)
|
30
|
+
page.should have_content('Welcome')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should use the current users language setting if no other parameter is given" do
|
34
|
+
Alchemy::User.first.update_attributes(:language => :de)
|
35
|
+
visit admin_dashboard_path
|
36
|
+
page.should have_content('Willkommen')
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
context "with translated header" do
|
42
|
+
|
43
|
+
before do
|
44
|
+
# Hack my hack.... OMG
|
45
|
+
Rails.stub(:env).and_return('foo')
|
46
|
+
Capybara.current_driver = :rack_test_translated_header
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should use the browsers language setting if no other parameter is given" do
|
50
|
+
visit root_path
|
51
|
+
::I18n.locale.should == :de
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "ActsAsEssence" do
|
4
|
+
|
5
|
+
let(:element) { FactoryGirl.create(:element, :name => 'headline', :create_contents_after_create => true) }
|
6
|
+
|
7
|
+
describe '#ingredient=' do
|
8
|
+
|
9
|
+
it "should set the value to ingredient column" do
|
10
|
+
content = element.content_by_name('headline')
|
11
|
+
content.essence.ingredient = 'Hallo'
|
12
|
+
content.essence.save
|
13
|
+
content.essence.ingredient.should == 'Hallo'
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -4,117 +4,139 @@ require File.dirname(__FILE__) + '/../../lib/alchemy/resource'
|
|
4
4
|
class Event
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
resource = Alchemy::Resource.new("admin/events")
|
12
|
-
resource.should be_a Alchemy::Resource
|
13
|
-
end
|
14
|
-
it "can be can be initialized with an alchemy module_definition" do
|
15
|
-
resource = Alchemy::Resource.new("admin/events", {'engine_name' => 'engine'})
|
16
|
-
resource.should be_a Alchemy::Resource
|
7
|
+
module Namespace1
|
8
|
+
module Namespace2
|
9
|
+
class Event
|
10
|
+
end
|
17
11
|
end
|
12
|
+
end
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
14
|
+
module Namespace
|
15
|
+
class Event
|
16
|
+
end
|
17
|
+
end
|
24
18
|
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
module Engine
|
20
|
+
module Namespace
|
21
|
+
class Event
|
28
22
|
end
|
29
23
|
end
|
24
|
+
end
|
30
25
|
|
31
|
-
|
32
|
-
|
26
|
+
module Alchemy
|
27
|
+
describe Resource do
|
33
28
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
it "is initialized with a controller_path" do
|
30
|
+
resource = Resource.new("admin/events")
|
31
|
+
resource.should be_a Resource
|
32
|
+
end
|
33
|
+
it "can be can be initialized with an alchemy module_definition" do
|
34
|
+
resource = Resource.new("admin/events", {'engine_name' => 'engine'})
|
35
|
+
resource.should be_a Resource
|
36
|
+
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
describe "model_array" do
|
39
|
+
it "splits the controller_path and returns it as array." do
|
40
|
+
resource = Resource.new("namespace1/namespace2/events")
|
41
|
+
resource.model_array.should eql(['namespace1', 'namespace2', 'events'])
|
43
42
|
end
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
44
|
+
it "deletes 'admin' if found hence our model isn't in the admin-namespace by convention" do
|
45
|
+
resource = Resource.new("admin/events")
|
46
|
+
resource.model_array.should eql(['events'])
|
49
47
|
end
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
resource.permission_scope.should == :admin_events
|
54
|
-
end
|
55
|
-
end
|
50
|
+
describe "instance methods" do
|
51
|
+
let(:resource) { Resource.new("admin/events") }
|
56
52
|
|
57
|
-
describe "
|
58
|
-
it "returns
|
59
|
-
resource.
|
53
|
+
describe "model" do
|
54
|
+
it "returns resource's model-class" do
|
55
|
+
resource.model.should be(Event)
|
60
56
|
end
|
61
|
-
end
|
62
57
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
mock(:column, {:name => 'name', :type => :string}),
|
68
|
-
mock(:column, {:name => 'hidden_value', :type => :string}),
|
69
|
-
mock(:column, {:name => 'description', :type => :string}),
|
70
|
-
mock(:column, {:name => 'id', :type => :integer}),
|
71
|
-
mock(:column, {:name => 'starts_at', :type => :datetime}),
|
72
|
-
]
|
73
|
-
Event.stub(:columns).and_return columns
|
58
|
+
describe "resources_name" do
|
59
|
+
it "returns plural name (like events for model Event)" do
|
60
|
+
resource.resources_name.should == 'events'
|
61
|
+
end
|
74
62
|
end
|
75
63
|
|
76
|
-
|
77
|
-
|
64
|
+
describe "model_name" do
|
65
|
+
it "returns model_name (like event for model Event" do
|
66
|
+
resource.model_name.should == 'event'
|
67
|
+
end
|
78
68
|
end
|
79
69
|
|
80
|
-
|
81
|
-
|
82
|
-
|
70
|
+
describe "permission_scope" do
|
71
|
+
it "should return the permissions_scope usable in declarative authorization" do
|
72
|
+
resource.permission_scope.should == :admin_events
|
73
|
+
end
|
83
74
|
end
|
84
75
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
76
|
+
describe "namespace_for_scope" do
|
77
|
+
it "returns a scope for use in url_for-based path-helpers" do
|
78
|
+
resource.namespace_for_scope.should == ['admin']
|
79
|
+
end
|
89
80
|
end
|
90
81
|
|
91
|
-
describe "
|
92
|
-
|
93
|
-
|
94
|
-
|
82
|
+
describe "attributes" do
|
83
|
+
before :each do
|
84
|
+
##stubbing an ActiveRecord::ModelSchema...
|
85
|
+
columns = [
|
86
|
+
mock(:column, {:name => 'name', :type => :string}),
|
87
|
+
mock(:column, {:name => 'hidden_value', :type => :string}),
|
88
|
+
mock(:column, {:name => 'description', :type => :string}),
|
89
|
+
mock(:column, {:name => 'id', :type => :integer}),
|
90
|
+
mock(:column, {:name => 'starts_at', :type => :datetime}),
|
91
|
+
]
|
92
|
+
Event.stub(:columns).and_return columns
|
93
|
+
Config.stub(:get).and_return {}
|
94
|
+
end
|
95
|
+
|
96
|
+
it "parses and returns the resource-model's attributes from ActiveRecord::ModelSchema" do
|
97
|
+
resource.attributes.should == [{:name => "name", :type => :string}, {:name => "hidden_value", :type => :string}, {:name => "description", :type => :string}, {:name => "starts_at", :type => :datetime}]
|
98
|
+
end
|
99
|
+
|
100
|
+
it "skips a set of default attributes (DEFAULT_SKIPPED_ATTRIBUTES)" do
|
101
|
+
resource.attributes.should_not include({:name => "id", :type => :integer})
|
102
|
+
resource.attributes.should include({:name => "hidden_value", :type => :string})
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should skip attributes set via skip_attributes" do
|
106
|
+
resource.skip_attributes = %W[hidden_value]
|
107
|
+
resource.attributes.should include({:name => "id", :type => :integer})
|
108
|
+
resource.attributes.should_not include({:name => "hidden_value", :type => :string})
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "searchable_attributes" do
|
112
|
+
it "should return all attributes of type string" do
|
113
|
+
resource.skip_attributes = []
|
114
|
+
resource.searchable_attributes.should == [{:name => "name", :type => :string}, {:name => "hidden_value", :type => :string}, {:name => "description", :type => :string}]
|
115
|
+
end
|
95
116
|
end
|
96
117
|
end
|
118
|
+
|
97
119
|
end
|
98
120
|
|
99
|
-
|
121
|
+
describe "namespaced_model_name" do
|
100
122
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
end
|
123
|
+
it "returns model_name with namespace (namespace_event for Namespace::Event), i.e. for use in forms" do
|
124
|
+
namespaced_resource = Resource.new("admin/namespace/events")
|
125
|
+
namespaced_resource.namespaced_model_name.should == 'namespace_event'
|
126
|
+
end
|
106
127
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
128
|
+
it "should not include the engine's name" do
|
129
|
+
namespaced_resource = Resource.new("admin/engine/namespace/events", {'engine_name' => 'engine'})
|
130
|
+
namespaced_resource.namespaced_model_name.should == 'namespace_event'
|
131
|
+
end
|
111
132
|
|
112
|
-
|
113
|
-
|
114
|
-
|
133
|
+
it "should equal model_name if model not namespaced" do
|
134
|
+
namespaced_resource = Resource.new("admin/events")
|
135
|
+
namespaced_resource.namespaced_model_name.should == namespaced_resource.model_name
|
136
|
+
end
|
115
137
|
end
|
116
|
-
end
|
117
138
|
|
118
139
|
|
140
|
+
end
|
119
141
|
end
|
120
142
|
end
|