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
@@ -1,61 +1,63 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Alchemy::BaseController do
3
+ module Alchemy
4
+ describe BaseController do
4
5
 
5
- describe "#set_language_from" do
6
+ let(:default_language) { Language.get_default }
7
+ let(:klingonian) { FactoryGirl.create(:klingonian) }
6
8
 
7
- it "should set the language from id" do
8
- @language = Alchemy::Language.get_default
9
- controller.send :set_language_from, @language.id
10
- controller.session[:language_id].should == @language.id
11
- end
9
+ describe "#set_language_from" do
12
10
 
13
- it "should set the language from code" do
14
- @language = FactoryGirl.create(:language, :code => 'kl')
15
- controller.send :set_language_from, "kl"
16
- controller.session[:language_id].should == @language.id
17
- controller.session[:language_code].should == @language.code
18
- end
11
+ it "should set the language from id" do
12
+ controller.send :set_language_from, default_language.id
13
+ controller.session[:language_id].should == default_language.id
14
+ end
15
+
16
+ it "should set the language from code" do
17
+ controller.send :set_language_from, klingonian.code
18
+ controller.session[:language_id].should == klingonian.id
19
+ controller.session[:language_code].should == klingonian.code
20
+ end
21
+
22
+ it "should set the language from id as string" do
23
+ controller.send :set_language_from, default_language.id.to_s
24
+ controller.session[:language_id].should == default_language.id
25
+ controller.session[:language_code].should == default_language.code
26
+ end
19
27
 
20
- it "should set the language from id as string" do
21
- @language = FactoryGirl.create(:language)
22
- controller.send :set_language_from, @language.id.to_s
23
- controller.session[:language_id].should == @language.id
24
- controller.session[:language_code].should == @language.code
25
28
  end
26
29
 
27
- end
30
+ describe "#set_language" do
28
31
 
29
- describe "#set_language" do
32
+ context "with no lang param" do
30
33
 
31
- context "with no lang param" do
34
+ it "should set the default language" do
35
+ controller.stub!(:params).and_return({})
36
+ controller.send :set_language
37
+ controller.session[:language_id].should == default_language.id
38
+ controller.session[:language_code].should == default_language.code
39
+ end
32
40
 
33
- it "should set the default language" do
34
- controller.stub!(:params).and_return({})
35
- controller.send :set_language
36
- controller.session[:language_id].should == Alchemy::Language.get_default.id
37
- controller.session[:language_code].should == Alchemy::Language.get_default.code
38
41
  end
39
42
 
40
- end
43
+ context "with lang param" do
41
44
 
42
- context "with lang param" do
45
+ it "should set the language" do
46
+ controller.stub!(:params).and_return({:lang => klingonian.code})
47
+ controller.send :set_language
48
+ controller.session[:language_id].should == klingonian.id
49
+ controller.session[:language_code].should == klingonian.code
50
+ end
43
51
 
44
- it "should set the language" do
45
- @language = FactoryGirl.create(:language)
46
- controller.stub!(:params).and_return({:lang => 'kl'})
47
- controller.send :set_language
48
- controller.session[:language_id].should == @language.id
49
- controller.session[:language_code].should == @language.code
50
- end
52
+ context "for language that does not exist" do
51
53
 
52
- context "for language that does not exist" do
54
+ it "should set the language to default" do
55
+ controller.stub!(:params).and_return({:lang => 'fo'})
56
+ controller.send :set_language
57
+ controller.session[:language_id].should == default_language.id
58
+ controller.session[:language_code].should == default_language.code
59
+ end
53
60
 
54
- it "should set the language to default" do
55
- controller.stub!(:params).and_return({:lang => 'fo'})
56
- controller.send :set_language
57
- controller.session[:language_id].should == Alchemy::Language.get_default.id
58
- controller.session[:language_code].should == Alchemy::Language.get_default.code
59
61
  end
60
62
 
61
63
  end
@@ -63,5 +65,4 @@ describe Alchemy::BaseController do
63
65
  end
64
66
 
65
67
  end
66
-
67
68
  end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ module Alchemy
4
+ describe ElementsController do
5
+
6
+ let(:page) { FactoryGirl.create(:public_page, :restricted => true) }
7
+ let(:element) { FactoryGirl.create(:element, :page => page, :name => 'download') }
8
+
9
+ it "should not be possible to see restricted elements" do
10
+ get :show, :id => element.id
11
+ response.status.should == 302
12
+ response.should redirect_to(login_path)
13
+ end
14
+
15
+ context "as a registered user" do
16
+
17
+ before do
18
+ activate_authlogic
19
+ UserSession.create(FactoryGirl.create(:registered_user))
20
+ end
21
+
22
+ it "should be possible to see restricted elements" do
23
+ get :show, :id => element.id
24
+ response.status.should == 200
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
@@ -12,7 +12,7 @@ describe Alchemy::PagesController do
12
12
  context "requested for a page containing a feed" do
13
13
 
14
14
  before(:each) do
15
- @page = FactoryGirl.create(:public_page, :parent_id => @default_language_root.id, :page_layout => 'news', :name => 'News', :language => @default_language)
15
+ @page = FactoryGirl.create(:public_page, :parent_id => @default_language_root.id, :page_layout => 'news', :name => 'News', :language => @default_language, :do_not_autogenerate => false)
16
16
  end
17
17
 
18
18
  it "should render a rss feed" do
@@ -42,8 +42,25 @@ describe Alchemy::PagesController do
42
42
  context "with param layout set to none" do
43
43
 
44
44
  it "should not render a layout" do
45
- get :show, :urlname => :home, :layout => false
46
- response.body.should_not have_content('<head>')
45
+ get :show, :urlname => :home, :layout => 'none'
46
+ response.body.should_not match /<head>/
47
+ end
48
+
49
+ end
50
+
51
+ context "with param layout set to false" do
52
+
53
+ it "should not render a layout" do
54
+ get :show, :urlname => :home, :layout => 'false'
55
+ response.body.should_not match /<head>/
56
+ end
57
+
58
+ end
59
+
60
+ context "with params layout set to not existing layout" do
61
+
62
+ it "should raise ActionController::RoutingError" do
63
+ expect { get :show, :urlname => :home, :layout => 'lkuiuk' }.to raise_error(ActionController::RoutingError)
47
64
  end
48
65
 
49
66
  end
@@ -104,8 +121,8 @@ describe Alchemy::PagesController do
104
121
  before(:each) do
105
122
  @catalog = FactoryGirl.create(:public_page, :name => "Catalog", :parent_id => @default_language_root.id, :language => @default_language)
106
123
  @products = FactoryGirl.create(:public_page, :name => "Products", :parent_id => @catalog.id, :language => @default_language)
107
- @product = FactoryGirl.create(:public_page, :name => "Screwdriver", :parent_id => @products.id, :language => @default_language)
108
- @product.elements.find_by_name('article').contents.essence_texts.first.essence.update_attribute(:body, 'screwdriver')
124
+ @product = FactoryGirl.create(:public_page, :name => "Screwdriver", :parent_id => @products.id, :language => @default_language, :do_not_autogenerate => false)
125
+ @product.elements.find_by_name('article').contents.essence_texts.first.essence.update_column(:body, 'screwdriver')
109
126
  controller.stub!(:configuration) { |arg| arg == :url_nesting ? true : false }
110
127
  end
111
128
 
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ # Fixes missing method tempfile error
4
+ class Rack::Test::UploadedFile
5
+ attr_reader :tempfile
6
+ end
7
+
8
+ module Alchemy
9
+ describe PicturesController do
10
+
11
+ let(:page) { FactoryGirl.create(:public_page, :restricted => false) }
12
+ let(:restricted_page) { FactoryGirl.create(:public_page, :restricted => true) }
13
+ let(:element) { FactoryGirl.create(:element, :page => page, :name => 'bild', :create_contents_after_create => true) }
14
+ let(:restricted_element) { FactoryGirl.create(:element, :page => restricted_page, :name => 'bild', :create_contents_after_create => true) }
15
+ let(:picture) { Picture.create(:image_file => fixture_file_upload(File.expand_path('../../support/image.png', __FILE__), 'image/png')) }
16
+
17
+ context "Requesting a picture that is not assigned with any page" do
18
+ it "should render the picture" do
19
+ get :show, :id => picture.id, :format => :png
20
+ response.status.should == 200
21
+ end
22
+ end
23
+
24
+ context "Requesting a picture that is assigned on restricted and non-restricted pages" do
25
+
26
+ before do
27
+ essence = element.contents.where(:name => 'image').first.essence
28
+ essence.picture_id = picture.id
29
+ essence.save
30
+
31
+ essence = restricted_element.contents.where(:name => 'image').first.essence
32
+ essence.picture_id = picture.id
33
+ essence.save
34
+ end
35
+
36
+ context "as guest user" do
37
+ it "should render the picture" do
38
+ get :show, :id => picture.id, :format => :png
39
+ response.status.should == 200
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ context "Requesting a picture that is assigned with restricted pages only" do
46
+
47
+ before do
48
+ essence = restricted_element.contents.where(:name => 'image').first.essence
49
+ essence.picture_id = picture.id
50
+ essence.save
51
+ end
52
+
53
+ context "as guest user" do
54
+
55
+ it "should not render the picture, but redirect to login path" do
56
+ get :show, :id => picture.id
57
+ response.status.should == 302
58
+ response.should redirect_to(login_path)
59
+ end
60
+
61
+ end
62
+
63
+ context "as registered user" do
64
+
65
+ before do
66
+ activate_authlogic
67
+ UserSession.create(FactoryGirl.create(:registered_user))
68
+ end
69
+
70
+ it "should render the picture" do
71
+ get :show, :id => picture.id, :format => :png
72
+ response.status.should == 200
73
+ end
74
+
75
+ end
76
+
77
+
78
+ end
79
+
80
+
81
+ end
82
+ end
@@ -1,4 +1,5 @@
1
1
  class Event < ActiveRecord::Base
2
- attr_accessible :name, :hidden_name, :starts_at, :ends_at, :description, :published, :entrance_fee, :location_id
2
+ attr_accessible :name, :hidden_name, :starts_at, :ends_at, :description, :published, :entrance_fee, :location_id, :organizer_id
3
3
  validates_presence_of :name
4
+
4
5
  end
@@ -5,13 +5,14 @@ sqlite: &sqlite
5
5
  mysql: &mysql
6
6
  adapter: mysql2
7
7
  username: root
8
- password:
8
+ password:
9
9
  database: alchemy_cms_dummy_<%= Rails.env %>
10
10
 
11
11
  postgresql: &postgresql
12
12
  adapter: postgresql
13
+ <% if ENV['CI'] %>
13
14
  username: postgres
14
- password:
15
+ <% end %>
15
16
  database: alchemy_cms_dummy_<%= Rails.env %>
16
17
  min_messages: ERROR
17
18
 
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20120611221734) do
14
+ ActiveRecord::Schema.define(:version => 20120831135441) do
15
15
 
16
16
  create_table "alchemy_attachments", :force => true do |t|
17
17
  t.string "name"
@@ -24,14 +24,6 @@ ActiveRecord::Schema.define(:version => 20120611221734) do
24
24
  t.datetime "updated_at", :null => false
25
25
  end
26
26
 
27
- create_table "alchemy_essence_booleans", :force => true do |t|
28
- t.boolean "value"
29
- t.timestamps
30
- t.userstamps
31
- end
32
-
33
- add_index "alchemy_essence_booleans", ["value"], :name => "index_alchemy_essence_booleans_on_value"
34
-
35
27
  create_table "alchemy_cells", :force => true do |t|
36
28
  t.integer "page_id"
37
29
  t.string "name"
@@ -86,6 +78,16 @@ ActiveRecord::Schema.define(:version => 20120611221734) do
86
78
  t.datetime "updated_at", :null => false
87
79
  end
88
80
 
81
+ create_table "alchemy_essence_booleans", :force => true do |t|
82
+ t.boolean "value"
83
+ t.datetime "created_at", :null => false
84
+ t.datetime "updated_at", :null => false
85
+ t.integer "creator_id"
86
+ t.integer "updater_id"
87
+ end
88
+
89
+ add_index "alchemy_essence_booleans", ["value"], :name => "index_alchemy_essence_booleans_on_value"
90
+
89
91
  create_table "alchemy_essence_dates", :force => true do |t|
90
92
  t.datetime "date"
91
93
  t.integer "creator_id"
@@ -154,9 +156,11 @@ ActiveRecord::Schema.define(:version => 20120611221734) do
154
156
  end
155
157
 
156
158
  create_table "alchemy_essence_selects", :force => true do |t|
157
- t.string "value"
158
- t.timestamps
159
- t.userstamps
159
+ t.string "value"
160
+ t.datetime "created_at", :null => false
161
+ t.datetime "updated_at", :null => false
162
+ t.integer "creator_id"
163
+ t.integer "updater_id"
160
164
  end
161
165
 
162
166
  add_index "alchemy_essence_selects", ["value"], :name => "index_alchemy_essence_selects_on_value"
@@ -205,7 +209,7 @@ ActiveRecord::Schema.define(:version => 20120611221734) do
205
209
  t.integer "creator_id"
206
210
  t.integer "updater_id"
207
211
  t.boolean "default", :default => false
208
- t.string "country_code"
212
+ t.string "country_code", :default => "", :null => false
209
213
  end
210
214
 
211
215
  add_index "alchemy_languages", ["language_code", "country_code"], :name => "index_alchemy_languages_on_language_code_and_country_code"
@@ -224,17 +228,17 @@ ActiveRecord::Schema.define(:version => 20120611221734) do
224
228
  t.integer "rgt"
225
229
  t.integer "parent_id"
226
230
  t.integer "depth"
227
- t.boolean "visible", :default => false
228
- t.boolean "public", :default => false
229
- t.boolean "locked", :default => false
231
+ t.boolean "visible", :default => false
232
+ t.boolean "public", :default => false
233
+ t.boolean "locked", :default => false
230
234
  t.integer "locked_by"
231
- t.boolean "restricted", :default => false
232
- t.boolean "robot_index", :default => true
233
- t.boolean "robot_follow", :default => true
234
- t.boolean "sitemap", :default => true
235
- t.boolean "layoutpage", :default => false
236
- t.datetime "created_at", :null => false
237
- t.datetime "updated_at", :null => false
235
+ t.boolean "restricted", :default => false
236
+ t.boolean "robot_index", :default => true
237
+ t.boolean "robot_follow", :default => true
238
+ t.boolean "sitemap", :default => true
239
+ t.boolean "layoutpage", :default => false
240
+ t.datetime "created_at", :null => false
241
+ t.datetime "updated_at", :null => false
238
242
  t.integer "creator_id"
239
243
  t.integer "updater_id"
240
244
  t.integer "language_id"
@@ -249,10 +253,12 @@ ActiveRecord::Schema.define(:version => 20120611221734) do
249
253
  t.string "image_filename"
250
254
  t.integer "image_width"
251
255
  t.integer "image_height"
252
- t.datetime "created_at", :null => false
253
- t.datetime "updated_at", :null => false
256
+ t.datetime "created_at", :null => false
257
+ t.datetime "updated_at", :null => false
254
258
  t.integer "creator_id"
255
259
  t.integer "updater_id"
260
+ t.string "upload_hash"
261
+ t.string "cached_tag_list"
256
262
  end
257
263
 
258
264
  create_table "alchemy_users", :force => true do |t|
@@ -292,8 +298,26 @@ ActiveRecord::Schema.define(:version => 20120611221734) do
292
298
  t.decimal "entrance_fee", :precision => 6, :scale => 2
293
299
  t.boolean "published"
294
300
  t.integer "location_id"
295
- t.datetime "created_at", :null => false
296
- t.datetime "updated_at", :null => false
301
+ t.integer "organizer_id"
302
+ t.datetime "created_at", :null => false
303
+ t.datetime "updated_at", :null => false
304
+ end
305
+
306
+ create_table "taggings", :force => true do |t|
307
+ t.integer "tag_id"
308
+ t.integer "taggable_id"
309
+ t.string "taggable_type"
310
+ t.integer "tagger_id"
311
+ t.string "tagger_type"
312
+ t.string "context"
313
+ t.datetime "created_at"
314
+ end
315
+
316
+ add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
317
+ add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
318
+
319
+ create_table "tags", :force => true do |t|
320
+ t.string "name"
297
321
  end
298
322
 
299
323
  end
@@ -25,27 +25,40 @@ FactoryGirl.define do
25
25
  end
26
26
 
27
27
  factory :language, :class => 'Alchemy::Language' do
28
- language_code "kl"
29
- name 'Klingonian'
30
- default false
31
- frontpage_name 'Tuq'
28
+ name 'Deutsch'
29
+ code 'de'
30
+ default true
31
+ frontpage_name 'Intro'
32
32
  page_layout 'intro'
33
33
  public true
34
34
 
35
- factory :language_with_country_code do
36
- country_code 'cr'
35
+ factory :klingonian do
36
+ name 'Klingonian'
37
+ code 'kl'
38
+ frontpage_name 'Tuq'
39
+ default false
40
+ end
41
+
42
+ factory :english do
43
+ name 'English'
44
+ code 'en'
45
+ frontpage_name 'Intro'
46
+ default false
37
47
  end
38
48
  end
39
49
 
40
50
  factory :page, :class => 'Alchemy::Page' do
41
51
 
42
- language { Alchemy::Language.find_by_language_code('kl') || FactoryGirl.create(:language) }
52
+ language { Alchemy::Language.get_default || FactoryGirl.create(:language) }
43
53
  sequence(:name) { |n| "A Page #{n}" }
44
54
  parent_id { (Alchemy::Page.find_by_language_root(true) || FactoryGirl.create(:language_root_page)).id }
45
55
  page_layout "standard"
46
56
 
57
+ # This speeds up creating of pages dramatically. Pass :do_not_autogenerate => false to generate elements
58
+ do_not_autogenerate true
59
+
47
60
  factory :language_root_page do
48
- name 'Klingonian'
61
+ name 'Startseite'
49
62
  page_layout 'intro'
50
63
  language_root true
51
64
  public true
@@ -74,6 +87,14 @@ FactoryGirl.define do
74
87
 
75
88
  factory :element, :class => 'Alchemy::Element' do
76
89
  name 'article'
90
+ create_contents_after_create false
91
+ end
92
+
93
+ factory :picture, :class => 'Alchemy::Picture' do
94
+ image_file File.new(File.expand_path('../support/image.png', __FILE__))
95
+ name 'image'
96
+ image_filename 'image.png'
97
+ upload_hash Time.now.hash
77
98
  end
78
99
 
79
100
  end