browsercms 3.4.2 → 3.5.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (367) hide show
  1. data/README.markdown +1 -0
  2. data/app/assets/images/cms/file-uploading.gif +0 -0
  3. data/app/assets/javascripts/cms/application.js +1 -0
  4. data/app/assets/javascripts/cms/attachment_manager.js.erb +87 -0
  5. data/app/assets/javascripts/cms/core_library.js.erb +38 -25
  6. data/app/assets/stylesheets/cms/application.css.erb +1 -0
  7. data/app/assets/stylesheets/cms/attachment_manager.css.scss +28 -0
  8. data/app/controllers/cms/application_controller.rb +1 -1
  9. data/app/controllers/cms/attachments_controller.rb +45 -10
  10. data/app/controllers/cms/cache_controller.rb +1 -1
  11. data/app/controllers/cms/content_block_controller.rb +134 -122
  12. data/app/controllers/cms/content_controller.rb +143 -155
  13. data/app/controllers/cms/dashboard_controller.rb +11 -9
  14. data/app/controllers/cms/error_handling.rb +19 -7
  15. data/app/controllers/cms/file_blocks_controller.rb +2 -2
  16. data/app/controllers/cms/home_controller.rb +3 -0
  17. data/app/controllers/cms/section_nodes_controller.rb +52 -44
  18. data/app/controllers/cms/sections_controller.rb +4 -2
  19. data/app/controllers/cms/toolbar_controller.rb +14 -10
  20. data/app/helpers/cms/application_helper.rb +23 -19
  21. data/app/helpers/cms/form_builder.rb +65 -18
  22. data/app/helpers/cms/mobile_helper.rb +19 -0
  23. data/app/helpers/cms/path_helper.rb +30 -4
  24. data/app/helpers/cms/rendering_helper.rb +9 -1
  25. data/app/models/cms/abstract_file_block.rb +6 -6
  26. data/app/models/cms/attachment.rb +196 -107
  27. data/app/models/cms/category.rb +3 -0
  28. data/app/models/cms/category_type.rb +2 -0
  29. data/app/models/cms/connector.rb +3 -0
  30. data/app/models/cms/content_type.rb +3 -0
  31. data/app/models/cms/content_type_group.rb +2 -0
  32. data/app/models/cms/dynamic_view.rb +4 -0
  33. data/app/models/cms/email_message.rb +2 -0
  34. data/app/models/cms/file_block.rb +9 -2
  35. data/app/models/cms/group.rb +5 -2
  36. data/app/models/cms/group_permission.rb +2 -0
  37. data/app/models/cms/group_section.rb +3 -0
  38. data/app/models/cms/group_type.rb +2 -0
  39. data/app/models/cms/group_type_permission.rb +2 -0
  40. data/app/models/cms/html_block.rb +3 -2
  41. data/app/models/cms/image_block.rb +13 -2
  42. data/app/models/cms/page.rb +14 -3
  43. data/app/models/cms/page_route.rb +4 -0
  44. data/app/models/cms/page_route_condition.rb +1 -0
  45. data/app/models/cms/page_route_option.rb +2 -0
  46. data/app/models/cms/page_route_requirement.rb +1 -0
  47. data/app/models/cms/permission.rb +3 -0
  48. data/app/models/cms/portlet.rb +2 -2
  49. data/app/models/cms/redirect.rb +2 -0
  50. data/app/models/cms/section.rb +15 -1
  51. data/app/models/cms/section_node.rb +1 -0
  52. data/app/models/cms/site.rb +3 -0
  53. data/app/models/cms/tag.rb +2 -0
  54. data/app/models/cms/tagging.rb +3 -0
  55. data/app/models/cms/task.rb +5 -1
  56. data/app/models/cms/user.rb +1 -1
  57. data/app/models/cms/user_group_membership.rb +3 -0
  58. data/app/views/cms/attachments/_attachment.html.erb +14 -0
  59. data/app/views/cms/attachments/_attachment_table.html.erb +17 -0
  60. data/app/views/cms/attachments/_attachment_wrapper.html.erb +4 -0
  61. data/app/views/cms/blocks/index.html.erb +2 -3
  62. data/app/views/cms/blocks/show.html.erb +1 -1
  63. data/app/views/cms/dynamic_views/index.html.erb +1 -1
  64. data/app/views/cms/email_messages/index.html.erb +1 -1
  65. data/app/views/cms/file_blocks/_form.html.erb +1 -27
  66. data/app/views/cms/file_blocks/_section_selector.html.erb +13 -0
  67. data/app/views/cms/file_blocks/render.html.erb +3 -3
  68. data/app/views/cms/form_builder/_cms_attachment_manager.html.erb +26 -0
  69. data/app/views/cms/form_builder/_cms_file_field.html.erb +27 -35
  70. data/app/views/cms/groups/index.html.erb +1 -1
  71. data/app/views/cms/image_blocks/_form.html.erb +1 -27
  72. data/app/views/cms/image_blocks/render.html.erb +4 -1
  73. data/app/views/cms/page_routes/index.html.erb +3 -0
  74. data/app/views/cms/shared/error.xml.erb +8 -0
  75. data/app/views/cms/tags/render.html.erb +1 -1
  76. data/app/views/cms/toolbar/_mobile_toggle.html.erb +33 -0
  77. data/app/views/cms/users/index.html.erb +1 -1
  78. data/app/views/layouts/_page_toolbar.html.erb +2 -1
  79. data/bin/bcms +21 -26
  80. data/config/routes.rb +3 -2
  81. data/db/browsercms.seeds.rb +2 -1
  82. data/db/migrate/20111130221145_browsercms340.rb +5 -4
  83. data/db/migrate/20120329144406_browsercms350.rb +32 -0
  84. data/{test/dummy/db → db}/schema.rb +97 -128
  85. data/{performance_tuning_notes.md → doc/performance_tuning_notes.md} +0 -0
  86. data/doc/release_notes.md +74 -0
  87. data/lib/browsercms.rb +3 -0
  88. data/lib/cms/acts/content_block.rb +10 -2
  89. data/lib/cms/addressable.rb +8 -0
  90. data/lib/cms/attachments/attachment_serving.rb +59 -0
  91. data/lib/cms/attachments/configuration.rb +88 -0
  92. data/lib/cms/behaviors/attaching.rb +305 -136
  93. data/lib/cms/behaviors/connecting.rb +3 -4
  94. data/lib/cms/behaviors/dynamic_attributes.rb +121 -118
  95. data/lib/cms/behaviors/flush_cache_on_change.rb +1 -3
  96. data/lib/cms/behaviors/naming.rb +16 -0
  97. data/lib/cms/behaviors/pagination.rb +4 -1
  98. data/lib/cms/behaviors/publishing.rb +9 -3
  99. data/lib/cms/behaviors/searching.rb +3 -8
  100. data/lib/cms/behaviors/soft_deleting.rb +1 -0
  101. data/lib/cms/behaviors/taggable.rb +2 -0
  102. data/lib/cms/behaviors/versioning.rb +73 -120
  103. data/lib/cms/caching.rb +53 -11
  104. data/lib/cms/commands/actions.rb +19 -2
  105. data/lib/cms/configuration.rb +44 -0
  106. data/lib/cms/content_rendering_support.rb +9 -6
  107. data/lib/cms/default_accessible.rb +13 -0
  108. data/lib/cms/domain_support.rb +22 -0
  109. data/lib/cms/engine.rb +40 -19
  110. data/lib/cms/engine_helper.rb +54 -0
  111. data/lib/cms/extensions/active_record/connection_adapters/abstract/schema_statements.rb +14 -2
  112. data/lib/cms/mobile_aware.rb +67 -0
  113. data/lib/cms/route_extensions.rb +3 -0
  114. data/lib/cms/upgrades/v3_5_0.rb +155 -0
  115. data/lib/cms/version.rb +6 -1
  116. data/lib/generators/cms/content_block/content_block_generator.rb +14 -9
  117. data/lib/generators/cms/content_block/templates/_form.html.erb +17 -6
  118. data/lib/generators/cms/content_block/templates/render.html.erb +12 -5
  119. data/lib/generators/cms/template/template_generator.rb +11 -2
  120. data/lib/tasks/cms.rake +23 -0
  121. data/lib/templates/active_record/model/model.rb +6 -0
  122. metadata +127 -517
  123. data/.gitignore +0 -24
  124. data/.rvmrc +0 -2
  125. data/Gemfile +0 -29
  126. data/Gemfile.lock +0 -196
  127. data/Rakefile +0 -97
  128. data/app/assets/images/browsercms/.gitkeep +0 -0
  129. data/app/controllers/browsercms/application_controller.rb +0 -4
  130. data/browsercms.gemspec +0 -35
  131. data/config/cucumber.yml +0 -8
  132. data/config/database.jdbcmysql.yml +0 -30
  133. data/config/database.mysql.yml +0 -27
  134. data/config/database.postgres.yml +0 -25
  135. data/config/database.sqlite3.yml +0 -11
  136. data/config/environment.rb +0 -6
  137. data/config/initializers/query_reviewer_patch.rb +0 -12
  138. data/config/initializers/rack_1_2_1_patch.rb +0 -12
  139. data/config/locales/en.yml +0 -5
  140. data/features/acts_as_content_page.feature +0 -62
  141. data/features/add_content_to_pages.feature +0 -45
  142. data/features/caching.feature +0 -13
  143. data/features/ckeditor.feature +0 -11
  144. data/features/commands/confirm_aruba_works.feature +0 -24
  145. data/features/commands/generate_module.feature +0 -54
  146. data/features/commands/install_browsercms.feature +0 -21
  147. data/features/commands/new_demo_project.feature +0 -30
  148. data/features/commands/new_projects.feature +0 -50
  149. data/features/commands/upgrade_modules_to_3_4_0_from_3_1_x.feature +0 -19
  150. data/features/commands/upgrade_project_to_3_4_0_from_3_3_x.feature +0 -52
  151. data/features/commands/upgrading_modules.feature +0 -67
  152. data/features/content_blocks/manage_custom_blocks.feature +0 -67
  153. data/features/content_blocks/manage_html_blocks.feature +0 -48
  154. data/features/content_blocks/manage_image_blocks.feature +0 -41
  155. data/features/content_files.feature +0 -37
  156. data/features/content_pages.feature +0 -21
  157. data/features/generators/content_blocks_for_modules.feature +0 -58
  158. data/features/generators/content_blocks_for_projects.feature +0 -109
  159. data/features/install_content.feature +0 -25
  160. data/features/jquery-testplan.txt +0 -12
  161. data/features/manage_groups.feature +0 -33
  162. data/features/manage_page_routes.feature +0 -72
  163. data/features/manage_redirects.feature +0 -20
  164. data/features/manage_sections.feature +0 -12
  165. data/features/manage_tasks.feature +0 -25
  166. data/features/manage_users.feature +0 -38
  167. data/features/page_templates.feature +0 -49
  168. data/features/portlets/email_friend_portlet.feature +0 -29
  169. data/features/portlets/portlets.feature +0 -100
  170. data/features/portlets/tag_cloud_portlet.feature +0 -28
  171. data/features/sitemap/create_pages.feature +0 -15
  172. data/features/sitemap/manage_links.feature +0 -29
  173. data/features/sitemap/sitemap.feature +0 -18
  174. data/features/step_definitions/acts_as_content_page_steps.rb.rb +0 -3
  175. data/features/step_definitions/ckeditor_steps.rb +0 -13
  176. data/features/step_definitions/command_line_steps.rb +0 -212
  177. data/features/step_definitions/content_pages_steps.rb +0 -170
  178. data/features/step_definitions/data_steps.rb +0 -48
  179. data/features/step_definitions/edit_page_templates_steps.rb +0 -21
  180. data/features/step_definitions/html_blocks_steps.rb +0 -9
  181. data/features/step_definitions/install_content_steps.rb +0 -4
  182. data/features/step_definitions/manage_content_blocks_steps.rb +0 -26
  183. data/features/step_definitions/manage_image_blocks_steps.rb +0 -31
  184. data/features/step_definitions/manage_sections_steps.rb +0 -18
  185. data/features/step_definitions/manage_user_steps.rb +0 -22
  186. data/features/step_definitions/more_custom_block_steps.rb +0 -34
  187. data/features/step_definitions/page_route_steps.rb +0 -65
  188. data/features/step_definitions/page_template_steps.rb +0 -5
  189. data/features/step_definitions/permissions_steps.rb +0 -13
  190. data/features/step_definitions/portlets_steps.rb +0 -64
  191. data/features/step_definitions/redirect_steps.rb +0 -12
  192. data/features/step_definitions/sitemap_steps.rb +0 -18
  193. data/features/step_definitions/tag_cloud_steps.rb +0 -11
  194. data/features/step_definitions/task_steps.rb +0 -4
  195. data/features/step_definitions/taxonomy_steps.rb +0 -16
  196. data/features/step_definitions/upgrade_module_steps.rb +0 -76
  197. data/features/step_definitions/web_steps.rb +0 -211
  198. data/features/support/async_support.rb +0 -17
  199. data/features/support/command_line_helpers.rb +0 -63
  200. data/features/support/debug_formatter.rb +0 -7
  201. data/features/support/debugging.rb +0 -28
  202. data/features/support/env.rb +0 -73
  203. data/features/support/git_api.rb +0 -9
  204. data/features/support/open_on_first_failure.rb +0 -25
  205. data/features/support/paths.rb +0 -32
  206. data/features/support/rails_api.rb +0 -8
  207. data/features/support/selectors.rb +0 -39
  208. data/features/support/transforms.rb +0 -7
  209. data/features/taxonomy/add_content_with_category.feature +0 -30
  210. data/features/taxonomy/manage_categories.feature +0 -20
  211. data/features/taxonomy/manage_category_types.feature +0 -16
  212. data/lib/cms/init.rb +0 -105
  213. data/lib/tasks/data.rake +0 -43
  214. data/lib/tasks/db.rake +0 -82
  215. data/public/styled_file_field/index.html +0 -72
  216. data/script/cucumber +0 -10
  217. data/script/rails +0 -6
  218. data/test/console_helper.rb +0 -5
  219. data/test/custom_assertions.rb +0 -84
  220. data/test/dummy/Rakefile +0 -7
  221. data/test/dummy/app/assets/javascripts/application.js +0 -9
  222. data/test/dummy/app/assets/javascripts/content_page.js +0 -2
  223. data/test/dummy/app/assets/stylesheets/application.css +0 -7
  224. data/test/dummy/app/assets/stylesheets/content_page.css +0 -4
  225. data/test/dummy/app/controllers/application_controller.rb +0 -3
  226. data/test/dummy/app/controllers/cms/products_controller.rb +0 -2
  227. data/test/dummy/app/controllers/cms/sample_blocks_controller.rb +0 -3
  228. data/test/dummy/app/controllers/content_page_controller.rb +0 -13
  229. data/test/dummy/app/helpers/application_helper.rb +0 -2
  230. data/test/dummy/app/helpers/content_page_helper.rb +0 -2
  231. data/test/dummy/app/mailers/.gitkeep +0 -0
  232. data/test/dummy/app/models/.gitkeep +0 -0
  233. data/test/dummy/app/models/cms/sample_block.rb +0 -22
  234. data/test/dummy/app/models/product.rb +0 -5
  235. data/test/dummy/app/views/cms/products/_form.html.erb +0 -7
  236. data/test/dummy/app/views/cms/products/render.html.erb +0 -3
  237. data/test/dummy/app/views/content_page/custom_page.html.erb +0 -3
  238. data/test/dummy/app/views/content_page/index.html.erb +0 -2
  239. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  240. data/test/dummy/app/views/layouts/templates/default.html.erb +0 -17
  241. data/test/dummy/app/views/layouts/templates/subpage.html.erb +0 -16
  242. data/test/dummy/app/views/test_route/index.html.erb +0 -14
  243. data/test/dummy/config.ru +0 -4
  244. data/test/dummy/config/application.rb +0 -45
  245. data/test/dummy/config/boot.rb +0 -10
  246. data/test/dummy/config/database.yml +0 -27
  247. data/test/dummy/config/environment.rb +0 -5
  248. data/test/dummy/config/environments/development.rb +0 -32
  249. data/test/dummy/config/environments/production.rb +0 -60
  250. data/test/dummy/config/environments/test.rb +0 -46
  251. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  252. data/test/dummy/config/initializers/browsercms.rb +0 -7
  253. data/test/dummy/config/initializers/inflections.rb +0 -10
  254. data/test/dummy/config/initializers/mime_types.rb +0 -5
  255. data/test/dummy/config/initializers/quiet_sprocket_assets.rb +0 -13
  256. data/test/dummy/config/initializers/secret_token.rb +0 -7
  257. data/test/dummy/config/initializers/session_store.rb +0 -8
  258. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  259. data/test/dummy/config/locales/en.yml +0 -5
  260. data/test/dummy/config/routes.rb +0 -23
  261. data/test/dummy/db/migrate/20111228141250_create_products.rb +0 -16
  262. data/test/dummy/db/seeds.rb +0 -1
  263. data/test/dummy/lib/assets/.gitkeep +0 -0
  264. data/test/dummy/public/404.html +0 -26
  265. data/test/dummy/public/422.html +0 -26
  266. data/test/dummy/public/500.html +0 -26
  267. data/test/dummy/public/favicon.ico +0 -0
  268. data/test/dummy/script/rails +0 -6
  269. data/test/dummy/test/functional/content_page_controller_test.rb +0 -9
  270. data/test/dummy/test/unit/helpers/content_page_helper_test.rb +0 -4
  271. data/test/factories.rb +0 -235
  272. data/test/fixtures/multipart/foo.jpg +0 -0
  273. data/test/fixtures/multipart/sample_upload.txt +0 -1
  274. data/test/fixtures/multipart/second_upload.txt +0 -1
  275. data/test/fixtures/multipart/test.jpg +0 -0
  276. data/test/fixtures/multipart/version1.txt +0 -1
  277. data/test/fixtures/multipart/version2.txt +0 -1
  278. data/test/functional/cms/cache_controller_test.rb +0 -16
  279. data/test/functional/cms/categories_controller_test.rb +0 -28
  280. data/test/functional/cms/connectors_controller_test.rb +0 -64
  281. data/test/functional/cms/content_block_controller_test.rb +0 -127
  282. data/test/functional/cms/content_controller_test.rb +0 -351
  283. data/test/functional/cms/dashboard_controller_test.rb +0 -20
  284. data/test/functional/cms/file_blocks_controller_test.rb +0 -55
  285. data/test/functional/cms/home_controller_test.rb +0 -160
  286. data/test/functional/cms/html_blocks_controller_test.rb +0 -159
  287. data/test/functional/cms/image_blocks_controller_test.rb +0 -78
  288. data/test/functional/cms/links_controller_test.rb +0 -92
  289. data/test/functional/cms/log/test.log +0 -0
  290. data/test/functional/cms/pages_controller_test.rb +0 -233
  291. data/test/functional/cms/portlets_controller_test.rb +0 -57
  292. data/test/functional/cms/sections_controller_test.rb +0 -234
  293. data/test/functional/cms/sessions_controller_test.rb +0 -80
  294. data/test/functional/cms/tasks_controller_test.rb +0 -64
  295. data/test/functional/cms/toolbar_controller_test.rb +0 -76
  296. data/test/functional/cms/users_controller_test.rb +0 -218
  297. data/test/integration/cms/password_management_test.rb +0 -66
  298. data/test/integration/sitemap_performance_test.rb +0 -26
  299. data/test/mock_file.rb +0 -33
  300. data/test/performance/browsing_test.rb +0 -9
  301. data/test/support/engine_controller_hacks.rb +0 -34
  302. data/test/support/factory_helpers.rb +0 -57
  303. data/test/support/rails_3_1_routes_hack.rb +0 -70
  304. data/test/test_helper.rb +0 -199
  305. data/test/test_logging.rb +0 -67
  306. data/test/unit/active_record_callbacks.rb +0 -50
  307. data/test/unit/behaviors/attaching_test.rb +0 -370
  308. data/test/unit/behaviors/cms_user_test.rb +0 -67
  309. data/test/unit/behaviors/connectable_test.rb +0 -32
  310. data/test/unit/behaviors/connecting_test.rb +0 -56
  311. data/test/unit/behaviors/dynamic_attributes_test.rb +0 -74
  312. data/test/unit/behaviors/namespacing_test.rb +0 -76
  313. data/test/unit/behaviors/publishable_test.rb +0 -83
  314. data/test/unit/behaviors/rendering_test.rb +0 -68
  315. data/test/unit/behaviors/searching_test.rb +0 -102
  316. data/test/unit/behaviors/taggable_test.rb +0 -110
  317. data/test/unit/behaviors/userstamping_test.rb +0 -27
  318. data/test/unit/behaviors/versioning_test.rb +0 -102
  319. data/test/unit/extensions/active_record/base_test.rb +0 -25
  320. data/test/unit/extensions/hash_test.rb +0 -26
  321. data/test/unit/extensions/integer_test.rb +0 -10
  322. data/test/unit/extensions/string_test.rb +0 -14
  323. data/test/unit/factories_test.rb +0 -50
  324. data/test/unit/generators/install_generator_test.rb +0 -15
  325. data/test/unit/helpers/application_helper_test.rb +0 -104
  326. data/test/unit/helpers/date_picker_test.rb +0 -17
  327. data/test/unit/helpers/menu_helper_test.rb +0 -240
  328. data/test/unit/helpers/page_helper_test.rb +0 -69
  329. data/test/unit/helpers/path_helper_test.rb +0 -38
  330. data/test/unit/helpers/rendering_helper_test.rb +0 -8
  331. data/test/unit/lib/acts_as_content_page_test.rb +0 -72
  332. data/test/unit/lib/cms/authentication/controller_test.rb +0 -20
  333. data/test/unit/lib/cms/engine_helper_test.rb +0 -119
  334. data/test/unit/lib/cms/sitemap_test.rb +0 -210
  335. data/test/unit/lib/cms_domain_support_test.rb +0 -44
  336. data/test/unit/lib/command_line_test.rb +0 -70
  337. data/test/unit/lib/content_block_test.rb +0 -304
  338. data/test/unit/lib/content_rendering_support_test.rb +0 -40
  339. data/test/unit/lib/generators_test.rb +0 -40
  340. data/test/unit/lib/routes_test.rb +0 -98
  341. data/test/unit/mock_file_test.rb +0 -19
  342. data/test/unit/models/attachment_test.rb +0 -160
  343. data/test/unit/models/category_test.rb +0 -40
  344. data/test/unit/models/category_type_test.rb +0 -8
  345. data/test/unit/models/connector_test.rb +0 -152
  346. data/test/unit/models/content_type_group_test.rb +0 -26
  347. data/test/unit/models/content_type_test.rb +0 -177
  348. data/test/unit/models/dynamic_views_test.rb +0 -36
  349. data/test/unit/models/email_page_portlet_test.rb +0 -20
  350. data/test/unit/models/file_block_test.rb +0 -246
  351. data/test/unit/models/group_test.rb +0 -29
  352. data/test/unit/models/html_block_test.rb +0 -121
  353. data/test/unit/models/image_block_test.rb +0 -35
  354. data/test/unit/models/link_test.rb +0 -52
  355. data/test/unit/models/namespaces_test.rb +0 -57
  356. data/test/unit/models/page_partial_test.rb +0 -37
  357. data/test/unit/models/page_route_test.rb +0 -113
  358. data/test/unit/models/page_template_test.rb +0 -50
  359. data/test/unit/models/page_test.rb +0 -879
  360. data/test/unit/models/permission_test.rb +0 -10
  361. data/test/unit/models/portlet_test.rb +0 -99
  362. data/test/unit/models/sections_test.rb +0 -278
  363. data/test/unit/models/site_test.rb +0 -50
  364. data/test/unit/models/task_test.rb +0 -150
  365. data/test/unit/models/user_test.rb +0 -358
  366. data/test/unit/schema_statements_test.rb +0 -137
  367. data/todo_list.markdown +0 -50
@@ -1,19 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MockFileTest < ActiveSupport::TestCase
4
-
5
- def setup
6
-
7
- end
8
-
9
- def teardown
10
-
11
- end
12
-
13
-
14
- test "mock files can have data read from them" do
15
- file = mock_file()
16
- assert_not_nil file.path
17
- assert_equal "", open(file.path) { |f| f.read }
18
- end
19
- end
@@ -1,160 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Cms
4
- class AttachmentTest < ActiveSupport::TestCase
5
-
6
- def setup
7
- @file = file_upload_object({:original_filename => "sample_upload.txt", :content_type => "text/plain"})
8
-
9
- end
10
-
11
- def test_creating_an_attachment_with_no_file
12
- attachment = Cms::Attachment.new
13
- assert_not_valid attachment
14
- assert_has_error_on attachment, :temp_file, "You must upload a file"
15
- end
16
-
17
- def test_creating_an_attachment_with_a_StringIO_file
18
- file = @file
19
- attachment = Cms::Attachment.new(:temp_file => file, :file_path => "/sample_upload.txt", :section => root_section)
20
-
21
- attachment.save!
22
- assert_equal "sample_upload.txt", attachment.file_name
23
- assert_equal "text/plain", attachment.file_type
24
- assert_equal "txt", attachment.file_extension
25
- assert_file_exists attachment.full_file_location
26
- assert_equal "This is a file.", open(attachment.full_file_location) { |f| f.read }
27
- end
28
-
29
- def test_creating_an_attachment_with_a_Tempfile_file
30
- attachment = Cms::Attachment.new(:temp_file => @file, :file_path => "/foo.txt", :section => root_section)
31
- attachment.save!
32
-
33
- assert_equal "foo.txt", attachment.file_name
34
- assert_file_exists attachment.full_file_location
35
- assert_equal "This is a file.", open(attachment.full_file_location) { |f| f.read }
36
-
37
- # If you change the attributes of the attachment, but don't change the file
38
- # the file_location should not change
39
- original_file_location = attachment.file_location
40
- attachment = Cms::Attachment.find(attachment.id)
41
- attachment.update_attributes(:file_path => "bar.txt")
42
- assert_equal 2, attachment.draft.version
43
- assert_equal "/bar.txt", attachment.file_path
44
- assert_equal "bar.txt", attachment.file_name
45
- assert_equal original_file_location, attachment.file_location
46
- end
47
-
48
- def test_updating_a_new_file_should_change_the_file_location
49
- attachment = Cms::Attachment.create!(:temp_file => @file, :file_path => "/foo.txt", :section => root_section)
50
-
51
- reloaded_attachment = Cms::Attachment.find(attachment.id)
52
- original_file_location = attachment.file_location
53
- file = file_upload_object(:original_filename => "second_upload.txt", :content_type => "text/plain")
54
- reloaded_attachment.update_attributes(:temp_file => file)
55
- assert_equal 2, reloaded_attachment.draft.version
56
- assert_equal "/foo.txt", reloaded_attachment.as_of_draft_version.file_path, "Updating the file itself should also update the name of the file. (Note:This might just be an invalid test)"
57
- assert_equal "foo.txt", reloaded_attachment.as_of_draft_version.file_name
58
- assert_not_equal original_file_location, reloaded_attachment.as_of_draft_version.file_location
59
- assert_equal "This is a second file.", open(reloaded_attachment.as_of_draft_version.full_file_location) { |f| f.read }
60
- end
61
-
62
- def test_find_live_by_file_path
63
- file = @file
64
- attachment = Cms::Attachment.new(:temp_file => file, :file_path => "/foo.txt", :section => root_section)
65
- attachment.save!
66
- assert !attachment.published?, "Attachment should not be published"
67
- assert_nil Cms::Attachment.find_live_by_file_path("/foo.txt")
68
-
69
- attachment.publish
70
- assert attachment.reload.published?, "Attachment should be published"
71
- assert_equal attachment, Cms::Attachment.find_live_by_file_path("/foo.txt")
72
-
73
- attachment.update_attributes(:file_type => "text/html")
74
- assert !attachment.live?, "Attachment should not be live"
75
- assert_equal attachment.as_of_version(2), Cms::Attachment.find_live_by_file_path("/foo.txt")
76
- end
77
-
78
-
79
- test "If an uploaded file has no detectable content type (i.e. markdown) then assign it the 'unknown' type" do
80
- mock_file = mock()
81
- mock_file.expects(:content_type).returns(nil)
82
- atk = Cms::Attachment.new(:temp_file => mock_file)
83
- atk.extract_file_type_from_temp_file
84
-
85
- assert_equal Cms::Attachment::UNKNOWN_MIME_TYPE, atk.file_type
86
- end
87
- end
88
-
89
- class Cms::Attachment::SectionTest < ActiveSupport::TestCase
90
-
91
- def setup
92
- @file = file_upload_object({:original_filename => "sample_upload.txt", :content_type => "text/plain"})
93
- @attachment = Cms::Attachment.create!(:temp_file => @file, :file_path => "/foo.txt", :section => root_section)
94
- @attachment = Cms::Attachment.find(@attachment.id) # Force reload
95
- end
96
-
97
- test "Setting the section on an attachment persists that section" do
98
- assert_equal root_section, @attachment.section, "Should be associated with the root section"
99
- end
100
-
101
- test "Replacing an existing section should update it" do
102
- new_section = Factory(:section)
103
- @attachment.section = new_section
104
- @attachment.save!
105
- @attachment = Cms::Attachment.find(@attachment.id) # Force reload
106
- assert_equal new_section, @attachment.section
107
- end
108
- end
109
-
110
- class AttachmentRelations < ActiveSupport::TestCase
111
-
112
- def setup
113
- @file = file_upload_object({:original_filename => "sample_upload.txt", :content_type => "text/plain"})
114
- @attachment = Attachment.new(:temp_file => @file, :file_path => "/bar.txt", :section => root)
115
- @attachment.save!
116
- end
117
-
118
- test "#section= assigns a parent to a given attachment" do
119
- a = Attachment.new
120
- a.section = root
121
- assert_equal root, a.section
122
- end
123
-
124
- test "Attachments should be associated with a section" do
125
- assert_not_nil @attachment.section_node
126
- assert_not_nil @attachment.section_node.parent
127
- assert_equal root, @attachment.section
128
- end
129
-
130
- test "Attachment should be unpublished and unfindable" do
131
- assert !@attachment.published?, "Attachment should not be published"
132
- assert_nil Attachment.find_live_by_file_path("/foo.txt")
133
- end
134
-
135
- test "Publishing an attachment should make it findable" do
136
- @attachment.publish
137
- assert @attachment.reload.published?, "Attachment should be published"
138
- assert_equal @attachment, Attachment.find_live_by_file_path("/bar.txt")
139
- end
140
-
141
- test "Changing but not republishing an attachment should keep old version live" do
142
- @attachment.publish
143
- assert_equal @root, @attachment.section
144
- @attachment.update_attributes!(:file_type => "text/html")
145
- assert !@attachment.live?, "Attachment should not be live"
146
- assert_equal @attachment.as_of_version(2), Attachment.find_live_by_file_path("/bar.txt")
147
- end
148
-
149
- test "Updating the section" do
150
- new_section = Factory(:section, :name => "New")
151
- @attachment.update_attributes!(:section => new_section)
152
- assert_equal new_section, @attachment.section
153
- end
154
- private
155
-
156
- def root
157
- @root ||= Factory :root_section
158
- end
159
- end
160
- end
@@ -1,40 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CategoryTest < ActiveSupport::TestCase
4
- def test_creating_categories
5
- @a_type = Factory(:category_type, :name => "A")
6
- @b_type = Factory(:category_type, :name => "B")
7
-
8
- @a = Factory(:category, :name => "A", :category_type => @a_type)
9
- @a1 = Factory(:category, :name => "A1", :category_type => @a_type, :parent => @a)
10
- @a1a = Factory(:category, :name => "A1a", :category_type => @a_type, :parent => @a1)
11
- @a2 = Factory(:category, :name => "A2", :category_type => @a_type, :parent => @a)
12
- @b = Factory(:category, :name => "B", :category_type => @b_type)
13
- @b1 = Factory(:category, :name => "B1", :category_type => @b_type, :parent => @b)
14
- @b2 = Factory(:category, :name => "B2", :category_type => @b_type, :parent => @b)
15
-
16
- assert @a.parent.blank?
17
- assert_equal [@a1, @a2], @a.children
18
-
19
- assert_equal @a, @a1.parent
20
- assert_equal [@a1a], @a1.children
21
-
22
- assert_equal @a, @a2.parent
23
- assert @a2.children.blank?
24
-
25
- assert @a.ancestors.blank?
26
- assert_equal [@a], @a1.ancestors
27
- assert_equal [@a, @a1], @a1a.ancestors
28
-
29
- assert_equal "#{@a.name}", @a.path
30
- assert_equal "#{@a.name} > #{@a1.name}", @a1.path
31
- assert_equal "#{@a.name} > #{@a1.name} > #{@a1a.name}", @a1a.path
32
-
33
- assert_equal [
34
- "#{@a.name}",
35
- "#{@a.name} > #{@a1.name}",
36
- "#{@a.name} > #{@a1.name} > #{@a1a.name}",
37
- "#{@a.name} > #{@a2.name}"
38
- ], Cms::Category.of_type("A").all.map(&:path)
39
- end
40
- end
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CategoryTypeTest < ActiveSupport::TestCase
4
- def test_create
5
- category_type = Cms::CategoryType.new(:name => "Test")
6
- assert category_type.save
7
- end
8
- end
@@ -1,152 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ConnectorTest < ActiveSupport::TestCase
4
-
5
- def test_container_is_required
6
- connector = Factory.build(:connector, :container => nil)
7
- assert_not_valid connector
8
- assert_has_error_on connector, :container
9
- end
10
-
11
- def test_find_by_block
12
- foo = Factory(:html_block, :name => "foo")
13
- bar = Factory(:html_block, :name => "bar")
14
- Factory(:connector, :connectable => foo, :connectable_version => foo.version)
15
- blocks = Cms::Connector.for_connectable(foo).map(&:connectable)
16
- assert blocks.include?(foo)
17
- assert !blocks.include?(bar)
18
- end
19
-
20
- def test_only_find_connectors_for_a_block_that_match_the_current_version
21
- @foo = Factory(:html_block, :name => "foo")
22
- @foo.update_attribute(:name, "foo v2")
23
- @bar = Factory(:html_block, :name => "bar")
24
- @con = Factory(:connector, :connectable => @foo)
25
- @con.update_attribute(:connectable_version, 99)
26
- reset(:con)
27
- assert_raise(ActiveRecord::RecordNotFound) { @con.current_connectable }
28
- end
29
-
30
- def test_only_find_connectors_for_the_current_version_of_the_page
31
- @page = Factory(:page, :section => root_section)
32
- @connector = Factory(:connector, :page => @page)
33
- @page.update_attributes(:name => "Updated")
34
- assert_equal 1, @page.reload.connectors.for_page_version(@page.version).count
35
- end
36
-
37
- def test_blocks_not_deleted_when_connector_is_not_deleted
38
- b = Factory(:html_block)
39
- c = Factory(:connector, :connectable => b)
40
- connector_count = Cms::Connector.count
41
- c.destroy
42
- assert_decremented connector_count, Cms::Connector.count
43
- assert !Cms::HtmlBlock.find_by_id(b.id).nil?
44
- end
45
-
46
- def test_re_order_blocks_within_a_container
47
- page = Factory(:page)
48
- one = Factory(:connector, :page => page, :container => "foo")
49
- two = Factory(:connector, :page => page, :container => "foo")
50
- three = Factory(:connector, :page => page, :container => "foo")
51
-
52
- two.reload.move_up
53
- assert_equal [two, one, three].map(&:id),
54
- page.reload.connectors.for_page_version(page.version).in_container("foo").all.map(&:id)
55
-
56
- two.reload.move_down
57
- assert_equal [one, two, three],
58
- page.reload.connectors.for_page_version(page.version).in_container("foo").all
59
-
60
- three.reload.move_to_top
61
- assert_equal [three, one, two],
62
- page.reload.connectors.for_page_version(page.version).in_container("foo").all
63
-
64
- one.reload.move_to_bottom
65
- assert_equal [three, two, one],
66
- page.reload.connectors.for_page_version(page.version).in_container("foo").all
67
- end
68
-
69
- def test_connectable_with_deleted
70
- @page = Factory(:page)
71
- @block = Factory(:html_block, :name => "Deleted",
72
- :connect_to_page_id => @page.id,
73
- :connect_to_container => "main",
74
- :publish_on_save => "true")
75
-
76
- reset(:page, :block)
77
- @block.destroy
78
-
79
- reset(:page)
80
-
81
- log_table_without_stamps Cms::Connector
82
-
83
- assert_nil @page.connectors.for_page_version(2).first.connectable
84
-
85
- c = @page.connectors.for_page_version(2).first.connectable_with_deleted
86
- assert !c.nil?
87
- assert_equal @block.id, c.id
88
- assert_equal @block.name, c.name
89
- assert_equal 1, c.version
90
- end
91
-
92
- def test_connector_should_be_copied_when_it_has_a_connectable
93
- @page = Factory(:page)
94
- @block = Factory(:html_block, :connect_to_page_id => @page.id, :connect_to_container => "main")
95
-
96
- conn = Cms::Connector.new
97
- conn.connectable = @block
98
- assert(conn.connectable, "Check the assumption there is connectable.")
99
- assert_equal(false, conn.connectable.draft.deleted?, "Check the assumption that the draft is not-deleted.")
100
-
101
- assert(conn.should_be_copied?, "Verifes that normally a connector should be copied.")
102
- end
103
-
104
- def test_connector_shouldnt_copy_when_its_connectable_is_nil
105
- conn = Cms::Connector.new
106
- assert_nil(conn.connectable, "Check assumption that connectable is nil.")
107
-
108
- assert_equal false, conn.should_be_copied?, "Shouldn't copy when a connector isn't connected to anything."
109
- end
110
-
111
- def test_connector_should_copy_when_its_latest_draft_is_deleted
112
- @page = Factory(:page)
113
- @block = Factory(:html_block, :connect_to_page_id => @page.id, :connect_to_container => "main")
114
-
115
- @block.destroy
116
-
117
- conn = Cms::Connector.new
118
- conn.connectable = @block
119
-
120
- assert_equal true, @block.draft.deleted?, "Check assumption that latest draft of this block is 'deleted'."
121
- assert_equal false, conn.should_be_copied?, "Should not copy when latest draft is deleted."
122
-
123
- end
124
-
125
- def test_connector_should_copy_even_if_connectable_doesnt_have_drafts
126
- @page = Factory(:page)
127
- @block = Cms::Portlet.create!(:name => "Stuff")
128
-
129
- conn = Cms::Connector.new
130
- conn.connectable = @block
131
-
132
- assert_equal false, @block.respond_to?(:draft), "Check assumption that portlets do not respond to draft method."
133
- assert_equal true, conn.should_be_copied?, "Should not copy when latest draft is deleted."
134
-
135
- end
136
-
137
- def test_connector_with_file_block_status
138
- @page = Factory(:page)
139
- @file = Factory(:image_block, :connect_to_page_id => @page.id, :connect_to_container => "main", :publish_on_save => true)
140
- @page.reload
141
-
142
- assert @file.live?
143
- assert @page.connectors.last.live?
144
-
145
- @file.update_attributes(:name => "Something Else")
146
- @page.reload
147
-
148
- assert !@file.live?
149
- assert !@page.connectors.last.live?
150
- end
151
-
152
- end
@@ -1,26 +0,0 @@
1
- require "test_helper"
2
-
3
- module Cms
4
- class ContentTypeGroupTest < ActiveSupport::TestCase
5
-
6
- def setup
7
- @type1 = ContentType.create!(:name => "Cms::Block", :group_name => "A")
8
- @type2 = ContentType.create!(:name => "Cms::Block", :group_name => "B")
9
- end
10
-
11
- test ".menu_list returns all groups" do
12
- groups = ContentTypeGroup.menu_list
13
-
14
- assert_equal 2, groups.size
15
- assert_equal ["A", "B"], groups.map {|g| g.name }
16
- end
17
-
18
- test "#types returns all types ordered by position" do
19
- @type3 = ContentType.create!(:name => "Cms::Block", :group_name => "A")
20
-
21
- group = ContentTypeGroup.where(:name=>"A").first
22
- assert_equal [@type1, @type3], group.types
23
- end
24
-
25
- end
26
- end
@@ -1,177 +0,0 @@
1
- require 'test_helper'
2
-
3
- # Sample Model for testing naming/model classes
4
- class Kindness < ActiveRecord::Base
5
- acts_as_content_block
6
- end
7
-
8
- class ReallyLongNameClass < ActiveRecord::Base
9
- acts_as_content_block
10
-
11
- def self.display_name
12
- "Short"
13
- end
14
-
15
- def self.display_name_plural
16
- "Shorteez"
17
- end
18
- end
19
-
20
- module Cms
21
- class NamespacedBlock < ActiveRecord::Base
22
- acts_as_content_block
23
- end
24
- end
25
-
26
- class Unnamespaced < ActiveRecord::Base
27
- acts_as_content_block
28
- end
29
-
30
- class Widget < ActiveRecord::Base
31
- acts_as_content_block
32
- end
33
-
34
- module BcmsStore
35
- class Engine < Rails::Engine
36
- end
37
- class Widget < ActiveRecord::Base
38
- acts_as_content_block
39
- end
40
- end
41
-
42
-
43
- module Cms
44
-
45
- class ContentTypeTest < ActiveSupport::TestCase
46
- def setup
47
- @c = Cms::ContentType.new(:name => "ReallyLongNameClass")
48
- @unnamespaced_type = Cms::ContentType.create!(:name => "Unnamespaced", :group_name => "Core")
49
- end
50
-
51
-
52
- test "#key" do
53
- assert_equal "really_long_name_class", @c.key
54
- end
55
-
56
- test "#display_name for blocks from modules" do
57
- assert_equal "Widget", Cms::ContentType.new(:name => "BcmsStore::Widget").display_name
58
- assert_equal "Widget", BcmsStore::Widget.display_name
59
- end
60
-
61
- test "display_name for non-Cms classes" do
62
- assert_equal "String", Cms::ContentType.new(:name => "String").display_name
63
- end
64
-
65
- test "#form for unnamespaced blocks" do
66
- widget_type = Cms::ContentType.create!(:name => "Widget", :group_name => "Core")
67
- assert_equal "cms/widgets/form", widget_type.form
68
- end
69
-
70
- test "template_path" do
71
- assert_equal "cms/widgets/render", Widget.template_path
72
- end
73
-
74
- test "template_path for modules" do
75
- assert_equal "bcms_store/widgets/render", BcmsStore::Widget.template_path
76
- end
77
-
78
- test "find_by_key checks multiple namespaces" do
79
- assert_equal @unnamespaced_type, Cms::ContentType.find_by_key("Unnamespaced")
80
- end
81
-
82
- test "model_resource_name" do
83
- assert_equal "really_long_name_class", @c.model_class_form_name
84
- end
85
-
86
- test "Project specific routes should be still be namespaced under cms_" do
87
- assert_equal "main_app.cms_unnamespaced", @unnamespaced_type.route_name
88
- end
89
-
90
- test "route_name removes cms_ as prefix (no longer needed for engines)" do
91
- content_type = Cms::ContentType.new(:name => "Cms::NamespacedBlock")
92
- assert_equal "namespaced_block", content_type.route_name
93
- end
94
-
95
- test "engine_for using Class" do
96
- EngineHelper.decorate(Unnamespaced)
97
- assert_equal "main_app", Unnamespaced.engine_name
98
- end
99
-
100
- test "engine_name for Cms engine" do
101
- cms_namespace = Cms::ContentType.new(:name => "Cms::NamespacedBlock")
102
- assert_equal "cms", cms_namespace.engine_name
103
- end
104
-
105
- test "path_elements for Cms engine" do
106
- cms_namespace = Cms::ContentType.new(:name => "Cms::NamespacedBlock")
107
- assert_equal [Cms::NamespacedBlock], cms_namespace.path_elements
108
- end
109
-
110
- test "path_elements for an app ContentType" do
111
- assert_equal ["cms", Unnamespaced], @unnamespaced_type.path_elements
112
- end
113
-
114
- def test_model_class
115
- assert_equal ReallyLongNameClass, @c.model_class
116
- end
117
-
118
- test "creating self.display_name on content block will set display_name on content type" do
119
- assert_equal "Short", @c.display_name
120
- end
121
-
122
- test "creating self.display_name_plural on content block will set display_name_plural on content type" do
123
- assert_equal "Shorteez", @c.display_name_plural
124
- end
125
-
126
- def test_content_block_type
127
- assert_equal "really_long_name_classes", @c.content_block_type
128
- end
129
-
130
- test "find_by_key handles names that end with s correctly" do
131
- Cms::ContentType.create!(:name => "Kindness", :group_name => "Anything")
132
-
133
- ct = Cms::ContentType.find_by_key("kindness")
134
- assert_not_nil ct
135
- assert_equal "Kindness", ct.display_name
136
- end
137
-
138
- test "calculate the model_class name with s" do
139
- ct = Cms::ContentType.new(:name => "Kindness")
140
- assert_equal Kindness, ct.model_class
141
- end
142
-
143
- test "Form for Blocks with Engines" do
144
- engine_type = Cms::ContentType.new(:name => "BcmsStore::Widget")
145
- assert_equal true, engine_type.engine_exists?
146
- assert_equal "bcms_store/widgets/form", engine_type.form
147
- end
148
-
149
- end
150
- end
151
-
152
- # For testing find_by_key with pluralization
153
- class Person < ActiveRecord::Base
154
- acts_as_content_block
155
- end
156
-
157
- module Cms
158
-
159
- class FindByKeyTest < ActiveSupport::TestCase
160
-
161
- test "ActiveSupport#classify automatically singularizes" do
162
- assert_equal "Person", "people".tableize.classify
163
- assert_equal "people", "people".tableize
164
-
165
- end
166
-
167
- test "#find_by_key with irregular pluralization" do
168
- Factory(:content_type, :name => "Person")
169
-
170
- type = Cms::ContentType.find_by_key("people")
171
- assert_not_nil type
172
- assert_equal "Person", type.display_name
173
-
174
- end
175
- end
176
- end
177
-