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.
Files changed (215) hide show
  1. data/.gitignore +1 -1
  2. data/.travis.yml +3 -4
  3. data/Gemfile +1 -0
  4. data/README.md +10 -6
  5. data/alchemy_cms.gemspec +5 -2
  6. data/app/assets/images/alchemy/icons.png +0 -0
  7. data/app/assets/images/sassy-ie-overlay.png +0 -0
  8. data/app/assets/javascripts/alchemy/alchemy.base.js +50 -59
  9. data/app/assets/javascripts/alchemy/alchemy.buttons.js +14 -4
  10. data/app/assets/javascripts/alchemy/alchemy.datepicker.js +8 -2
  11. data/app/assets/javascripts/alchemy/alchemy.elements_window.js +11 -3
  12. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +1 -1
  13. data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +14 -1
  14. data/app/assets/javascripts/alchemy/alchemy.preview.js +1 -1
  15. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +12 -4
  16. data/app/assets/javascripts/alchemy/alchemy.uploader.js +4 -1
  17. data/app/assets/javascripts/alchemy/alchemy.windows.js +18 -8
  18. data/app/assets/stylesheets/alchemy/_defaults.scss +84 -120
  19. data/app/assets/stylesheets/alchemy/alchemy.css +2 -2
  20. data/app/assets/stylesheets/alchemy/archive.css.scss +288 -0
  21. data/app/assets/stylesheets/alchemy/base.css.scss +95 -390
  22. data/app/assets/stylesheets/alchemy/dashboard.css.scss +4 -4
  23. data/app/assets/stylesheets/alchemy/elements.css.scss +83 -118
  24. data/app/assets/stylesheets/alchemy/flash.css.scss +1 -1
  25. data/app/assets/stylesheets/alchemy/form_elements.css.scss +528 -0
  26. data/app/assets/stylesheets/alchemy/frame.css.scss +13 -39
  27. data/app/assets/stylesheets/alchemy/icons.css.scss +217 -228
  28. data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +48 -50
  29. data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
  30. data/app/assets/stylesheets/alchemy/login.css.scss +1 -5
  31. data/app/assets/stylesheets/alchemy/menubar.css.scss +19 -29
  32. data/app/assets/stylesheets/alchemy/pagination.css.scss +3 -4
  33. data/app/assets/stylesheets/alchemy/sitemap.css.scss +81 -81
  34. data/app/assets/stylesheets/alchemy/tables.css.scss +63 -57
  35. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +57 -57
  36. data/app/assets/stylesheets/alchemy/upload.css.scss +6 -6
  37. data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.scss +6 -10
  38. data/app/controllers/alchemy/admin/attachments_controller.rb +5 -4
  39. data/app/controllers/alchemy/admin/base_controller.rb +1 -9
  40. data/app/controllers/alchemy/admin/contents_controller.rb +4 -6
  41. data/app/controllers/alchemy/admin/elements_controller.rb +2 -2
  42. data/app/controllers/alchemy/admin/pages_controller.rb +2 -2
  43. data/app/controllers/alchemy/admin/pictures_controller.rb +74 -15
  44. data/app/controllers/alchemy/attachments_controller.rb +8 -2
  45. data/app/controllers/alchemy/base_controller.rb +47 -5
  46. data/app/controllers/alchemy/elements_controller.rb +1 -1
  47. data/app/controllers/alchemy/messages_controller.rb +12 -12
  48. data/app/controllers/alchemy/pages_controller.rb +5 -1
  49. data/app/controllers/alchemy/pictures_controller.rb +9 -4
  50. data/app/controllers/alchemy/user_sessions_controller.rb +2 -4
  51. data/app/helpers/alchemy/admin/base_helper.rb +98 -19
  52. data/app/helpers/alchemy/admin/contents_helper.rb +2 -2
  53. data/app/helpers/alchemy/admin/elements_helper.rb +2 -3
  54. data/app/helpers/alchemy/base_helper.rb +6 -5
  55. data/app/helpers/alchemy/elements_helper.rb +2 -2
  56. data/app/helpers/alchemy/essences_helper.rb +4 -5
  57. data/app/helpers/alchemy/pages_helper.rb +15 -79
  58. data/app/helpers/alchemy/url_helper.rb +67 -0
  59. data/app/mailers/alchemy/messages.rb +1 -1
  60. data/app/mailers/alchemy/notifications.rb +1 -1
  61. data/app/models/alchemy/attachment.rb +11 -2
  62. data/app/models/alchemy/cell.rb +20 -10
  63. data/app/models/alchemy/content.rb +4 -3
  64. data/app/models/alchemy/element.rb +170 -178
  65. data/app/models/alchemy/language/code.rb +4 -1
  66. data/app/models/alchemy/message.rb +19 -3
  67. data/app/models/alchemy/page.rb +45 -40
  68. data/app/models/alchemy/picture.rb +24 -2
  69. data/app/models/alchemy/user.rb +2 -3
  70. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +12 -12
  71. data/app/views/alchemy/admin/attachments/_attachment.html.erb +1 -1
  72. data/app/views/alchemy/admin/attachments/create.js.erb +1 -0
  73. data/app/views/alchemy/admin/attachments/edit.html.erb +9 -3
  74. data/app/views/alchemy/admin/attachments/index.html.erb +3 -2
  75. data/app/views/alchemy/admin/contents/_missing.html.erb +1 -1
  76. data/app/views/alchemy/admin/contents/create.js.erb +54 -0
  77. data/app/views/alchemy/admin/contents/new.html.erb +9 -4
  78. data/app/views/alchemy/admin/elements/{_add_content.html.erb → _add_picture.html.erb} +4 -4
  79. data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -1
  80. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -1
  81. data/app/views/alchemy/admin/elements/{_picture_editor.html.erb → _picture_gallery_editor.html.erb} +7 -11
  82. data/app/views/alchemy/admin/elements/fold.js.erb +46 -0
  83. data/app/views/alchemy/admin/elements/index.html.erb +24 -24
  84. data/app/views/alchemy/admin/elements/list.js.erb +11 -9
  85. data/app/views/alchemy/admin/essence_files/assign.js.erb +3 -1
  86. data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +28 -0
  87. data/app/views/alchemy/admin/pages/_contactform_links.html.erb +8 -6
  88. data/app/views/alchemy/admin/pages/_external_link.html.erb +11 -9
  89. data/app/views/alchemy/admin/pages/_file_link.html.erb +10 -8
  90. data/app/views/alchemy/admin/pages/_internal_link.html.erb +14 -10
  91. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
  92. data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
  93. data/app/views/alchemy/admin/pages/_page_for_links.html.erb +32 -21
  94. data/app/views/alchemy/admin/pages/configure.html.erb +2 -2
  95. data/app/views/alchemy/admin/pages/configure_external.html.erb +13 -13
  96. data/app/views/alchemy/admin/pages/edit.html.erb +2 -2
  97. data/app/views/alchemy/admin/pages/index.html.erb +26 -24
  98. data/app/views/alchemy/admin/pages/link.html.erb +2 -5
  99. data/app/views/alchemy/admin/partials/_upload_form.html.erb +28 -12
  100. data/app/views/alchemy/admin/pictures/_archive.html.erb +54 -0
  101. data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +10 -7
  102. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +21 -22
  103. data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +31 -0
  104. data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +9 -0
  105. data/app/views/alchemy/admin/pictures/_picture.html.erb +36 -6
  106. data/app/views/alchemy/admin/pictures/_tag_list.html.erb +27 -0
  107. data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +3 -1
  108. data/app/views/alchemy/admin/pictures/create.js.erb +4 -5
  109. data/app/views/alchemy/admin/pictures/edit.html.erb +26 -0
  110. data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +39 -0
  111. data/app/views/alchemy/admin/pictures/index.html.erb +81 -70
  112. data/app/views/alchemy/admin/pictures/index.js.erb +3 -0
  113. data/app/views/alchemy/admin/pictures/new.html.erb +1 -0
  114. data/app/views/alchemy/admin/resources/index.html.erb +3 -1
  115. data/app/views/alchemy/admin/users/_table.html.erb +1 -1
  116. data/app/views/alchemy/admin/users/index.html.erb +27 -23
  117. data/app/views/alchemy/elements/_article_editor.html.erb +7 -2
  118. data/app/views/alchemy/elements/_bild_editor.html.erb +1 -1
  119. data/app/views/alchemy/elements/_bild_text_editor.html.erb +6 -1
  120. data/app/views/alchemy/elements/_bild_text_view.html.erb +3 -3
  121. data/app/views/alchemy/elements/_image_mosaic_editor.html.erb +1 -1
  122. data/app/views/alchemy/elements/_image_mosaic_view.html.erb +2 -2
  123. data/app/views/alchemy/elements/_intro_image_text_view.html.erb +4 -4
  124. data/app/views/alchemy/elements/_searchresult_editor.html.erb +4 -1
  125. data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +1 -1
  126. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +2 -3
  127. data/app/views/alchemy/essences/_essence_picture_tools.html.erb +1 -1
  128. data/app/views/alchemy/search/_form.html.erb +8 -0
  129. data/app/views/alchemy/search/_result.html.erb +3 -2
  130. data/app/views/alchemy/search/_results.html.erb +28 -0
  131. data/app/views/alchemy/user_sessions/leave.html.erb +4 -4
  132. data/app/views/alchemy/user_sessions/login.html.erb +1 -2
  133. data/app/views/layouts/alchemy/admin.html.erb +30 -10
  134. data/app/views/layouts/alchemy/login.html.erb +2 -39
  135. data/config/alchemy/elements.yml +1 -2
  136. data/config/alchemy/page_layouts.yml +8 -5
  137. data/config/authorization_rules.rb +27 -18
  138. data/config/initializers/localeapp.rb +9 -0
  139. data/config/locales/alchemy.de.yml +93 -56
  140. data/config/locales/alchemy.en.yml +73 -50
  141. data/config/routes.rb +3 -1
  142. data/db/migrate/20120704181529_add_upload_hash_to_alchemy_picture.rb +5 -0
  143. data/db/migrate/20120705214247_acts_as_taggable_on_migration.rb +28 -0
  144. data/db/migrate/20120728185830_add_cached_tag_list_to_alchemy_pictures.rb +5 -0
  145. data/db/migrate/20120831135441_set_alchemy_languages_country_code_default_to_empty_string.rb +9 -0
  146. data/lib/alchemy/capistrano.rb +2 -2
  147. data/lib/alchemy/essence.rb +14 -0
  148. data/lib/alchemy/page_layout.rb +0 -6
  149. data/lib/alchemy/resource.rb +9 -15
  150. data/lib/alchemy/upgrader.rb +18 -3
  151. data/lib/alchemy/version.rb +5 -1
  152. data/lib/alchemy_cms.rb +4 -1
  153. data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +16 -6
  154. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +17 -3
  155. data/lib/rails/generators/alchemy/elements/elements_generator.rb +6 -1
  156. data/lib/rails/generators/alchemy/elements/templates/editor.html.erb +10 -1
  157. data/lib/rails/generators/alchemy/elements/templates/view.html.erb +17 -18
  158. data/lib/rails/generators/alchemy/scaffold/files/pages.html.erb +4 -2
  159. data/lib/tasks/fleximage.rake +2 -2
  160. data/spec/controllers/admin/contents_controller_spec.rb +2 -2
  161. data/spec/controllers/admin/elements_controller_spec.rb +30 -1
  162. data/spec/controllers/admin/pages_controller_spec.rb +35 -18
  163. data/spec/controllers/admin/trash_controller_spec.rb +40 -16
  164. data/spec/controllers/attachments_controller_spec.rb +62 -0
  165. data/spec/controllers/base_controller_spec.rb +43 -42
  166. data/spec/controllers/elements_controller_spec.rb +30 -0
  167. data/spec/controllers/pages_controller_spec.rb +22 -5
  168. data/spec/controllers/pictures_controller_spec.rb +82 -0
  169. data/spec/dummy/app/models/event.rb +2 -1
  170. data/spec/dummy/config/database.yml +3 -2
  171. data/spec/dummy/db/schema.rb +51 -27
  172. data/spec/factories.rb +29 -8
  173. data/spec/helpers/admin/base_helper_spec.rb +134 -21
  174. data/spec/helpers/admin/contents_helper_spec.rb +2 -2
  175. data/spec/helpers/admin/elements_helper_spec.rb +17 -9
  176. data/spec/helpers/admin/essences_helper_spec.rb +7 -6
  177. data/spec/helpers/essences_helper_spec.rb +8 -7
  178. data/spec/helpers/pages_helper_spec.rb +208 -325
  179. data/spec/helpers/url_helper_spec.rb +171 -0
  180. data/spec/integration/admin/link_overlay_spec.rb +53 -0
  181. data/spec/integration/admin/modules_integration_spec.rb +22 -26
  182. data/spec/integration/admin/pages_controller_spec.rb +10 -19
  183. data/spec/integration/admin/picture_library_integration_spec.rb +52 -0
  184. data/spec/integration/admin/resources_integration_spec.rb +68 -75
  185. data/spec/integration/pages_controller_spec.rb +70 -61
  186. data/spec/integration/security_spec.rb +3 -5
  187. data/spec/integration/translation_integration_spec.rb +56 -0
  188. data/spec/libraries/essence_spec.rb +18 -0
  189. data/spec/libraries/resource_spec.rb +101 -79
  190. data/spec/libraries/resources_helper_spec.rb +3 -0
  191. data/spec/models/content_spec.rb +63 -60
  192. data/spec/models/element_spec.rb +203 -93
  193. data/spec/models/language_spec.rb +90 -65
  194. data/spec/models/page_layout_spec.rb +37 -0
  195. data/spec/models/page_spec.rb +181 -113
  196. data/spec/models/picture_spec.rb +73 -26
  197. data/spec/models/resource_spec.rb +52 -23
  198. data/spec/support/alchemy/specs_helpers.rb +2 -0
  199. data/spec/support/image.png +0 -0
  200. data/spec/{helpers/url_helpers_spec.rb → url_helpers_spec.rb} +0 -0
  201. data/vendor/assets/javascripts/jquery_plugins/jquery.selectBoxIt.js +1909 -0
  202. data/vendor/assets/javascripts/jquery_plugins/preloadCssImages.jQuery_v5.js +152 -0
  203. metadata +106 -33
  204. data/app/assets/stylesheets/alchemy/buttons.css.scss +0 -361
  205. data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +0 -260
  206. data/app/views/alchemy/admin/contents/create.js.coffee +0 -49
  207. data/app/views/alchemy/admin/elements/fold.js.coffee +0 -37
  208. data/app/views/alchemy/admin/essence_pictures/destroy.js.coffee +0 -19
  209. data/app/views/alchemy/admin/pictures/_pictures_list.html.erb +0 -16
  210. data/app/views/alchemy/admin/pictures/update.js.erb +0 -3
  211. data/spec/dummy/config/locales/en.yml +0 -5
  212. data/spec/dummy/config/locales/fo.yml +0 -5
  213. data/spec/page_layout_spec.rb +0 -35
  214. data/vendor/assets/javascripts/jquery_plugins/jquery.in-place-edit.js +0 -172
  215. 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
- before(:all) do
8
- @default_language = Language.get_default
9
- @default_language_root = FactoryGirl.create(:language_root_page, :language => @default_language, :name => 'Home')
10
- end
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, :language => @default_language)
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, :language => @default_language, :visible => true, :name => 'Page 1', :parent_id => @default_language_root.id),
25
- FactoryGirl.create(:public_page, :language => @default_language, :visible => true, :name => 'Page 2', :parent_id => @default_language_root.id)
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(:all) do
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
- @element.content_by_name('text').essence.update_attributes(:body => '<p>Welcome to Peters Petshop</p>', :public => true)
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
- @element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
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
- @page.update_attributes(:layoutpage => true)
62
- @element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
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
- @page.update_attributes(:public => false)
69
- @element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
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
- @page.update_attributes(:restricted => true)
76
- @element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop', :public => true)
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(:each) do
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/#{@page.urlname}"
96
- page.current_path.should == "/alchemy/#{@page.language_code}/#{@page.urlname}"
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(:each) do
102
- @page.update_attributes(:public => false, :name => 'Not Public', :urlname => '')
103
- @child = FactoryGirl.create(:public_page, :name => 'Public Child', :parent_id => @page.id)
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 '/alchemy/kl/not-public'
109
- page.current_path.should == '/alchemy/kl/public-child'
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 == '/alchemy/kl/public-child'
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 == '/alchemy/de/home'
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 '/alchemy/de'
126
- page.current_path.should == '/alchemy/de/home'
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/#{@page.urlname}?query=Peter"
137
+ visit "/alchemy/#{public_page_1.urlname}?query=Peter"
138
138
  page.current_url.should match(/\?query=Peter/)
139
139
  end
140
140
 
141
- it "should render 404 if urlname and lang parameter do not belong to same page" do
142
- User.stub!(:admins).and_return(OpenStruct.new(:count => 2))
143
- visit "/alchemy/en/#{@page.urlname}"
144
- page.status_code.should == 404
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(:all) do
150
- @level1 = FactoryGirl.create(:public_page, :parent_id => @default_language_root.id, :name => 'catalog', :language => @default_language)
151
- @level2 = FactoryGirl.create(:public_page, :parent_id => @level1.id, :name => 'products', :language => @default_language)
152
- @level3 = FactoryGirl.create(:public_page, :parent_id => @level2.id, :name => 'screwdriver', :language => @default_language)
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(:each) do
202
- @page = FactoryGirl.create(:public_page, :language => @default_language, :parent_id => @default_language_root.id)
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/#{@page.urlname}"
208
- page.current_path.should == "/alchemy/#{@page.urlname}"
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(:each) do
228
- @page.update_attributes(:public => false, :name => 'Not Public', :urlname => '')
229
- @child = FactoryGirl.create(:public_page, :name => 'Public Child', :parent_id => @page.id, :language => @default_language)
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/#{@page.urlname}?query=Peter"
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
- context "when a language root page exists" do
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
- before do
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
- context "404-Errors are handled by Rails now, so no need to test anymore.
278
- However, it still serves as documentation how they can be handled, so we leave it here" do
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(:all) do
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(:each) do
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(:each) do
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
- describe Alchemy::Resource do
9
-
10
- it "is initialized with a controller_path" do
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
- describe "model_array" do
20
- it "splits the controller_path and returns it as array." do
21
- resource = Alchemy::Resource.new("namespace1/namespace2/events")
22
- resource.model_array.should eql(['namespace1', 'namespace2', 'events'])
23
- end
14
+ module Namespace
15
+ class Event
16
+ end
17
+ end
24
18
 
25
- it "deletes 'admin' if found hence our model isn't in the admin-namespace by convention" do
26
- resource = Alchemy::Resource.new("admin/events")
27
- resource.model_array.should eql(['events'])
19
+ module Engine
20
+ module Namespace
21
+ class Event
28
22
  end
29
23
  end
24
+ end
30
25
 
31
- describe "instance methods" do
32
- let(:resource) { Alchemy::Resource.new("admin/events") }
26
+ module Alchemy
27
+ describe Resource do
33
28
 
34
- describe "model" do
35
- it "returns resource's model-class" do
36
- resource.model.should be(Event)
37
- end
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
- describe "resources_name" do
40
- it "returns plural name (like events for model Event)" do
41
- resource.resources_name.should == 'events'
42
- end
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
- describe "model_name" do
46
- it "returns model_name (like event for model Event" do
47
- resource.model_name.should == 'event'
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
- describe "permission_scope" do
52
- it "should return the permissions_scope usable in declarative authorization" do
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 "namespace_for_scope" do
58
- it "returns a scope for use in url_for-based path-helpers" do
59
- resource.namespace_for_scope.should == ['admin']
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
- describe "attributes" do
64
- before :each do
65
- ##stubbing an ActiveRecord::ModelSchema...
66
- columns = [
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
- it "parses and returns the resource-model's attributes from ActiveRecord::ModelSchema" do
77
- resource.attributes.should == [{:name => "name", :type => :string}, {:name => "hidden_value", :type => :string}, {:name => "description", :type => :string}, {:name => "starts_at", :type => :datetime}]
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
- it "skips a set of default attributes (DEFAULT_SKIPPED_ATTRIBUTES)" do
81
- resource.attributes.should_not include({:name => "id", :type => :integer})
82
- resource.attributes.should include({:name => "hidden_value", :type => :string})
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
- it "should skip attributes set via skip_attributes" do
86
- resource.skip_attributes = %W[hidden_value]
87
- resource.attributes.should include({:name => "id", :type => :integer})
88
- resource.attributes.should_not include({:name => "hidden_value", :type => :string})
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 "searchable_attributes" do
92
- it "should return all attributes of type string" do
93
- resource.skip_attributes = []
94
- resource.searchable_attributes.should == [{:name => "name", :type => :string}, {:name => "hidden_value", :type => :string}, {:name => "description", :type => :string}]
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
- end
121
+ describe "namespaced_model_name" do
100
122
 
101
- describe "namespaced_model_name" do
102
- it "returns model_name with namespace (namespace_event for Namespace::Event), i.e. for use in forms" do
103
- namespaced_resource = Alchemy::Resource.new("admin/namespace/events")
104
- namespaced_resource.namespaced_model_name.should == 'namespace_event'
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
- it "should not include the engine's name" do
108
- namespaced_resource = Alchemy::Resource.new("admin/engine/namespace/events", {'engine_name' => 'engine'})
109
- namespaced_resource.namespaced_model_name.should == 'namespace_event'
110
- end
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
- it "should equal model_name if model not namespaced" do
113
- namespaced_resource = Alchemy::Resource.new("admin/events")
114
- namespaced_resource.namespaced_model_name.should == namespaced_resource.model_name
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