kuhsaft 0.3.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. data/README.md +127 -77
  2. data/Rakefile +15 -10
  3. data/app/assets/javascripts/kuhsaft/application.js +2 -0
  4. data/app/assets/javascripts/kuhsaft/cms/application.js +16 -4
  5. data/app/assets/javascripts/kuhsaft/cms/customizations.js +1 -0
  6. data/app/assets/stylesheets/kuhsaft/application.css.sass +4 -0
  7. data/app/assets/stylesheets/kuhsaft/cms/application.css.sass +125 -0
  8. data/app/assets/stylesheets/kuhsaft/cms/customizations.css.sass +1 -0
  9. data/app/controllers/kuhsaft/application_controller.rb +5 -0
  10. data/app/controllers/kuhsaft/cms/admin_controller.rb +8 -10
  11. data/app/controllers/kuhsaft/cms/bricks_controller.rb +35 -0
  12. data/app/controllers/kuhsaft/cms/pages_controller.rb +16 -19
  13. data/app/controllers/kuhsaft/pages_controller.rb +4 -10
  14. data/app/helpers/cms_helper.rb +3 -3
  15. data/app/helpers/kuhsaft/application_helper.rb +21 -0
  16. data/app/helpers/kuhsaft/cms/application_helper.rb +10 -0
  17. data/app/helpers/kuhsaft/cms/pages_helper.rb +14 -0
  18. data/app/helpers/pages_helper.rb +18 -21
  19. data/app/models/kuhsaft/accordion_brick.rb +16 -0
  20. data/app/models/kuhsaft/accordion_item_brick.rb +22 -0
  21. data/app/models/kuhsaft/brick.rb +85 -0
  22. data/app/models/kuhsaft/brick_type.rb +7 -0
  23. data/app/models/kuhsaft/cms.rb +7 -0
  24. data/app/models/kuhsaft/cms/admin.rb +20 -0
  25. data/app/models/kuhsaft/column_brick.rb +23 -0
  26. data/app/models/kuhsaft/image_brick.rb +19 -0
  27. data/app/models/kuhsaft/image_size.rb +52 -0
  28. data/app/models/kuhsaft/link_brick.rb +19 -0
  29. data/app/models/kuhsaft/page.rb +83 -101
  30. data/app/models/kuhsaft/partition.rb +18 -0
  31. data/app/models/kuhsaft/placeholder_brick.rb +11 -0
  32. data/app/models/kuhsaft/slider_brick.rb +16 -0
  33. data/app/models/kuhsaft/text_brick.rb +9 -0
  34. data/app/models/kuhsaft/two_column_brick.rb +50 -0
  35. data/app/models/kuhsaft/video_brick.rb +20 -0
  36. data/app/uploaders/kuhsaft/asset_uploader.rb +2 -2
  37. data/app/uploaders/kuhsaft/image_brick_image_uploader.rb +63 -0
  38. data/app/views/kuhsaft/accordion_bricks/_accordion_brick.html.haml +3 -0
  39. data/app/{assets/stylesheets/kuhsaft/cms/base/partials/_forms.css.sass → views/kuhsaft/accordion_bricks/accordion_brick/_edit.html.haml} +0 -0
  40. data/app/views/kuhsaft/accordion_item_bricks/_accordion_item_brick.html.haml +8 -0
  41. data/app/views/kuhsaft/accordion_item_bricks/accordion_item_brick/_edit.html.haml +1 -0
  42. data/app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml +10 -0
  43. data/app/views/kuhsaft/cms/admin/_content_language_switch.html.haml +7 -0
  44. data/app/views/kuhsaft/cms/admin/_empty_state.html.haml +5 -0
  45. data/app/views/kuhsaft/cms/admin/_main_navigation.html.haml +6 -0
  46. data/app/views/kuhsaft/cms/assets/index.html.haml +2 -2
  47. data/app/views/kuhsaft/cms/bricks/_brick_item.html.haml +38 -0
  48. data/app/views/kuhsaft/cms/bricks/_brick_list.html.haml +4 -0
  49. data/app/views/kuhsaft/cms/bricks/create.js.haml +1 -0
  50. data/app/views/kuhsaft/cms/bricks/destroy.js.haml +7 -0
  51. data/app/views/kuhsaft/cms/bricks/update.js.haml +2 -0
  52. data/app/views/kuhsaft/cms/pages/_branch.html.haml +17 -9
  53. data/app/views/kuhsaft/cms/pages/_form.html.haml +25 -60
  54. data/app/views/kuhsaft/cms/pages/edit.html.haml +14 -8
  55. data/app/views/kuhsaft/cms/pages/index.html.haml +8 -8
  56. data/app/views/kuhsaft/cms/pages/new.html.haml +1 -10
  57. data/app/views/kuhsaft/column_bricks/_column_brick.html.haml +3 -0
  58. data/app/views/kuhsaft/{cms/page_parts/edit.html.haml → column_bricks/column_brick/_edit.html.haml} +0 -0
  59. data/app/views/kuhsaft/image_bricks/_image_brick.html.haml +9 -0
  60. data/app/views/kuhsaft/image_bricks/image_brick/_edit.html.haml +10 -0
  61. data/app/views/kuhsaft/link_bricks/_link_brick.html.haml +3 -0
  62. data/app/views/kuhsaft/link_bricks/link_brick/_edit.html.haml +3 -0
  63. data/app/views/kuhsaft/pages/show.html.haml +5 -3
  64. data/app/views/kuhsaft/placeholder_bricks/_placeholder_brick.html.haml +2 -0
  65. data/app/views/kuhsaft/placeholder_bricks/placeholder_brick/_edit.html.haml +1 -0
  66. data/app/views/kuhsaft/slider_bricks/_slider_brick.html.haml +10 -0
  67. data/app/views/kuhsaft/{cms/page_parts/index.html.haml → slider_bricks/slider_brick/_edit.html.haml} +0 -0
  68. data/app/views/kuhsaft/text_bricks/_text_brick.html.haml +12 -0
  69. data/app/views/kuhsaft/text_bricks/text_brick/_edit.html.haml +2 -0
  70. data/app/views/kuhsaft/two_column_bricks/_two_column_brick.html.haml +3 -0
  71. data/app/views/kuhsaft/two_column_bricks/two_column_brick/_childs.html.haml +5 -0
  72. data/app/views/kuhsaft/two_column_bricks/two_column_brick/_edit.html.haml +1 -0
  73. data/app/views/kuhsaft/video_bricks/_video_brick.html.haml +9 -0
  74. data/app/views/kuhsaft/video_bricks/video_brick/_edit.html.haml +8 -0
  75. data/app/views/layouts/kuhsaft/cms/application.html.haml +20 -0
  76. data/config/initializers/devise.rb +231 -0
  77. data/config/initializers/simple_form.rb +142 -0
  78. data/config/initializers/simple_form_bootstrap.rb +45 -0
  79. data/config/locales/kuhsaft.en.yml +4 -1
  80. data/config/locales/models/kuhsaft/accordion_brick/de.yml +4 -0
  81. data/config/locales/models/kuhsaft/accordion_item_brick/de.yml +7 -0
  82. data/config/locales/models/kuhsaft/column_brick/de.yml +6 -0
  83. data/config/locales/models/kuhsaft/image_brick/de.yml +10 -0
  84. data/config/locales/models/kuhsaft/image_size/de.yml +13 -0
  85. data/config/locales/models/kuhsaft/link_brick/de.yml +9 -0
  86. data/config/locales/models/kuhsaft/page/de.yml +17 -0
  87. data/config/locales/models/kuhsaft/placeholder_brick/de.yml +8 -0
  88. data/config/locales/models/kuhsaft/slider_brick/de.yml +4 -0
  89. data/config/locales/models/kuhsaft/text_brick/de.yml +8 -0
  90. data/config/locales/models/kuhsaft/two_column_brick/de.yml +7 -0
  91. data/config/locales/models/kuhsaft/video_brick/de.yml +9 -0
  92. data/config/locales/simple_form.en.yml +26 -0
  93. data/config/locales/views/kuhsaft/cms/admin/de.yml +10 -0
  94. data/config/locales/views/kuhsaft/cms/bricks/de.yml +8 -0
  95. data/config/locales/views/kuhsaft/cms/pages/de.yml +9 -0
  96. data/config/locales/views/kuhsaft/cms/video_bricks/de.yml +7 -0
  97. data/config/locales/views/kuhsaft/text_brick/de.yml +6 -0
  98. data/config/locales/views/layouts/de.yml +6 -0
  99. data/config/routes.rb +10 -11
  100. data/db/migrate/01_create_kuhsaft_pages.rb +31 -0
  101. data/db/migrate/02_create_kuhsaft_bricks.rb +23 -0
  102. data/db/migrate/03_create_kuhsaft_brick_types.rb +12 -0
  103. data/db/migrate/04_create_kuhsaft_assets.rb +10 -0
  104. data/db/migrate/05_create_kuhsaft_cms_admins.rb +46 -0
  105. data/db/migrate/06_add_template_name_to_kuhsaft_bricks.rb +7 -0
  106. data/db/seeds.rb +14 -0
  107. data/lib/generators/kuhsaft/translations/add_generator.rb +26 -0
  108. data/lib/kuhsaft.rb +8 -1
  109. data/lib/kuhsaft/brick_list.rb +71 -0
  110. data/lib/kuhsaft/engine.rb +17 -12
  111. data/lib/kuhsaft/partial_extractor.rb +21 -0
  112. data/lib/kuhsaft/translatable.rb +40 -0
  113. data/lib/kuhsaft/version.rb +1 -1
  114. data/lib/tasks/kuhsaft_tasks.rake +10 -0
  115. data/lib/templates/kuhsaft/translations/add_translation.html.erb +13 -0
  116. data/spec/dummy/Rakefile +1 -1
  117. data/spec/dummy/app/assets/javascripts/application.js +9 -3
  118. data/spec/dummy/app/assets/stylesheets/application.css +11 -5
  119. data/spec/dummy/app/controllers/application_controller.rb +0 -6
  120. data/spec/dummy/app/views/layouts/application.html.erb +1 -1
  121. data/spec/dummy/config/application.rb +24 -7
  122. data/spec/dummy/config/boot.rb +3 -2
  123. data/spec/dummy/config/database.yml +6 -3
  124. data/spec/dummy/config/environments/development.rb +8 -1
  125. data/spec/dummy/config/environments/production.rb +9 -2
  126. data/spec/dummy/config/environments/test.rb +4 -9
  127. data/spec/dummy/config/initializers/inflections.rb +5 -0
  128. data/spec/dummy/config/initializers/secret_token.rb +1 -1
  129. data/spec/dummy/config/initializers/session_store.rb +1 -1
  130. data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
  131. data/spec/dummy/config/locales/en.yml +2 -2
  132. data/spec/dummy/config/routes.rb +2 -57
  133. data/spec/dummy/db/{migrate/.gitkeep → .gitkeep} +0 -0
  134. data/spec/dummy/public/500.html +0 -1
  135. data/spec/dummy/{lib/tasks → public/stylesheets}/.gitkeep +0 -0
  136. data/spec/factories.rb +11 -17
  137. data/spec/features/cms_auth_spec.rb +9 -0
  138. data/spec/features/cms_pages_spec.rb +23 -0
  139. data/spec/helpers/kuhsaft/cms/application_helper_spec.rb +25 -0
  140. data/spec/lib/brick_list_spec.rb +39 -0
  141. data/spec/lib/engine_spec.rb +25 -0
  142. data/spec/lib/translatable_spec.rb +85 -0
  143. data/spec/models/accordion_brick_spec.rb +32 -0
  144. data/spec/models/accordion_item_brick_spec.rb +50 -0
  145. data/spec/models/asset_spec.rb +25 -23
  146. data/spec/models/brick_spec.rb +110 -0
  147. data/spec/models/cms/admin_spec.rb +26 -0
  148. data/spec/models/column_brick_spec.rb +32 -0
  149. data/spec/models/image_brick_spec.rb +36 -0
  150. data/spec/models/image_size_spec.rb +36 -0
  151. data/spec/models/link_brick_spec.rb +45 -0
  152. data/spec/models/page_spec.rb +262 -281
  153. data/spec/models/placeholder_brick_spec.rb +40 -0
  154. data/spec/models/slider_brick_spec.rb +20 -0
  155. data/spec/models/text_brick_spec.rb +14 -0
  156. data/spec/models/two_column_brick_spec.rb +72 -0
  157. data/spec/models/video_brick_spec.rb +26 -0
  158. data/spec/spec_helper.rb +60 -51
  159. data/spec/support/kuhsaft_spec_helper.rb +4 -28
  160. data/spec/support/request_macros.rb +19 -0
  161. data/vendor/assets/javascripts/redactor.min.js +12 -0
  162. data/vendor/assets/stylesheets/redactor.css +692 -0
  163. metadata +402 -346
  164. data/.gitignore +0 -19
  165. data/.rspec +0 -2
  166. data/.rvmrc +0 -47
  167. data/CHANGELOG.md +0 -81
  168. data/Gemfile +0 -2
  169. data/Guardfile +0 -25
  170. data/LICENSE +0 -7
  171. data/app/assets/images/kuhsaft/add-child-page.png +0 -0
  172. data/app/assets/images/kuhsaft/closedhand.cur +0 -0
  173. data/app/assets/images/kuhsaft/delete.png +0 -0
  174. data/app/assets/images/kuhsaft/header-bg.jpg +0 -0
  175. data/app/assets/images/kuhsaft/module-nav-tab-bg.png +0 -0
  176. data/app/assets/images/kuhsaft/openhand.cur +0 -0
  177. data/app/assets/images/kuhsaft/page-edit-icon.png +0 -0
  178. data/app/assets/images/kuhsaft/page-new-icon.png +0 -0
  179. data/app/assets/images/kuhsaft/page-part-draggable-area.png +0 -0
  180. data/app/assets/images/kuhsaft/page-tree-breadcrumb-arrow.png +0 -0
  181. data/app/assets/images/kuhsaft/pages-breadcrumb-icon.png +0 -0
  182. data/app/assets/images/kuhsaft/tab-bg.png +0 -0
  183. data/app/assets/images/kuhsaft/toggle-arrow-closed.png +0 -0
  184. data/app/assets/images/kuhsaft/toggle-arrow-open.png +0 -0
  185. data/app/assets/images/kuhsaft/wrapper-bg.png +0 -0
  186. data/app/assets/javascripts/kuhsaft/cms/backend.js +0 -34
  187. data/app/assets/javascripts/kuhsaft/cms/jquery-ui-1.8.12.custom.min.js +0 -192
  188. data/app/assets/javascripts/kuhsaft/cms/jquery.elastic.source.js +0 -161
  189. data/app/assets/javascripts/kuhsaft/cms/jquery.min.js +0 -18
  190. data/app/assets/javascripts/kuhsaft/cms/jquery_ujs.js +0 -336
  191. data/app/assets/stylesheets/kuhsaft/cms/application.css +0 -6
  192. data/app/assets/stylesheets/kuhsaft/cms/base/base.css.sass +0 -9
  193. data/app/assets/stylesheets/kuhsaft/cms/base/partials/_assets.css.sass +0 -15
  194. data/app/assets/stylesheets/kuhsaft/cms/base/partials/_buttons.css.sass +0 -34
  195. data/app/assets/stylesheets/kuhsaft/cms/base/partials/_generic.css.sass +0 -342
  196. data/app/assets/stylesheets/kuhsaft/cms/base/partials/_simple_form.css.sass +0 -76
  197. data/app/controllers/kuhsaft/cms/page_parts_controller.rb +0 -34
  198. data/app/models/kuhsaft/localized_page.rb +0 -81
  199. data/app/models/kuhsaft/page_part.rb +0 -12
  200. data/app/models/kuhsaft/page_part/content.rb +0 -76
  201. data/app/models/kuhsaft/page_part/markdown.rb +0 -8
  202. data/app/views/kuhsaft/cms/page_parts/destroy.js.haml +0 -1
  203. data/app/views/kuhsaft/cms/page_parts/new.html.haml +0 -0
  204. data/app/views/kuhsaft/cms/page_parts/show.html.haml +0 -0
  205. data/app/views/kuhsaft/cms/page_parts/update.js.haml +0 -0
  206. data/app/views/kuhsaft/page_part/markdowns/_edit_markdown.html.haml +0 -1
  207. data/app/views/kuhsaft/page_part/markdowns/_show_markdown.html.haml +0 -1
  208. data/app/views/kuhsaft/pages/index.html.haml +0 -0
  209. data/app/views/layouts/kuhsaft/admin.html.haml +0 -35
  210. data/config/initializers/generators.rb +0 -7
  211. data/config/initializers/page_parts.rb +0 -17
  212. data/kuhsaft.gemspec +0 -39
  213. data/lib/generators/kuhsaft/install/assets_generator.rb +0 -12
  214. data/lib/generators/kuhsaft/install/migrations_generator.rb +0 -43
  215. data/lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb +0 -37
  216. data/lib/templates/kuhsaft/install/add_fulltext_to_localized_page.rb +0 -9
  217. data/lib/templates/kuhsaft/install/add_page_type_to_localized_pages.rb +0 -9
  218. data/lib/templates/kuhsaft/install/add_published_at_to_localized_pages.rb +0 -9
  219. data/lib/templates/kuhsaft/install/add_tags_to_page_part_contents.rb +0 -9
  220. data/lib/templates/kuhsaft/install/add_type_to_page_part_contents.rb +0 -9
  221. data/lib/templates/kuhsaft/install/add_url_to_localized_pages.rb +0 -9
  222. data/lib/templates/kuhsaft/install/create_assets.rb +0 -12
  223. data/lib/templates/kuhsaft/install/create_kuhsaft_localized_pages.rb +0 -19
  224. data/lib/templates/kuhsaft/install/create_kuhsaft_pages.rb +0 -14
  225. data/lib/templates/kuhsaft/install/create_page_part_contents.rb +0 -14
  226. data/spec/controllers/cms_assets_controller_spec.rb +0 -26
  227. data/spec/controllers/cms_pages_controller_spec.rb +0 -65
  228. data/spec/controllers/page_parts_controller_spec.rb +0 -60
  229. data/spec/controllers/pages_controller_spec.rb +0 -30
  230. data/spec/dummy/app/assets/images/rails.png +0 -0
  231. data/spec/helpers/cms_helper_spec.rb +0 -22
  232. data/spec/helpers/pages_helper_spec.rb +0 -119
  233. data/spec/integration/navigation_spec.rb +0 -9
  234. data/spec/models/localized_page_spec.rb +0 -266
  235. data/spec/models/page_part_content_spec.rb +0 -95
  236. data/spec/models/page_part_spec.rb +0 -17
  237. data/spec/requests/cms_pages_spec.rb +0 -27
  238. data/spec/routing/assets_routing_spec.rb +0 -63
  239. data/spec/routing/page_part_routing_spec.rb +0 -70
  240. data/spec/routing/pages_routing_spec.rb +0 -74
@@ -2,9 +2,9 @@ Dummy::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
4
  # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
5
+ # test suite. You never need to work with it otherwise. Remember that
6
6
  # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
7
+ # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = true
9
9
 
10
10
  # Configure static asset server for tests with Cache-Control for performance
@@ -29,14 +29,9 @@ Dummy::Application.configure do
29
29
  # ActionMailer::Base.deliveries array.
30
30
  config.action_mailer.delivery_method = :test
31
31
 
32
- # Use SQL instead of Active Record's schema dumper when creating the test database.
33
- # This is necessary if your schema can't be completely dumped by the schema dumper,
34
- # like if you have constraints or database-specific column types
35
- # config.active_record.schema_format = :sql
32
+ # Raise exception on mass assignment protection for Active Record models
33
+ config.active_record.mass_assignment_sanitizer = :strict
36
34
 
37
35
  # Print deprecation notices to the stderr
38
36
  config.active_support.deprecation = :stderr
39
-
40
- # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
41
- config.assets.allow_debugging = true
42
37
  end
@@ -8,3 +8,8 @@
8
8
  # inflect.irregular 'person', 'people'
9
9
  # inflect.uncountable %w( fish sheep )
10
10
  # end
11
+ #
12
+ # These inflection rules are supported but not enabled by default:
13
+ # ActiveSupport::Inflector.inflections do |inflect|
14
+ # inflect.acronym 'RESTful'
15
+ # end
@@ -4,4 +4,4 @@
4
4
  # If you change this key, all old signed cookies will become invalid!
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = '0d5c3beaf628d165c2d8241c7a09690eb1a25e5d03829f090b43a23783ea0c7596b6aed009f996a37911532f60831363719babc47ffdf3cc2632784879f9164b'
7
+ Dummy::Application.config.secret_token = '5577820f2c8866989aa7588272eba883f77a3da3c23f151633a379a619dcbd803ef1e9cb9cf5f1c4103662fa5c8e149011cbbb3850c0f845c7707c583b937734'
@@ -1,6 +1,6 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
4
 
5
5
  # Use the database for sessions instead of the cookie-based default,
6
6
  # which shouldn't be used to store highly confidential information
@@ -5,7 +5,7 @@
5
5
 
6
6
  # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
7
  ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters :format => [:json]
8
+ wrap_parameters format: [:json]
9
9
  end
10
10
 
11
11
  # Disable root element in JSON by default.
@@ -1,5 +1,5 @@
1
1
  # Sample localization file for English. Add more files in this directory for other locales.
2
- # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
3
 
4
4
  en:
5
- nothing: ''
5
+ hello: "Hello world"
@@ -1,58 +1,3 @@
1
- Dummy::Application.routes.draw do
2
- # The priority is based upon order of creation:
3
- # first created -> highest priority.
4
-
5
- # Sample of regular route:
6
- # match 'products/:id' => 'catalog#view'
7
- # Keep in mind you can assign values other than :controller and :action
8
-
9
- # Sample of named route:
10
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
11
- # This route can be invoked with purchase_url(:id => product.id)
12
-
13
- # Sample resource route (maps HTTP verbs to controller actions automatically):
14
- # resources :products
15
-
16
- # Sample resource route with options:
17
- # resources :products do
18
- # member do
19
- # get 'short'
20
- # post 'toggle'
21
- # end
22
- #
23
- # collection do
24
- # get 'sold'
25
- # end
26
- # end
27
-
28
- # Sample resource route with sub-resources:
29
- # resources :products do
30
- # resources :comments, :sales
31
- # resource :seller
32
- # end
33
-
34
- # Sample resource route with more complex sub-resources
35
- # resources :products do
36
- # resources :comments
37
- # resources :sales do
38
- # get 'recent', :on => :collection
39
- # end
40
- # end
41
-
42
- # Sample resource route within a namespace:
43
- # namespace :admin do
44
- # # Directs /admin/products/* to Admin::ProductsController
45
- # # (app/controllers/admin/products_controller.rb)
46
- # resources :products
47
- # end
48
-
49
- # You can have the root of your site routed with "root"
50
- # just remember to delete public/index.html.
51
- # root :to => "welcome#index"
52
-
53
- # See how all your routes lay out with "rake routes"
54
-
55
- # This is a legacy wild controller route that's not recommended for RESTful applications.
56
- # Note: This route will make all actions in every controller accessible via GET requests.
57
- # match ':controller(/:action(/:id(.:format)))'
1
+ Rails.application.routes.draw do
2
+ mount Kuhsaft::Engine => "/"
58
3
  end
@@ -20,7 +20,6 @@
20
20
  <!-- This file lives in public/500.html -->
21
21
  <div class="dialog">
22
22
  <h1>We're sorry, but something went wrong.</h1>
23
- <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
23
  </div>
25
24
  </body>
26
25
  </html>
@@ -1,21 +1,15 @@
1
- Factory.define :localized_page, :class => Kuhsaft::LocalizedPage do |p|
2
- p.locale 'en'
3
- p.title { "English Title #{Factory.next(:title)}" }
4
- p.published 1
5
- p.body 'hi'
6
- p.url ''
7
- p.association :page
8
- end
1
+ FactoryGirl.define do
2
+ sequence(:title) { |n| n }
9
3
 
10
- Factory.define :page, :class => Kuhsaft::Page do |p|
11
- p.position 1
12
- p.after_create do |page|
13
- page.localized_pages << Factory.create(:localized_page, :page => page)
4
+ factory :page, :class => 'Kuhsaft::Page' do |p|
5
+ p.position 1
6
+ p.title { "English Title #{FactoryGirl.generate(:title)}" }
7
+ p.published 1
8
+ p.body 'lorem ipsum'
9
+ p.url ''
14
10
  end
15
- end
16
11
 
17
- Factory.define :asset, :class => Kuhsaft::Asset do |a|
18
- a.file File.open("#{Kuhsaft::Engine.root}/spec/dummy/app/assets/images/spec-image.png")
12
+ factory :asset, :class => Kuhsaft::Asset do |a|
13
+ a.file File.open("#{Kuhsaft::Engine.root}/spec/dummy/app/assets/images/spec-image.png")
14
+ end
19
15
  end
20
-
21
- Factory.sequence(:title) { |n| n }
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Admin authentication' do
4
+ sign_in_cms_admin
5
+
6
+ it 'redirects to the pages index' do
7
+ current_path.should == kuhsaft.cms_pages_path
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Cms/Pages' do
6
+ sign_in_cms_admin
7
+
8
+ context '#new' do
9
+ before do
10
+ visit kuhsaft.new_cms_page_path
11
+ fill_in 'Titel', :with => 'The Title of the page'
12
+ fill_in 'Stichwörter', :with => 'My keywords'
13
+ fill_in 'Beschreibung', :with => 'My Description'
14
+ end
15
+
16
+ describe '#create' do
17
+ it 'creates a new page' do
18
+ expect { click_on 'Create Seite' }.to change(Kuhsaft::Page, :count).by(1)
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Kuhsaft::Cms::ApplicationHelper do
4
+ describe '#render_language_switch?' do
5
+ context 'when there is one language' do
6
+ before do
7
+ I18n.stub(:available_locales).and_return([:de])
8
+ end
9
+
10
+ it 'returns false' do
11
+ helper.render_language_switch?.should be_false
12
+ end
13
+ end
14
+
15
+ context 'when there are multiple languages' do
16
+ before do
17
+ I18n.stub(:available_locales).and_return([:de, :en])
18
+ end
19
+
20
+ it 'returns true' do
21
+ helper.render_language_switch?.should be_true
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Kuhsaft::BrickList do
4
+
5
+ class TestBrick
6
+ include Kuhsaft::BrickList
7
+ end
8
+
9
+ let :brick do
10
+ TestBrick.new
11
+ end
12
+
13
+ describe '#collect_fulltext' do
14
+ context 'with bricks' do
15
+ it 'collects its childs fulltext' do
16
+ brick.stub_chain(:bricks, :localized).and_return([mock_model(Kuhsaft::Brick, :collect_fulltext => 'hallo')])
17
+ brick.collect_fulltext.should == 'hallo'
18
+ end
19
+ end
20
+
21
+ context 'with bricks without content' do
22
+ it 'returns a string' do
23
+ brick.stub_chain(:bricks, :localized).and_return([])
24
+ brick.collect_fulltext.should == ''
25
+ end
26
+ end
27
+
28
+ context 'without bricks' do
29
+ it 'returns a string' do
30
+ brick.collect_fulltext.should == ''
31
+ end
32
+
33
+ it 'does not fail' do
34
+ expect { brick.collect_fulltext }.to_not raise_error
35
+ end
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Kuhsaft::Engine do
4
+
5
+ describe '.configure' do
6
+
7
+ describe '.image_sizes' do
8
+ it 'delegates .clear to ImageSize' do
9
+ Kuhsaft::ImageSize.should_receive(:clear!)
10
+ Kuhsaft::Engine.configure do
11
+ config.image_sizes.clear!
12
+ end
13
+ end
14
+
15
+ it 'delegates .add to ImageSize' do
16
+ Kuhsaft::ImageSize.should_receive(:add).with(:something, 100, 200)
17
+ Kuhsaft::Engine.configure do
18
+ config.image_sizes.add(:something, 100, 200)
19
+ end
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+
3
+ describe Kuhsaft::Translatable do
4
+
5
+ class Demo
6
+ include Kuhsaft::Translatable
7
+ translate :name
8
+ end
9
+
10
+ let :model do
11
+ Demo.new
12
+ end
13
+
14
+ before do
15
+ I18n.available_locales = [:en, :de]
16
+ I18n.locale = :en
17
+ end
18
+
19
+ after do
20
+ I18n.available_locales = [:en]
21
+ I18n.locale = :en
22
+ end
23
+
24
+ describe '.translate' do
25
+ it 'defines a getter for each attribute' do
26
+ model.should respond_to(:name)
27
+ end
28
+
29
+ it 'defines a setter for each attributes' do
30
+ model.should respond_to(:name=)
31
+ end
32
+ end
33
+
34
+ describe '.locale_attr' do
35
+ it 'returns a suffixed attribute name' do
36
+ Demo.locale_attr('text').should == 'text_en'
37
+ end
38
+ end
39
+
40
+ describe '#locale_attr' do
41
+ it 'returns a suffixed attribute name' do
42
+ model.locale_attr('text').should == 'text_en'
43
+ end
44
+ end
45
+
46
+ describe 'translated attributes' do
47
+ it 'delegates the getter to the suffixed attribute' do
48
+ model.should_receive(:name_en).and_return('John')
49
+ model.name.should == 'John'
50
+ end
51
+
52
+ it 'delegates the setter to the suffixed attribute' do
53
+ model.should_receive(:name_en=).with('Johnny')
54
+ model.name = 'Johnny'
55
+ end
56
+
57
+ context 'dynamic methods' do
58
+ it 'delegates boolean accessors' do
59
+ model.should_receive(:name_en?)
60
+ model.name?
61
+ end
62
+
63
+ it 'delegates simple dynamic finders' do
64
+ model.should_receive(:find_by_name_en).with('Max')
65
+ model.find_by_name('Max')
66
+ end
67
+ end
68
+
69
+ context 'when changing the locale' do
70
+ before do
71
+ I18n.locale = :de
72
+ end
73
+
74
+ it 'delegates the getter to current locale' do
75
+ model.should_receive(:name_de).and_return('Johannes')
76
+ model.name.should == 'Johannes'
77
+ end
78
+
79
+ it 'delegates the getter to current locale' do
80
+ model.should_receive(:name_de=).with('Johannes')
81
+ model.name = 'Johannes'
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Kuhsaft::AccordionBrick do
4
+
5
+ let :accordion_brick do
6
+ Kuhsaft::AccordionBrick.new
7
+ end
8
+
9
+ describe '#user_can_delete?' do
10
+ it 'returns true' do
11
+ accordion_brick.user_can_delete?.should be_true
12
+ end
13
+ end
14
+
15
+ describe '#renders_own_childs?' do
16
+ it 'returns false' do
17
+ accordion_brick.renders_own_childs?.should be_false
18
+ end
19
+ end
20
+
21
+ describe '#bricks' do
22
+ it 'can have childs' do
23
+ accordion_brick.should respond_to(:bricks)
24
+ end
25
+ end
26
+
27
+ describe '#to_style_class' do
28
+ it 'includes the bootstrap classname' do
29
+ accordion_brick.to_style_class.should == 'kuhsaft-accordion-brick accordion'
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Kuhsaft::AccordionItemBrick do
4
+
5
+ let :accordion_item_brick do
6
+ Kuhsaft::AccordionItemBrick.new
7
+ end
8
+
9
+ describe '#valid' do
10
+ before do
11
+ accordion_item_brick.valid?
12
+ end
13
+
14
+ context 'without a #caption' do
15
+ it 'has en error' do
16
+ accordion_item_brick.should have(1).error_on(:caption)
17
+ end
18
+ end
19
+ end
20
+
21
+ describe '#user_can_delete?' do
22
+ it 'returns true' do
23
+ accordion_item_brick.user_can_delete?.should be_true
24
+ end
25
+ end
26
+
27
+ describe '#user_can_save' do
28
+ it 'returns true' do
29
+ accordion_item_brick.user_can_save?.should == true
30
+ end
31
+ end
32
+
33
+ describe '#renders_own_childs?' do
34
+ it 'returns false' do
35
+ accordion_item_brick.renders_own_childs?.should be_false
36
+ end
37
+ end
38
+
39
+ describe '#bricks' do
40
+ it 'can have childs' do
41
+ accordion_item_brick.should respond_to(:bricks)
42
+ end
43
+ end
44
+
45
+ describe '#to_style_class' do
46
+ it 'includes the bootstrap classname' do
47
+ accordion_item_brick.to_style_class.should == 'kuhsaft-accordion-item-brick accordion-group'
48
+ end
49
+ end
50
+ end