alchemy_cms 2.6.3 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/.simplecov +14 -0
  3. data/.travis.yml +1 -1
  4. data/Gemfile +7 -6
  5. data/README.md +15 -5
  6. data/alchemy_cms.gemspec +3 -2
  7. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +9 -17
  8. data/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +70 -0
  9. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +80 -0
  10. data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +43 -19
  11. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +3 -1
  12. data/app/assets/javascripts/alchemy/alchemy.js +4 -2
  13. data/app/assets/javascripts/alchemy/alchemy.onload.js.coffee +1 -1
  14. data/app/assets/javascripts/alchemy/alchemy.spinner.js.coffee +14 -0
  15. data/app/assets/javascripts/alchemy/alchemy.tinymce.js.coffee.erb +96 -0
  16. data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +22 -0
  17. data/app/assets/javascripts/alchemy/alchemy.windows.js.coffee +28 -17
  18. data/app/assets/stylesheets/alchemy/base.scss +6 -0
  19. data/app/assets/stylesheets/alchemy/elements.scss +2 -28
  20. data/app/assets/stylesheets/alchemy/errors.scss +1 -1
  21. data/app/assets/stylesheets/alchemy/menubar.css.scss +2 -0
  22. data/app/assets/stylesheets/alchemy/sitemap.scss +21 -34
  23. data/app/assets/stylesheets/alchemy/tables.scss +13 -3
  24. data/app/controllers/alchemy/admin/attachments_controller.rb +10 -5
  25. data/app/controllers/alchemy/admin/base_controller.rb +19 -0
  26. data/app/controllers/alchemy/admin/contents_controller.rb +1 -4
  27. data/app/controllers/alchemy/admin/dashboard_controller.rb +2 -1
  28. data/app/controllers/alchemy/admin/elements_controller.rb +1 -1
  29. data/app/controllers/alchemy/admin/essence_files_controller.rb +1 -1
  30. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +70 -56
  31. data/app/controllers/alchemy/admin/pages_controller.rb +37 -114
  32. data/app/controllers/alchemy/admin/pictures_controller.rb +5 -12
  33. data/app/controllers/alchemy/admin/resources_controller.rb +3 -1
  34. data/app/controllers/alchemy/admin/trash_controller.rb +1 -1
  35. data/app/controllers/alchemy/attachments_controller.rb +1 -1
  36. data/app/controllers/alchemy/base_controller.rb +3 -15
  37. data/app/controllers/alchemy/messages_controller.rb +4 -10
  38. data/app/controllers/alchemy/pages_controller.rb +6 -6
  39. data/app/controllers/alchemy/passwords_controller.rb +1 -1
  40. data/app/controllers/alchemy/user_sessions_controller.rb +1 -1
  41. data/app/helpers/alchemy/admin/base_helper.rb +49 -230
  42. data/app/helpers/alchemy/admin/contents_helper.rb +5 -1
  43. data/app/helpers/alchemy/admin/elements_helper.rb +19 -47
  44. data/app/helpers/alchemy/admin/essences_helper.rb +59 -17
  45. data/app/helpers/alchemy/admin/navigation_helper.rb +204 -0
  46. data/app/helpers/alchemy/admin/pages_helper.rb +22 -79
  47. data/app/helpers/alchemy/admin/pictures_helper.rb +1 -1
  48. data/app/helpers/alchemy/admin/tags_helper.rb +42 -0
  49. data/app/helpers/alchemy/base_helper.rb +0 -11
  50. data/app/helpers/alchemy/elements_helper.rb +48 -25
  51. data/app/helpers/alchemy/essences_helper.rb +0 -20
  52. data/app/helpers/alchemy/pages_helper.rb +18 -14
  53. data/app/helpers/alchemy/url_helper.rb +1 -0
  54. data/app/mailers/alchemy/messages.rb +4 -6
  55. data/app/models/alchemy/attachment.rb +3 -0
  56. data/app/models/alchemy/cell.rb +33 -35
  57. data/app/models/alchemy/content.rb +20 -111
  58. data/app/models/alchemy/content/factory.rb +188 -0
  59. data/app/models/alchemy/element.rb +51 -200
  60. data/app/models/alchemy/element/definitions.rb +52 -0
  61. data/app/models/alchemy/element/presenters.rb +87 -0
  62. data/app/models/alchemy/essence_date.rb +1 -1
  63. data/app/models/alchemy/essence_file.rb +6 -7
  64. data/app/models/alchemy/essence_picture.rb +19 -4
  65. data/app/models/alchemy/message.rb +18 -14
  66. data/app/models/alchemy/page.rb +120 -214
  67. data/app/models/alchemy/page/elements.rb +145 -36
  68. data/app/models/alchemy/page/natures.rb +90 -0
  69. data/app/models/alchemy/page/scopes.rb +93 -0
  70. data/app/models/alchemy/page/users.rb +25 -0
  71. data/app/models/alchemy/picture.rb +15 -0
  72. data/app/models/alchemy/site.rb +15 -1
  73. data/app/models/alchemy/site/layout.rb +38 -0
  74. data/app/models/alchemy/user.rb +13 -3
  75. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +7 -7
  76. data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +8 -8
  77. data/app/views/alchemy/admin/attachments/_tag_list.html.erb +1 -16
  78. data/app/views/alchemy/admin/attachments/destroy.js.erb +1 -4
  79. data/app/views/alchemy/admin/contents/create.js.erb +1 -1
  80. data/app/views/alchemy/admin/dashboard/index.html.erb +14 -13
  81. data/app/views/alchemy/admin/elements/_element_head.html.erb +7 -7
  82. data/app/views/alchemy/admin/elements/_refresh_editor.js.erb +10 -0
  83. data/app/views/alchemy/admin/elements/create.js.erb +44 -44
  84. data/app/views/alchemy/admin/elements/fold.js.erb +22 -26
  85. data/app/views/alchemy/admin/elements/trash.js.erb +1 -1
  86. data/app/views/alchemy/admin/elements/update.js.erb +22 -25
  87. data/app/views/alchemy/admin/essence_files/assign.js.erb +8 -3
  88. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +14 -12
  89. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +22 -39
  90. data/app/views/alchemy/admin/pages/_page.html.erb +73 -80
  91. data/app/views/alchemy/admin/pages/destroy.js.erb +2 -2
  92. data/app/views/alchemy/admin/pages/edit.html.erb +21 -18
  93. data/app/views/alchemy/admin/pages/fold.js.erb +1 -0
  94. data/app/views/alchemy/admin/pages/info.html.erb +32 -0
  95. data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +11 -13
  96. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +20 -20
  97. data/app/views/alchemy/admin/partials/_sub_navigation.html.erb +8 -0
  98. data/app/views/alchemy/admin/partials/_toolbar_button.html.erb +25 -0
  99. data/app/views/alchemy/admin/partials/_upload_form.html.erb +15 -15
  100. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +39 -39
  101. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +10 -10
  102. data/app/views/alchemy/admin/pictures/_tag_list.html.erb +1 -16
  103. data/app/views/alchemy/admin/resources/destroy.js.erb +1 -1
  104. data/app/views/alchemy/base/500.html.erb +1 -1
  105. data/app/views/alchemy/base/permission_denied.js.erb +1 -1
  106. data/app/views/alchemy/base/redirect.js.erb +1 -1
  107. data/app/views/alchemy/essences/_essence_link_editor.html.erb +1 -1
  108. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +1 -1
  109. data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +1 -1
  110. data/app/views/alchemy/essences/_essence_text_editor.html.erb +1 -1
  111. data/app/views/alchemy/essences/{_essence_picture_tools.html.erb → shared/_essence_picture_tools.html.erb} +5 -5
  112. data/app/views/alchemy/essences/{_linkable_essence_tools.html.erb → shared/_linkable_essence_tools.html.erb} +0 -0
  113. data/app/views/alchemy/messages/contact_form_mail.de.text.erb +12 -0
  114. data/app/views/alchemy/messages/contact_form_mail.en.text.erb +12 -0
  115. data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +1 -1
  116. data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +2 -2
  117. data/app/views/alchemy/pages/sitemap.xml.erb +3 -5
  118. data/app/views/alchemy/user_sessions/leave.html.erb +1 -1
  119. data/app/views/layouts/alchemy/admin.html.erb +4 -2
  120. data/app/views/layouts/alchemy/sitemap.xml.erb +1 -1
  121. data/bin/alchemy +7 -13
  122. data/config/alchemy/config.yml +1 -0
  123. data/config/authorization_rules.rb +2 -3
  124. data/config/initializers/dragonfly.rb +2 -0
  125. data/config/locales/alchemy.de.yml +8 -9
  126. data/config/locales/alchemy.en.yml +7 -4
  127. data/config/routes.rb +3 -0
  128. data/db/migrate/{20130214233001_alchemy_two_point_five.rb → 20130827094554_alchemy_two_point_six.rb} +29 -6
  129. data/lib/alchemy/auth/engine.rb +9 -0
  130. data/lib/alchemy/capistrano.rb +37 -12
  131. data/lib/alchemy/config.rb +48 -35
  132. data/lib/alchemy/engine.rb +35 -6
  133. data/lib/alchemy/essence.rb +25 -29
  134. data/lib/alchemy/ferret/search.rb +86 -0
  135. data/lib/alchemy/{scoped_pagination_url_helper.rb → kaminari/scoped_pagination_url_helper.rb} +0 -0
  136. data/lib/alchemy/logger.rb +3 -4
  137. data/lib/alchemy/page_layout.rb +124 -55
  138. data/lib/alchemy/resource.rb +0 -10
  139. data/lib/alchemy/resources_helper.rb +0 -5
  140. data/lib/alchemy/seeder.rb +1 -32
  141. data/lib/alchemy/shell.rb +6 -1
  142. data/lib/alchemy/tinymce.rb +41 -32
  143. data/lib/alchemy/upgrader.rb +3 -1
  144. data/lib/alchemy/upgrader/two_point_five.rb +15 -8
  145. data/lib/alchemy/upgrader/two_point_one.rb +10 -10
  146. data/lib/alchemy/upgrader/two_point_two.rb +96 -51
  147. data/lib/alchemy/version.rb +1 -1
  148. data/lib/alchemy_cms.rb +5 -46
  149. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +1 -1
  150. data/lib/rails/generators/alchemy/devise/devise_generator.rb +9 -4
  151. data/lib/rails/generators/alchemy/essence/essence_generator.rb +7 -6
  152. data/lib/rails/generators/alchemy/essence/templates/editor.html.erb +1 -1
  153. data/lib/rails/generators/alchemy/scaffold/files/_standard.html.erb +1 -0
  154. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +1 -0
  155. data/lib/rails/generators/alchemy/site_layouts/site_layouts_generator.rb +23 -0
  156. data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.erb +1 -0
  157. data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.haml +1 -0
  158. data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.slim +1 -0
  159. data/lib/rails/templates/alchemy.rb +2 -2
  160. data/lib/tasks/alchemy/db.rake +3 -1
  161. data/lib/tasks/alchemy/tidy.rake +82 -0
  162. data/lib/tasks/alchemy/upgrade.rake +2 -1
  163. data/spec/controllers/admin/attachments_controller_spec.rb +124 -0
  164. data/spec/controllers/admin/base_controller_spec.rb +35 -0
  165. data/spec/controllers/admin/clipboard_controller_spec.rb +1 -1
  166. data/spec/controllers/admin/contents_controller_spec.rb +17 -26
  167. data/spec/controllers/admin/dashboard_controller_spec.rb +121 -0
  168. data/spec/controllers/admin/elements_controller_spec.rb +1 -1
  169. data/spec/controllers/admin/essence_files_controller_spec.rb +67 -0
  170. data/spec/controllers/admin/essence_pictures_controller_spec.rb +161 -0
  171. data/spec/controllers/admin/languages_controller_spec.rb +1 -1
  172. data/spec/controllers/admin/layoutpages_controller_spec.rb +28 -0
  173. data/spec/controllers/admin/pages_controller_spec.rb +164 -118
  174. data/spec/controllers/admin/pictures_controller_spec.rb +89 -0
  175. data/spec/controllers/admin/trash_controller_spec.rb +21 -31
  176. data/spec/controllers/admin/users_controller_spec.rb +114 -85
  177. data/spec/controllers/attachments_controller_spec.rb +6 -2
  178. data/spec/controllers/base_controller_spec.rb +22 -0
  179. data/spec/controllers/elements_controller_spec.rb +1 -1
  180. data/spec/controllers/messages_controller_spec.rb +200 -0
  181. data/spec/controllers/pictures_controller_spec.rb +1 -1
  182. data/spec/controllers/user_sessions_controller_spec.rb +7 -6
  183. data/spec/controllers/users_controller_spec.rb +2 -2
  184. data/spec/dummy/config/alchemy/cells.yml +2 -0
  185. data/spec/dummy/config/application.rb +19 -8
  186. data/spec/dummy/db/migrate/{20130214233001_alchemy_two_point_five.rb → 20130827094554_alchemy_two_point_six.rb} +29 -6
  187. data/spec/dummy/db/schema.rb +1 -1
  188. data/spec/fast_specs.rb +15 -0
  189. data/spec/helpers/admin/base_helper_spec.rb +53 -34
  190. data/spec/helpers/admin/contents_helper_spec.rb +15 -7
  191. data/spec/helpers/admin/elements_helper_spec.rb +79 -34
  192. data/spec/helpers/admin/essences_helper_spec.rb +45 -31
  193. data/spec/helpers/admin/navigation_helper_spec.rb +204 -0
  194. data/spec/helpers/admin/pages_helper_spec.rb +25 -15
  195. data/spec/helpers/admin/tags_helper_spec.rb +62 -2
  196. data/spec/helpers/elements_helper_spec.rb +202 -138
  197. data/spec/helpers/pages_helper_spec.rb +48 -0
  198. data/spec/helpers/url_helper_spec.rb +7 -0
  199. data/spec/libraries/config_spec.rb +110 -3
  200. data/spec/libraries/essence_spec.rb +29 -9
  201. data/spec/libraries/page_layout_spec.rb +134 -0
  202. data/spec/libraries/resource_spec.rb +3 -16
  203. data/spec/libraries/resources_helper_spec.rb +4 -8
  204. data/spec/libraries/shell_spec.rb +1 -0
  205. data/spec/libraries/tinymce_spec.rb +61 -0
  206. data/spec/mailers/messages_spec.rb +23 -0
  207. data/spec/models/attachment_spec.rb +45 -0
  208. data/spec/models/cell_spec.rb +62 -9
  209. data/spec/models/content_spec.rb +110 -28
  210. data/spec/models/element_spec.rb +275 -253
  211. data/spec/models/essence_date_spec.rb +25 -0
  212. data/spec/models/essence_file_spec.rb +23 -0
  213. data/spec/models/essence_html_spec.rb +13 -0
  214. data/spec/models/essence_picture_spec.rb +16 -0
  215. data/spec/models/essence_text_spec.rb +29 -0
  216. data/spec/models/language_spec.rb +34 -0
  217. data/spec/models/message_spec.rb +43 -0
  218. data/spec/models/page_spec.rb +726 -567
  219. data/spec/models/picture_spec.rb +98 -0
  220. data/spec/models/site_spec.rb +60 -2
  221. data/spec/models/tag_spec.rb +31 -0
  222. data/spec/models/user_spec.rb +4 -4
  223. data/spec/spec_helper.rb +49 -58
  224. data/spec/support/alchemy/controller_helpers.rb +35 -0
  225. data/spec/support/alchemy/{specs_helpers.rb → integration_helpers.rb} +4 -8
  226. data/spec/{factories.rb → support/factories.rb} +11 -1
  227. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +2 -8
  228. metadata +166 -106
  229. data/Guardfile +0 -16
  230. data/app/assets/javascripts/alchemy/alchemy.dirty.js +0 -93
  231. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +0 -122
  232. data/app/models/alchemy/tree_node.rb +0 -4
  233. data/app/views/alchemy/admin/pages/_page_infos.html.erb +0 -3
  234. data/app/views/alchemy/admin/partials/_sub_navigation_tab.html.erb +0 -8
  235. data/app/views/alchemy/messages/contact_form_mail.text.erb +0 -12
  236. data/config/initializers/kaminari_config.rb +0 -9
  237. data/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +0 -21
  238. data/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +0 -11
  239. data/lib/alchemy/auth_engine.rb +0 -7
  240. data/lib/alchemy/authentication_helpers.rb +0 -9
  241. data/lib/alchemy/ferret_search.rb +0 -84
  242. data/lib/extensions/array.rb +0 -25
  243. data/lib/extensions/hash.rb +0 -34
  244. data/spec/dummy/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +0 -21
  245. data/spec/dummy/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +0 -11
  246. data/spec/models/page_layout_spec.rb +0 -60
@@ -57,7 +57,7 @@ module Alchemy
57
57
 
58
58
  context "as registered user" do
59
59
  before do
60
- sign_in :user, FactoryGirl.create(:registered_user)
60
+ sign_in(registered_user)
61
61
  end
62
62
 
63
63
  it "should render the picture" do
@@ -3,17 +3,18 @@ require 'spec_helper'
3
3
  module Alchemy
4
4
  describe UserSessionsController do
5
5
 
6
- let(:user) { FactoryGirl.create(:admin_user) }
7
- let(:alchemy_page) { FactoryGirl.create(:page) }
6
+ let(:user) { FactoryGirl.build_stubbed(:admin_user) }
8
7
 
9
- before { sign_in :user, user }
8
+ before do
9
+ controller.stub!(:store_user_request_time)
10
+ sign_in(user)
11
+ end
10
12
 
11
- describe "signout" do
13
+ describe "#destroy" do
12
14
  it "should unlock all pages" do
13
15
  @request.env["devise.mapping"] = Devise.mappings[:user]
14
- alchemy_page.lock(user)
16
+ user.should_receive(:unlock_pages!)
15
17
  delete :destroy
16
- user.locked_pages.should be_empty
17
18
  end
18
19
  end
19
20
 
@@ -33,10 +33,10 @@ module Alchemy
33
33
  describe '#create' do
34
34
  before { ActionMailer::Base.deliveries = [] }
35
35
 
36
- context "with send_credentials set to true" do
36
+ context "with send_credentials set to '1'" do
37
37
  it "should send an email notification" do
38
38
  post :create, {
39
- :user => FactoryGirl.attributes_for(:admin_user).merge(send_credentials: true)
39
+ :user => FactoryGirl.attributes_for(:admin_user).merge(send_credentials: '1')
40
40
  }
41
41
  ActionMailer::Base.deliveries.should_not be_empty
42
42
  end
@@ -0,0 +1,2 @@
1
+ - name: right_column
2
+ elements: [search]
@@ -1,18 +1,29 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  # Pick the frameworks you want:
4
- require "active_record/railtie"
5
- require "action_controller/railtie"
6
- require "action_mailer/railtie"
7
- require "active_resource/railtie"
8
- require "sprockets/railtie"
9
- # require "rails/test_unit/railtie"
4
+ if ENV['FAST_SPECS']
5
+ require "active_record/railtie"
6
+ require "action_controller/railtie"
7
+ require "action_mailer/railtie"
8
+ require "active_resource/railtie"
9
+ require "alchemy_cms"
10
+ else
11
+ require "active_record/railtie"
12
+ require "action_controller/railtie"
13
+ require "action_mailer/railtie"
14
+ require "active_resource/railtie"
15
+ require "sprockets/railtie"
16
+ end
10
17
 
11
18
  if defined?(Bundler)
12
19
  # If you precompile assets before deploying to production, use this line
13
- Bundler.require(*Rails.groups(:assets => %w(development test)))
20
+ # Bundler.require(*Rails.groups(:assets => %w(development test)))
14
21
  # If you want your assets lazily compiled in production, use this line
15
- # Bundler.require(:default, :assets, Rails.env)
22
+ if ENV['FAST_SPECS']
23
+ Bundler.require(:test)
24
+ else
25
+ Bundler.require(:default, :assets, Rails.env)
26
+ end
16
27
  end
17
28
 
18
29
  module Dummy
@@ -1,27 +1,30 @@
1
- # This is a compressed migration for creating all Alchemy 2.5 tables at once.
1
+ # This is a compressed migration for creating all Alchemy 2.6 tables at once.
2
2
  #
3
3
  # === Notice
4
4
  #
5
5
  # In order to upgrade from an old version of Alchemy, you have to run all migrations from
6
6
  # each version you missed up to the version you want to upgrade to, before running this migration.
7
7
  #
8
- class AlchemyTwoPointFive < ActiveRecord::Migration
8
+ class AlchemyTwoPointSix < ActiveRecord::Migration
9
9
  def up
10
10
  # Do not run if Alchemy tables are already present
11
11
  return if table_exists?(:alchemy_pages)
12
12
 
13
13
  create_table "alchemy_attachments", :force => true do |t|
14
14
  t.string "name"
15
- t.string "filename"
16
- t.string "content_type"
17
- t.integer "size"
15
+ t.string "file_name"
16
+ t.string "file_mime_type"
17
+ t.integer "file_size"
18
18
  t.integer "creator_id"
19
19
  t.integer "updater_id"
20
20
  t.datetime "created_at", :null => false
21
21
  t.datetime "updated_at", :null => false
22
22
  t.text "cached_tag_list"
23
+ t.string "file_uid"
23
24
  end
24
25
 
26
+ add_index "alchemy_attachments", ["file_uid"], :name => "index_alchemy_attachments_on_file_uid"
27
+
25
28
  create_table "alchemy_cells", :force => true do |t|
26
29
  t.integer "page_id"
27
30
  t.string "name"
@@ -268,7 +271,7 @@ class AlchemyTwoPointFive < ActiveRecord::Migration
268
271
  t.string "login"
269
272
  t.string "email"
270
273
  t.string "gender"
271
- t.string "role", :default => "registered"
274
+ t.string "roles", :default => "registered"
272
275
  t.string "language"
273
276
  t.string "encrypted_password", :limit => 128, :default => "", :null => false
274
277
  t.string "password_salt", :limit => 128, :default => "", :null => false
@@ -291,6 +294,26 @@ class AlchemyTwoPointFive < ActiveRecord::Migration
291
294
  add_index "alchemy_users", ["email"], :name => "index_alchemy_users_on_email", :unique => true
292
295
  add_index "alchemy_users", ["login"], :name => "index_alchemy_users_on_login", :unique => true
293
296
  add_index "alchemy_users", ["reset_password_token"], :name => "index_alchemy_users_on_reset_password_token", :unique => true
297
+ add_index "alchemy_users", ["roles"], :name => "index_alchemy_users_on_roles"
298
+
299
+ create_table "events", :force => true do |t|
300
+ t.string "name"
301
+ t.string "hidden_name"
302
+ t.datetime "starts_at"
303
+ t.datetime "ends_at"
304
+ t.text "description"
305
+ t.decimal "entrance_fee", :precision => 6, :scale => 2
306
+ t.boolean "published"
307
+ t.integer "location_id"
308
+ t.datetime "created_at", :null => false
309
+ t.datetime "updated_at", :null => false
310
+ end
311
+
312
+ create_table "locations", :force => true do |t|
313
+ t.string "name"
314
+ t.datetime "created_at", :null => false
315
+ t.datetime "updated_at", :null => false
316
+ end
294
317
 
295
318
  create_table "taggings", :force => true do |t|
296
319
  t.integer "tag_id"
@@ -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 => 20130328101418) do
14
+ ActiveRecord::Schema.define(:version => 20130827094554) do
15
15
 
16
16
  create_table "alchemy_attachments", :force => true do |t|
17
17
  t.string "name"
@@ -0,0 +1,15 @@
1
+ # Include this file insted of spec_helper, if you don't need database and other slow stuff
2
+ ENV["RAILS_ENV"] = "test"
3
+ ENV["FAST_SPECS"] = 'true'
4
+
5
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
6
+ require "rails/test_help"
7
+ require "rspec/rails"
8
+
9
+ Rails.logger.level = 4
10
+
11
+ RSpec.configure do |config|
12
+ config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ config.run_all_when_everything_filtered = true
14
+ config.filter_run :focus
15
+ end
@@ -96,54 +96,73 @@ module Alchemy
96
96
 
97
97
  end
98
98
 
99
- describe '#pages_for_select' do
100
-
101
- let(:contact_form) { FactoryGirl.create(:element, :name => 'contactform', :create_contents_after_create => true) }
102
- let(:page_a) { FactoryGirl.create(:public_page, :name => 'Page A') }
103
- let(:page_b) { FactoryGirl.create(:public_page, :name => 'Page B') }
104
- let(:page_c) { FactoryGirl.create(:public_page, :name => 'Page C', :parent_id => page_b.id) }
105
-
106
- before do
107
- # to be shure the ordering is alphabetic
108
- page_b
109
- page_a
110
- helper.session[:language_id] = 1
99
+ describe '#toolbar_button' do
100
+ context "with permission" do
101
+ before {
102
+ helper.stub(:permitted_to?).and_return(true)
103
+ }
104
+
105
+ it "renders a toolbar button" do
106
+ helper.toolbar_button(
107
+ url: admin_users_path
108
+ ).should match /<div.+class="button_with_label/
109
+ end
111
110
  end
112
111
 
113
- context "with no arguments given" do
112
+ context "without permission" do
113
+ before {
114
+ helper.stub(:permitted_to?).and_return(false)
115
+ }
114
116
 
115
- it "should return options for select with all pages ordered by lft" do
116
- helper.pages_for_select.should match(/option.*Page B.*Page A/m)
117
+ it "returns empty string" do
118
+ helper.toolbar_button(
119
+ url: admin_users_path
120
+ ).should be_empty
117
121
  end
122
+ end
118
123
 
119
- it "should return options for select with nested page names" do
120
- page_c
121
- output = helper.pages_for_select
122
- output.should match(/option.*Startseite.*>&nbsp;&nbsp;Page B.*>&nbsp;&nbsp;&nbsp;&nbsp;Page C.*>&nbsp;&nbsp;Page A/m)
123
- end
124
+ context "with disabled permission check" do
125
+ before {
126
+ helper.stub(:permitted_to?).and_return(false)
127
+ }
124
128
 
129
+ it "returns the button" do
130
+ helper.toolbar_button(
131
+ url: admin_users_path,
132
+ skip_permission_check: true
133
+ ).should match /<div.+class="button_with_label/
134
+ end
125
135
  end
126
136
 
127
- context "with pages passed in" do
137
+ context "with empty permission option" do
138
+ before {
139
+ helper.stub(:permitted_to?).and_return(true)
140
+ }
128
141
 
129
- before do
130
- @pages = []
131
- 3.times { @pages << FactoryGirl.create(:public_page) }
142
+ it "returns reads the permission from url" do
143
+ helper.should_receive(:permission_array_from_url)
144
+ helper.toolbar_button(
145
+ url: admin_users_path,
146
+ if_permitted_to: ''
147
+ ).should_not be_empty
132
148
  end
149
+ end
133
150
 
134
- it "should return options for select with only these pages" do
135
- output = helper.pages_for_select(@pages)
136
- output.should match(/#{@pages.collect(&:name).join('.*')}/m)
137
- output.should_not match(/Page A/m)
138
- end
151
+ context "with overlay option set to false" do
152
+ before {
153
+ helper.stub(:permitted_to?).and_return(true)
154
+ helper.should_receive(:permission_array_from_url)
155
+ }
139
156
 
140
- it "should not nest the page names" do
141
- output = helper.pages_for_select(@pages)
142
- output.should_not match(/option.*&nbsp;/m)
157
+ it "renders a normal link" do
158
+ button = helper.toolbar_button(
159
+ url: admin_users_path,
160
+ overlay: false
161
+ )
162
+ button.should match /<a.+href="#{admin_users_path}"/
163
+ button.should_not match /data-alchemy-overlay/
143
164
  end
144
-
145
165
  end
146
-
147
166
  end
148
167
 
149
168
  end
@@ -1,27 +1,35 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Alchemy::Admin::ContentsHelper do
4
+ let(:element) { FactoryGirl.create(:element, name: 'article', create_contents_after_create: true) }
4
5
 
5
- before(:each) do
6
- @element = FactoryGirl.create(:element, :name => 'article', :create_contents_after_create => true)
6
+ it "should render a dom id" do
7
+ helper.content_dom_id(element.content_by_type('EssenceText')).should match(/essence_text_\d{1,}/)
7
8
  end
8
9
 
9
- it "should render a dom id" do
10
- helper.content_dom_id(@element.content_by_type('EssenceText')).should match(/essence_text_\d{1,}/)
10
+ describe '#contents_form_field_ids_string' do
11
+ let(:content_1) { double('Alchemy::Content', form_field_id: 'contents_content_1_body') }
12
+ let(:content_2) { double('Alchemy::Content', form_field_id: 'contents_content_2_body') }
13
+
14
+ it "renders a jquery selector string of form field ids from given contents" do
15
+ expect(
16
+ helper.contents_form_field_ids_string([content_1, content_2])
17
+ ).to eq('#contents_content_1_body, #contents_content_2_body')
18
+ end
11
19
  end
12
20
 
13
21
  it "should render the content name" do
14
- helper.render_content_name(@element.content_by_type('EssenceText')).should == "Intro"
22
+ helper.render_content_name(element.content_by_type('EssenceText')).should == "Intro"
15
23
  end
16
24
 
17
25
  it "should render a link to add new content to element" do
18
26
  helper.stub!(:render_icon).and_return('')
19
- helper.render_new_content_link(@element).should match(/a.+href.*admin\/elements\/#{@element.id}\/contents\/new/m)
27
+ helper.render_new_content_link(element).should match(/a.+href.*admin\/elements\/#{element.id}\/contents\/new/m)
20
28
  end
21
29
 
22
30
  it "should render a link to create a content in element" do
23
31
  helper.stub!(:render_icon).and_return('')
24
- helper.render_create_content_link(@element, 'headline').should match(/a.+href.*admin\/contents.+class.+new_content_link.*data-method.+post/)
32
+ helper.render_create_content_link(element, 'headline').should match(/a.+href.*admin\/contents.+class.+new_content_link.*data-method.+post/)
25
33
  end
26
34
 
27
35
  end
@@ -1,56 +1,101 @@
1
1
  require 'spec_helper'
2
2
 
3
- include Alchemy::BaseHelper
3
+ module Alchemy
4
4
 
5
- describe Alchemy::Admin::ElementsHelper do
5
+ include BaseHelper
6
6
 
7
- context "partial rendering" do
7
+ describe Admin::ElementsHelper do
8
8
 
9
- before do
10
- @page = FactoryGirl.create(:public_page)
11
- @element = FactoryGirl.create(:element, :page => @page, :create_contents_after_create => true)
12
- end
9
+ context "partial rendering" do
13
10
 
14
- it "should render an element editor partial" do
15
- helper.render_editor(@element).should match(/class="essence_text content_editor".+id="essence_text_\d{1,}"/)
16
- end
11
+ before do
12
+ @page = FactoryGirl.create(:public_page)
13
+ @element = FactoryGirl.create(:element, :page => @page, :create_contents_after_create => true)
14
+ end
15
+
16
+ it "should render an element editor partial" do
17
+ helper.render_editor(@element).should match(/class="essence_text content_editor".+id="essence_text_\d{1,}"/)
18
+ end
19
+
20
+ it "should render a picture gallery editor partial" do
21
+ helper.render_picture_gallery_editor(@element).should match(/class=".+picture_gallery_editor"/)
22
+ end
17
23
 
18
- it "should render a picture gallery editor partial" do
19
- helper.render_picture_gallery_editor(@element).should match(/class=".+picture_gallery_editor"/)
20
24
  end
21
25
 
22
- end
26
+ describe "#grouped_elements_for_select" do
23
27
 
24
- describe "#grouped_elements_for_select" do
28
+ before do
29
+ @page = FactoryGirl.create(:public_page)
30
+ end
25
31
 
26
- before do
27
- @page = FactoryGirl.create(:public_page)
28
- end
32
+ before(:each) do
33
+ @page.stub!(:layout_description).and_return({'name' => "foo", 'cells' => ["foo_cell"]})
34
+ cell_descriptions = [{'name' => "foo_cell", 'elements' => ["1", "2"]}]
35
+ @elements = [
36
+ mock_model('Element', name: '1', display_name: '1'),
37
+ mock_model('Element', name: '2', display_name: '2')
38
+ ]
39
+ Alchemy::Cell.stub!(:definitions).and_return(cell_descriptions)
40
+ end
29
41
 
30
- before(:each) do
31
- @page.stub!(:layout_description).and_return({'name' => "foo", 'cells' => ["foo_cell"]})
32
- cell_descriptions = [{'name' => "foo_cell", 'elements' => ["1", "2"]}]
33
- @elements = [{'name' => '1'}, {'name' => '2'}]
34
- Alchemy::Cell.stub!(:definitions).and_return(cell_descriptions)
35
- end
42
+ it "should return string of elements grouped by cell for select_tag helper" do
43
+ helper.grouped_elements_for_select(@elements).should == helper.grouped_options_for_select({"Foo cell" => [["1", "1#foo_cell"], ["2", "2#foo_cell"]]})
44
+ end
36
45
 
37
- it "should return string of elements grouped by cell for select_tag helper" do
38
- helper.grouped_elements_for_select(@elements).should == helper.grouped_options_for_select({"Foo cell" => [["1", "1#foo_cell"], ["2", "2#foo_cell"]]})
39
- end
46
+ context "with empty elements array" do
47
+ it "should return an empty string" do
48
+ helper.grouped_elements_for_select([]).should == ""
49
+ end
50
+ end
40
51
 
41
- context "with empty elements array" do
42
- it "should return an empty string" do
43
- helper.grouped_elements_for_select([]).should == ""
52
+ context "with empty cell definitions" do
53
+ it "should return an empty string" do
54
+ @page.stub!(:layout_description).and_return({'name' => "foo"})
55
+ helper.grouped_elements_for_select(@elements).should == ""
56
+ end
44
57
  end
58
+
45
59
  end
46
60
 
47
- context "with empty cell definitions" do
48
- it "should return an empty string" do
49
- @page.stub!(:layout_description).and_return({'name' => "foo"})
50
- helper.grouped_elements_for_select(@elements).should == ""
61
+ describe "#elements_for_select" do
62
+
63
+ context "passing element instances" do
64
+ let(:element_objects) do
65
+ [
66
+ mock_model('Element', name: 'element_1', display_name: 'Element 1'),
67
+ mock_model('Element', name: 'element_2', display_name: 'Element 2')
68
+ ]
69
+ end
70
+
71
+ it "should return a String with html option tags" do
72
+ helper.should_receive(:options_for_select)
73
+ helper.elements_for_select(element_objects)
74
+ end
75
+ end
76
+
77
+ context "passing a hash with element descriptions" do
78
+ let(:element_descriptions) do
79
+ [{
80
+ 'name' => 'headline',
81
+ 'contents' => []
82
+ }]
83
+ end
84
+
85
+ subject { helper.elements_for_select(element_descriptions) }
86
+
87
+ it "should return a String with html option tags" do
88
+ helper.should_receive(:options_for_select)
89
+ subject
90
+ end
91
+
92
+ it "should render the elements display name" do
93
+ Element.should_receive(:display_name_for).with('headline')
94
+ subject
95
+ end
51
96
  end
97
+
52
98
  end
53
99
 
54
100
  end
55
-
56
101
  end