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
@@ -1,9 +0,0 @@
1
- class AddPageTypeToLocalizedPages < ActiveRecord::Migration
2
- def self.up
3
- add_column :localized_pages, :page_type, :string
4
- end
5
-
6
- def self.down
7
- remove_column :localized_pages, :string
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class AddPublishedAtToLocalizedPages < ActiveRecord::Migration
2
- def self.up
3
- add_column :localized_pages, :published_at, :datetime
4
- end
5
-
6
- def self.down
7
- remove_column :published_at, :type
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class AddTagsToPagePartContents < ActiveRecord::Migration
2
- def self.up
3
- add_column :contents, :tags, :string
4
- end
5
-
6
- def self.down
7
- remove_column :contents, :tags
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class AddTypeToPagePartContents < ActiveRecord::Migration
2
- def self.up
3
- add_column :contents, :type, :string
4
- end
5
-
6
- def self.down
7
- remove_column :contents, :type
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class AddUrlToLocalizedPages < ActiveRecord::Migration
2
- def self.up
3
- add_column :localized_pages, :url, :string
4
- end
5
-
6
- def self.down
7
- remove_column :localized_pages, :url
8
- end
9
- end
@@ -1,12 +0,0 @@
1
- class CreateAssets < ActiveRecord::Migration
2
- def self.up
3
- create_table :assets do |t|
4
- t.string :file
5
- t.timestamps
6
- end
7
- end
8
-
9
- def self.down
10
- drop_table :assets
11
- end
12
- end
@@ -1,19 +0,0 @@
1
- class CreateKuhsaftLocalizedPages < ActiveRecord::Migration
2
- def self.up
3
- create_table :localized_pages do |t|
4
- t.string :title
5
- t.string :slug
6
- t.string :keywords
7
- t.text :description
8
- t.text :body
9
- t.integer :published
10
- t.string :locale
11
- t.references :page
12
- t.timestamps
13
- end
14
- end
15
-
16
- def self.down
17
- drop_table :localized_pages
18
- end
19
- end
@@ -1,14 +0,0 @@
1
- class CreateKuhsaftPages < ActiveRecord::Migration
2
- def self.up
3
- create_table :pages do |t|
4
- t.integer :position
5
- t.integer :parent_id
6
- t.references :page
7
- t.timestamps
8
- end
9
- end
10
-
11
- def self.down
12
- drop_table :pages
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- class CreatePagePartContents < ActiveRecord::Migration
2
- def self.up
3
- create_table :contents do |t|
4
- t.integer :position
5
- t.text :content
6
- t.references :localized_page
7
- t.timestamps
8
- end
9
- end
10
-
11
- def self.down
12
- drop_table :contents
13
- end
14
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Kuhsaft::Cms::AssetsController do
4
- render_views
5
-
6
- before do
7
- Factory.create :asset
8
- end
9
-
10
- describe 'should render successfully' do
11
- it '#index' do
12
- get :index, :locale => :en
13
- response.should be_success
14
- end
15
-
16
- it '#new' do
17
- get :new, :locale => :en
18
- response.should be_success
19
- end
20
-
21
- it '#edit' do
22
- get :edit, :id => 1, :locale => :en
23
- response.should be_success
24
- end
25
- end
26
- end
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Kuhsaft::Cms::PagesController do
4
- render_views
5
-
6
- describe 'should render successfully' do
7
- before :all do
8
- # create page with ID=1 if none exists
9
- Factory.create :page
10
- end
11
-
12
- it '#index' do
13
- get :index, :locale => :en
14
- response.should be_success
15
- end
16
-
17
- it '#show' do
18
- get :show, :id => 1, :locale => :en
19
- response.should be_success
20
- end
21
-
22
- it '#new' do
23
- get :new, :locale => :en
24
- response.should be_success
25
- end
26
-
27
- it '#edit' do
28
- get :edit, :id => 1, :locale => :en
29
- response.should be_success
30
- end
31
-
32
- it '#create' do
33
- # TODO: this is ridiculous. We need to have integration tests(?) for this.
34
- params = { :kuhsaft_page => { :localized_pages_attributes => { 0 => { :title => 'hi', :locale => :en }}}, :locale => :en }
35
- post :create, params
36
- response.should be_redirect
37
- end
38
-
39
- it '#update' do
40
- # TODO: this is EXTREMELY ridiculous. We need to have integration tests(?) for this.
41
- page = Kuhsaft::Page.first
42
- localized_page = page.translation
43
- params = {
44
- :id => page.id,
45
- :kuhsaft_page => {
46
- :localized_pages_attributes => {
47
- 0 => {
48
- :slug => "hi",
49
- :title => "Hi",
50
- :id => localized_page.id,
51
- :description => '',
52
- :locale => 'en',
53
- :page_parts_attributes => {
54
- 0 => {
55
- :text => 'some text',
56
- :type => 'Kuhsaft::PagePart::Markdown'
57
- }
58
- }
59
- }
60
- }}, :locale => :en }
61
- post :update, params
62
- response.should be_redirect
63
- end
64
- end
65
- end
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Kuhsaft::Cms::PagePartsController do
4
- render_views
5
-
6
- describe 'should render successfully' do
7
- it '#index' do
8
- get :index, :locale => :en, :page_id => 1
9
- response.should be_success
10
- end
11
-
12
- it '#show' do
13
- get :show, :id => 1, :locale => :en, :page_id => 1
14
- response.should be_success
15
- end
16
-
17
- it '#new' do
18
- get :new, :locale => :en, :page_id => 1
19
- response.should be_success
20
- end
21
-
22
- it '#edit' do
23
- get :edit, :id => 1, :locale => :en, :page_id => 1
24
- response.should be_success
25
- end
26
-
27
- it '#create' do
28
- # TODO: this is ridiculous. We need to have integration tests(?) for this.
29
- # params = { :kuhsaft_page => { :localized_pages_attributes => { 0 => { :title => 'hi', :locale => :en }}}, :locale => :en }
30
- # post :create, params
31
- # response.should be_redirect
32
- end
33
-
34
- it '#update' do
35
- # TODO: this is EXTREMELY ridiculous. We need to have integration tests(?) for this.
36
- # page = Kuhsaft::Page.first
37
- # localized_page = page.translation
38
- # params = {
39
- # :id => page.id,
40
- # :kuhsaft_page => {
41
- # :localized_pages_attributes => {
42
- # 0 => {
43
- # :slug => "hi",
44
- # :title => "Hi",
45
- # :id => localized_page.id,
46
- # :description => '',
47
- # :locale => 'en',
48
- # :page_parts_attributes => {
49
- # 0 => {
50
- # :text => 'some text',
51
- # :type => 'Kuhsaft::PagePart::Markdown'
52
- # }
53
- # }
54
- # }
55
- # }}, :locale => :en }
56
- # post :update, params
57
- # response.should be_redirect
58
- end
59
- end
60
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Kuhsaft::PagesController do
4
- render_views
5
-
6
- before do
7
- set_lang :en
8
- # create page with slug=english-title-1
9
- @page = Factory(:page)
10
- end
11
-
12
- after do
13
- Kuhsaft::Page.all.each { |p| p.destroy }
14
- reset_lang
15
- end
16
-
17
- describe 'should render successfully' do
18
- it '#show' do
19
- get :show, :locale => 'en', :url => 'english-title-1'
20
- response.response_code.should eq(200)
21
- response.should be_success
22
- end
23
- end
24
-
25
- describe 'should render 404' do
26
- it 'should raise RoutingError by default' do
27
- expect{ get :show, :locale => 'en', :url => '/i-dont-know' }.to raise_error(ActionController::RoutingError)
28
- end
29
- end
30
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CmsHelper do
4
- context 'when the user creates a toplevel page' do
5
- describe '#available_parent_pages' do
6
- it 'should return the 2 pages' do
7
- helper.available_parent_pages.should have(2).pages
8
- end
9
- end
10
- end
11
-
12
- describe '#available_parent_pages' do
13
- before do
14
- page1, page2, page3 = create_page_tree
15
- helper.stub!(:params).and_return(:parent_id => page3.id)
16
- end
17
-
18
- it 'should return the parent pages' do
19
- helper.available_parent_pages.should have_at_least(3).pages
20
- end
21
- end
22
- end
@@ -1,119 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PagesHelper do
4
- before do
5
- @page = Factory.create :page
6
- end
7
-
8
- after do
9
- destroy_all_pages
10
- end
11
-
12
- describe '#asset_for' do
13
- it 'should return the asset with the given id' do
14
- asset = Factory.create :asset
15
- asset_for(asset.id).should eq(asset)
16
- end
17
- end
18
-
19
- describe '#render_markdown' do
20
- it 'should parse markdown and convert it to html' do
21
- render_markdown('# hi').should eq("<h1>hi</h1>\n")
22
- end
23
- end
24
-
25
- describe '#navigation_for' do
26
- before do
27
- @page = Factory.create :page
28
- @page.childs << Factory.create(:page)
29
- @page.childs << Factory.create(:page)
30
- @page.save
31
- end
32
-
33
- it 'should return a list of pages' do
34
- navigation_for(@page.id).should have_at_least(2).pages
35
- end
36
-
37
- it 'should yield a list of pages if there is more than 1' do
38
- navigation_for(@page.id) { |pages| @yielded_pages = pages }
39
- @yielded_pages.should respond_to(:each) # don't be explicity about AR:Relation
40
- end
41
-
42
- it 'should not yield if there are not pages' do
43
- navigation_for(9999) { |pages| @yielded_pages = pages }
44
- @yielded_pages.should be_nil
45
- end
46
-
47
- it 'should accept options instead of an id' do
48
- page1, page2, page3 = create_page_tree
49
- page1.translation.page_type = Kuhsaft::PageType::NAVIGATION
50
- page1.translation.slug = 'test'
51
- page1.save
52
- navigation_for(:slug => 'test').should have(1).item
53
- end
54
- end
55
-
56
- describe '#homepage' do
57
- before do
58
- page1, page2, page3 = create_page_tree
59
- page1.translation.page_type = page2.translation.page_type = Kuhsaft::PageType::NAVIGATION
60
- page1.save
61
- page2.save
62
- end
63
-
64
- it 'should return the first page in the page hierarchy' do
65
- homepage.should be_a(Kuhsaft::Page)
66
- end
67
- end
68
-
69
- describe '#current_page_path' do
70
- it 'should return the path for the current page' do
71
- @page.localized_pages.create :locale => :de, :title => 'seite1'
72
- helper.current_page_path(:de).should eq('/de/seite1')
73
- end
74
- end
75
-
76
- describe '#active_page_class' do
77
- it '#active_page_class should return :active' do
78
- helper.stub!(:params).and_return :url => @page.url
79
- helper.active_page_class(@page).should be(:active)
80
- end
81
- end
82
-
83
- describe '#page_for_level' do
84
- before do
85
- destroy_all_pages
86
- @page1, @page2, @page3 = create_page_tree
87
- helper.stub!(:params).and_return :url => @page3.url
88
- end
89
- it 'should return the page for the 1. level' do
90
- helper.page_for_level(1).should eq(@page1)
91
- end
92
-
93
- it 'should return the page for the 2. level' do
94
- helper.page_for_level(2).should eq(@page2)
95
- end
96
-
97
- it 'should return the page for the 3. level' do
98
- helper.page_for_level(3).should eq(@page3)
99
- end
100
-
101
- it 'should yield the page to the given block' do
102
- helper.page_for_level(1) { |p| @yielded_page = p }
103
- @yielded_page.should eq(@page1)
104
- end
105
- end
106
-
107
- describe '#current_page' do
108
- it '#current_page should return the current page' do
109
- helper.stub!(:params).and_return :url => '/de/seite1'
110
- helper.current_page.should eq(@page)
111
- end
112
-
113
- it 'should yield the current_page to the given block' do
114
- helper.stub!(:params).and_return :url => 'en/english-title'
115
- helper.current_page { |page| @yielded_page = page }
116
- @yielded_page.should be_instance_of(Kuhsaft::Page)
117
- end
118
- end
119
- end