activeadmin 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activeadmin might be problematic. Click here for more details.

Files changed (322) hide show
  1. data/.gitignore +5 -1
  2. data/.travis.yml +1 -1
  3. data/.yardopts +2 -3
  4. data/CHANGELOG.md +180 -36
  5. data/CONTRIBUTING.md +12 -2
  6. data/Gemfile +9 -3
  7. data/README.rdoc +38 -65
  8. data/Rakefile +1 -3
  9. data/activeadmin.gemspec +10 -11
  10. data/app/assets/images/active_admin/index_list_icons/block_icon.svg +1 -1
  11. data/app/assets/images/active_admin/index_list_icons/blog_icon.svg +1 -1
  12. data/app/assets/images/active_admin/index_list_icons/grid_icon.svg +1 -1
  13. data/app/assets/images/active_admin/index_list_icons/table_icon.svg +1 -1
  14. data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +2 -2
  15. data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +2 -2
  16. data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +2 -2
  17. data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +2 -2
  18. data/app/assets/javascripts/active_admin/lib/namespace.js.coffee +2 -1
  19. data/app/assets/javascripts/active_admin/pages/application.js.coffee +6 -1
  20. data/app/assets/stylesheets/active_admin/_base.css.scss +29 -34
  21. data/app/assets/stylesheets/active_admin/_forms.css.scss +65 -62
  22. data/app/assets/stylesheets/active_admin/_header.css.scss +57 -45
  23. data/app/assets/stylesheets/active_admin/_typography.css.scss +9 -9
  24. data/app/assets/stylesheets/active_admin/components/_batch_actions.css.scss +1 -1
  25. data/app/assets/stylesheets/active_admin/components/_blank_slates.scss +5 -5
  26. data/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss +2 -2
  27. data/app/assets/stylesheets/active_admin/components/_comments.css.scss +1 -1
  28. data/app/assets/stylesheets/active_admin/components/_date_picker.css.scss +20 -20
  29. data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +16 -16
  30. data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +25 -23
  31. data/app/assets/stylesheets/active_admin/components/_grid.scss +2 -2
  32. data/app/assets/stylesheets/active_admin/components/_index_list.scss +1 -1
  33. data/app/assets/stylesheets/active_admin/components/_pagination.scss +10 -10
  34. data/app/assets/stylesheets/active_admin/components/_panels.scss +1 -1
  35. data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +27 -27
  36. data/app/assets/stylesheets/active_admin/components/_scopes.scss +1 -1
  37. data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +10 -10
  38. data/app/assets/stylesheets/active_admin/components/_tables.css.scss +9 -9
  39. data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +3 -3
  40. data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +4 -4
  41. data/app/assets/stylesheets/active_admin/mixins/_icons.css.scss +4 -7
  42. data/app/assets/stylesheets/active_admin/mixins/_reset.css.scss +5 -5
  43. data/app/assets/stylesheets/active_admin/mixins/_rounded.css.scss +3 -3
  44. data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +6 -6
  45. data/app/assets/stylesheets/active_admin/mixins/_shadows.css.scss +8 -8
  46. data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
  47. data/app/assets/stylesheets/active_admin/mixins/_utilities.scss +1 -1
  48. data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +9 -1
  49. data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +1 -1
  50. data/app/assets/stylesheets/active_admin/print.css.scss +2 -8
  51. data/app/assets/stylesheets/active_admin/structure/_footer.scss +5 -5
  52. data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +13 -13
  53. data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +14 -14
  54. data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
  55. data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
  56. data/app/views/active_admin/devise/shared/_links.erb +8 -1
  57. data/app/views/active_admin/resource/index.csv.erb +3 -3
  58. data/app/views/layouts/active_admin_logged_out.html.erb +5 -3
  59. data/config/locales/bg.yml +101 -0
  60. data/{lib/active_admin → config}/locales/ca.yml +24 -7
  61. data/{lib/active_admin → config}/locales/cs.yml +34 -12
  62. data/{lib/active_admin → config}/locales/da.yml +29 -7
  63. data/config/locales/de-CH.yml +117 -0
  64. data/{lib/active_admin → config}/locales/de.yml +19 -9
  65. data/config/locales/en-GB.yml +90 -0
  66. data/{lib/active_admin → config}/locales/en.yml +16 -6
  67. data/config/locales/es.yml +106 -0
  68. data/{lib/active_admin/locales/es.yml → config/locales/es_MX.yml} +14 -8
  69. data/{lib/active_admin → config}/locales/fr.yml +14 -6
  70. data/{lib/active_admin → config}/locales/he.yml +16 -6
  71. data/{lib/active_admin → config}/locales/hr.yml +14 -6
  72. data/{lib/active_admin → config}/locales/hu.yml +31 -6
  73. data/{lib/active_admin → config}/locales/it.yml +14 -6
  74. data/{lib/active_admin → config}/locales/ja.yml +32 -7
  75. data/{lib/active_admin → config}/locales/ko.yml +14 -6
  76. data/{lib/active_admin → config}/locales/lt.yml +15 -6
  77. data/{lib/active_admin → config}/locales/lv.yml +14 -6
  78. data/{lib/active_admin → config}/locales/nl.yml +14 -6
  79. data/{lib/active_admin → config}/locales/no-NB.yml +14 -6
  80. data/{lib/active_admin → config}/locales/pl.yml +14 -6
  81. data/{lib/active_admin → config}/locales/pt-BR.yml +14 -6
  82. data/{lib/active_admin → config}/locales/pt-PT.yml +14 -6
  83. data/{lib/active_admin → config}/locales/ro.yml +32 -7
  84. data/{lib/active_admin → config}/locales/ru.yml +30 -8
  85. data/{lib/active_admin → config}/locales/sv-SE.yml +14 -6
  86. data/{lib/active_admin → config}/locales/tr.yml +15 -6
  87. data/config/locales/uk.yml +100 -0
  88. data/{lib/active_admin → config}/locales/vi.yml +15 -6
  89. data/{lib/active_admin → config}/locales/zh-CN.yml +15 -6
  90. data/{lib/active_admin → config}/locales/zh-TW.yml +15 -6
  91. data/docs/0-installation.md +22 -18
  92. data/docs/1-general-configuration.md +1 -1
  93. data/docs/10-custom-pages.md +3 -3
  94. data/docs/11-decorators.md +18 -2
  95. data/docs/12-arbre-components.md +53 -54
  96. data/docs/13-authorization-adapter.md +31 -10
  97. data/docs/2-resource-customization.md +16 -1
  98. data/docs/3-index-pages.md +13 -1
  99. data/docs/3-index-pages/create-an-index.md +4 -4
  100. data/docs/3-index-pages/index-as-block.md +1 -1
  101. data/docs/3-index-pages/index-as-blog.md +1 -1
  102. data/docs/3-index-pages/index-as-grid.md +1 -1
  103. data/docs/4-csv-format.md +4 -4
  104. data/docs/5-forms.md +46 -3
  105. data/docs/{6-show-screens.md → 6-show-pages.md} +3 -3
  106. data/docs/8-custom-actions.md +3 -3
  107. data/docs/9-batch-actions.md +9 -1
  108. data/features/action_item.feature +6 -6
  109. data/features/authorization_cancan.feature +1 -1
  110. data/features/belongs_to.feature +3 -3
  111. data/features/breadcrumb.feature +2 -2
  112. data/features/comments/commenting.feature +7 -5
  113. data/features/dashboard.feature +0 -51
  114. data/features/favicon.feature +20 -0
  115. data/features/global_navigation.feature +0 -1
  116. data/features/index/batch_actions.feature +12 -11
  117. data/features/index/filters.feature +6 -6
  118. data/features/index/format_as_csv.feature +4 -5
  119. data/features/index/index_as_blog.feature +20 -1
  120. data/features/index/index_as_table.feature +1 -1
  121. data/features/index/index_blank_slate.feature +3 -3
  122. data/features/index/index_parameters.feature +4 -10
  123. data/features/index/index_scope_to.feature +24 -0
  124. data/features/index/index_scopes.feature +17 -5
  125. data/features/index/pagination.feature +15 -0
  126. data/features/registering_pages.feature +1 -1
  127. data/features/registering_resources.feature +2 -2
  128. data/features/show/default_content.feature +3 -3
  129. data/features/sidebar_sections.feature +3 -3
  130. data/features/specifying_actions.feature +1 -1
  131. data/features/step_definitions/additional_web_steps.rb +3 -16
  132. data/features/step_definitions/asset_steps.rb +5 -1
  133. data/features/step_definitions/attribute_steps.rb +4 -4
  134. data/features/step_definitions/batch_action_steps.rb +25 -74
  135. data/features/step_definitions/breadcrumb_steps.rb +1 -3
  136. data/features/step_definitions/comment_steps.rb +0 -1
  137. data/features/step_definitions/configuration_steps.rb +53 -69
  138. data/features/step_definitions/dashboard_steps.rb +2 -2
  139. data/features/step_definitions/factory_steps.rb +17 -33
  140. data/features/step_definitions/filter_steps.rb +2 -2
  141. data/features/step_definitions/format_steps.rb +10 -14
  142. data/features/step_definitions/index_scope_steps.rb +9 -25
  143. data/features/step_definitions/index_views_steps.rb +1 -1
  144. data/features/step_definitions/sidebar_steps.rb +2 -1
  145. data/features/step_definitions/site_title_steps.rb +1 -1
  146. data/features/step_definitions/table_steps.rb +6 -1
  147. data/features/step_definitions/user_steps.rb +23 -38
  148. data/features/step_definitions/web_steps.rb +18 -147
  149. data/features/support/env.rb +13 -34
  150. data/features/support/paths.rb +2 -0
  151. data/features/users/logging_in.feature +2 -2
  152. data/features/users/logging_out.feature +0 -12
  153. data/features/users/resetting_password.feature +1 -1
  154. data/lib/active_admin.rb +4 -17
  155. data/lib/active_admin/abstract_view_factory.rb +1 -1
  156. data/lib/active_admin/application.rb +19 -28
  157. data/lib/active_admin/asset_registration.rb +7 -25
  158. data/lib/active_admin/authorization_adapter.rb +9 -5
  159. data/lib/active_admin/base_controller.rb +2 -2
  160. data/lib/active_admin/base_controller/authorization.rb +25 -27
  161. data/lib/active_admin/batch_actions/resource_extension.rb +3 -3
  162. data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -1
  163. data/lib/active_admin/batch_actions/views/selection_cells.rb +1 -1
  164. data/lib/active_admin/callbacks.rb +1 -1
  165. data/lib/active_admin/cancan_adapter.rb +2 -2
  166. data/lib/active_admin/comments.rb +32 -38
  167. data/lib/active_admin/comments/comment.rb +6 -8
  168. data/lib/active_admin/comments/views.rb +0 -1
  169. data/lib/active_admin/comments/views/active_admin_comments.rb +27 -38
  170. data/lib/active_admin/csv_builder.rb +4 -6
  171. data/lib/active_admin/dependency_checker.rb +4 -0
  172. data/lib/active_admin/deprecation.rb +3 -3
  173. data/lib/active_admin/dsl.rb +5 -5
  174. data/lib/active_admin/engine.rb +1 -1
  175. data/lib/active_admin/filters.rb +2 -1
  176. data/lib/active_admin/filters/forms.rb +36 -43
  177. data/lib/active_admin/filters/formtastic_addons.rb +45 -0
  178. data/lib/active_admin/filters/resource_extension.rb +9 -1
  179. data/lib/active_admin/form_builder.rb +30 -19
  180. data/lib/active_admin/helpers/optional_display.rb +11 -13
  181. data/lib/active_admin/helpers/settings.rb +50 -8
  182. data/lib/active_admin/inputs/filter_base.rb +5 -18
  183. data/lib/active_admin/inputs/filter_base/search_method_select.rb +73 -0
  184. data/lib/active_admin/inputs/filter_boolean_input.rb +6 -14
  185. data/lib/active_admin/inputs/filter_check_boxes_input.rb +1 -1
  186. data/lib/active_admin/inputs/filter_numeric_input.rb +2 -47
  187. data/lib/active_admin/inputs/filter_select_input.rb +32 -10
  188. data/lib/active_admin/inputs/filter_string_input.rb +12 -14
  189. data/lib/active_admin/namespace.rb +8 -40
  190. data/lib/active_admin/page.rb +2 -2
  191. data/lib/active_admin/page_dsl.rb +1 -1
  192. data/lib/active_admin/reloader.rb +3 -3
  193. data/lib/active_admin/resource.rb +16 -23
  194. data/lib/active_admin/resource/belongs_to.rb +8 -5
  195. data/lib/active_admin/resource/menu.rb +10 -23
  196. data/lib/active_admin/resource/naming.rb +3 -3
  197. data/lib/active_admin/resource/page_presenters.rb +2 -2
  198. data/lib/active_admin/resource/routes.rb +74 -21
  199. data/lib/active_admin/resource/scope_to.rb +74 -0
  200. data/lib/active_admin/resource/scopes.rb +8 -4
  201. data/lib/active_admin/resource_collection.rb +20 -66
  202. data/lib/active_admin/resource_controller.rb +12 -16
  203. data/lib/active_admin/resource_controller/data_access.rb +19 -22
  204. data/lib/active_admin/resource_controller/resource_class_methods.rb +2 -2
  205. data/lib/active_admin/resource_controller/scoping.rb +4 -9
  206. data/lib/active_admin/resource_dsl.rb +5 -32
  207. data/lib/active_admin/router.rb +34 -47
  208. data/lib/active_admin/scope.rb +5 -3
  209. data/lib/active_admin/sidebar_section.rb +1 -1
  210. data/lib/active_admin/version.rb +1 -1
  211. data/lib/active_admin/view_factory.rb +1 -1
  212. data/lib/active_admin/view_helpers/auto_link_helper.rb +1 -1
  213. data/lib/active_admin/view_helpers/breadcrumb_helper.rb +8 -8
  214. data/lib/active_admin/view_helpers/display_helper.rb +15 -6
  215. data/lib/active_admin/view_helpers/download_format_links_helper.rb +2 -2
  216. data/lib/active_admin/view_helpers/form_helper.rb +6 -1
  217. data/lib/active_admin/view_helpers/icon_helper.rb +1 -1
  218. data/lib/active_admin/view_helpers/method_or_proc_helper.rb +5 -5
  219. data/lib/active_admin/view_helpers/title_helper.rb +1 -1
  220. data/lib/active_admin/views/components/action_list_popover.rb +6 -6
  221. data/lib/active_admin/views/components/attributes_table.rb +9 -12
  222. data/lib/active_admin/views/components/blank_slate.rb +4 -4
  223. data/lib/active_admin/views/components/columns.rb +1 -1
  224. data/lib/active_admin/views/components/index_list.rb +1 -1
  225. data/lib/active_admin/views/components/paginated_collection.rb +20 -12
  226. data/lib/active_admin/views/components/panel.rb +1 -1
  227. data/lib/active_admin/views/components/scopes.rb +2 -1
  228. data/lib/active_admin/views/components/sidebar_section.rb +1 -1
  229. data/lib/active_admin/views/components/status_tag.rb +1 -1
  230. data/lib/active_admin/views/header.rb +2 -2
  231. data/lib/active_admin/views/index_as_blog.rb +16 -3
  232. data/lib/active_admin/views/index_as_table.rb +2 -2
  233. data/lib/active_admin/views/pages/base.rb +8 -3
  234. data/lib/active_admin/views/pages/form.rb +2 -2
  235. data/lib/active_admin/views/pages/index.rb +19 -17
  236. data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +1 -1
  237. data/lib/generators/active_admin/assets/templates/3.1/active_admin.css.scss +1 -13
  238. data/lib/generators/active_admin/devise/devise_generator.rb +22 -1
  239. data/lib/generators/active_admin/install/install_generator.rb +1 -5
  240. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +40 -19
  241. data/lib/generators/active_admin/install/templates/admin_user.rb.erb +18 -18
  242. data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb +19 -0
  243. data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
  244. data/lib/generators/active_admin/resource/templates/admin.rb +1 -1
  245. data/script/use_rails +1 -1
  246. data/spec/integration/memory_spec.rb +3 -2
  247. data/spec/javascripts/coffeescripts/jquery.aa.checkbox-toggler-spec.js.coffee +4 -4
  248. data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +1 -1
  249. data/spec/javascripts/coffeescripts/jquery.aa.table-checkbox-toggler-spec.js.coffee +2 -2
  250. data/spec/javascripts/compiled/jquery.aa.checkbox-toggler-spec.js +4 -4
  251. data/spec/javascripts/compiled/jquery.aa.popover-spec.js +1 -1
  252. data/spec/javascripts/compiled/jquery.aa.table-checkbox-toggler-spec.js +2 -2
  253. data/spec/spec_helper.rb +16 -6
  254. data/spec/spec_helper_without_rails.rb +2 -0
  255. data/spec/support/deferred_garbage_collection.rb +19 -0
  256. data/spec/support/jslint.yml +1 -1
  257. data/spec/support/rails_template.rb +29 -27
  258. data/spec/support/templates/admin/stores.rb +5 -1
  259. data/spec/unit/abstract_view_factory_spec.rb +1 -1
  260. data/spec/unit/action_builder_spec.rb +7 -7
  261. data/spec/unit/active_admin_spec.rb +0 -14
  262. data/spec/unit/application_spec.rb +16 -17
  263. data/spec/unit/asset_registration_spec.rb +21 -8
  264. data/spec/unit/authorization/authorization_adapter_spec.rb +3 -3
  265. data/spec/unit/authorization/controller_authorization_spec.rb +16 -24
  266. data/spec/unit/batch_actions/resource_spec.rb +11 -11
  267. data/spec/unit/belongs_to_spec.rb +1 -1
  268. data/spec/unit/cancan_adapter_spec.rb +11 -3
  269. data/spec/unit/comments_spec.rb +10 -28
  270. data/spec/unit/controller_filters_spec.rb +22 -24
  271. data/spec/unit/csv_builder_spec.rb +3 -3
  272. data/spec/unit/devise_spec.rb +10 -10
  273. data/spec/unit/filters/filter_form_builder_spec.rb +140 -45
  274. data/spec/unit/filters/resource_spec.rb +20 -19
  275. data/spec/unit/form_builder_spec.rb +122 -70
  276. data/spec/unit/menu_item_spec.rb +3 -3
  277. data/spec/unit/namespace/authorization_spec.rb +4 -8
  278. data/spec/unit/namespace/register_page_spec.rb +1 -1
  279. data/spec/unit/namespace/register_resource_spec.rb +12 -7
  280. data/spec/unit/namespace_spec.rb +4 -10
  281. data/spec/unit/page_spec.rb +1 -1
  282. data/spec/unit/resource/menu_spec.rb +1 -1
  283. data/spec/unit/resource/naming_spec.rb +9 -0
  284. data/spec/unit/resource/pagination_spec.rb +2 -2
  285. data/spec/unit/resource/routes_spec.rb +73 -0
  286. data/spec/unit/resource/scopes_spec.rb +1 -1
  287. data/spec/unit/resource_collection_spec.rb +95 -43
  288. data/spec/unit/resource_registration_spec.rb +3 -12
  289. data/spec/unit/resource_spec.rb +41 -48
  290. data/spec/unit/routing_spec.rb +10 -64
  291. data/spec/unit/scope_spec.rb +19 -0
  292. data/spec/unit/settings_spec.rb +88 -0
  293. data/spec/unit/view_factory_spec.rb +1 -0
  294. data/spec/unit/{breadcrumbs_spec.rb → view_helpers/breadcrumbs_spec.rb} +16 -7
  295. data/spec/unit/view_helpers/display_name_spec.rb +41 -0
  296. data/spec/unit/view_helpers/form_helper_spec.rb +36 -2
  297. data/spec/unit/views/components/attributes_table_spec.rb +17 -9
  298. data/spec/unit/views/components/batch_action_popover_spec.rb +4 -4
  299. data/spec/unit/views/components/index_list_spec.rb +2 -2
  300. data/spec/unit/views/components/paginated_collection_spec.rb +42 -0
  301. data/spec/unit/views/components/panel_spec.rb +8 -0
  302. data/spec/unit/views/components/site_title_spec.rb +2 -2
  303. data/spec/unit/views/components/table_for_spec.rb +4 -4
  304. data/spec/unit/views/pages/form_spec.rb +35 -0
  305. data/spec/unit/views/pages/layout_spec.rb +1 -1
  306. data/spec/unit/views/tabbed_navigation_spec.rb +10 -10
  307. data/tasks/parallel_tests.rake +1 -1
  308. data/tasks/test.rake +4 -1
  309. metadata +117 -106
  310. data/app/assets/stylesheets/active_admin/pages/_dashboard.scss +0 -5
  311. data/lib/active_admin/comments/views/active_admin_comment.rb +0 -0
  312. data/lib/active_admin/dashboards.rb +0 -68
  313. data/lib/active_admin/dashboards/dashboard_controller.rb +0 -50
  314. data/lib/active_admin/dashboards/section.rb +0 -34
  315. data/lib/active_admin/locales/bg.yml +0 -77
  316. data/lib/generators/active_admin/install/templates/migrations/1_create_admin_notes.rb +0 -17
  317. data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +0 -26
  318. data/spec/unit/base_controller_spec.rb +0 -6
  319. data/spec/unit/dashboard_controller_spec.rb +0 -76
  320. data/spec/unit/dashboard_section_spec.rb +0 -56
  321. data/spec/unit/dashboards_spec.rb +0 -59
  322. data/spec/unit/display_name_spec.rb +0 -29
@@ -9,66 +9,12 @@ describe ActiveAdmin, "Routing", :type => :routing do
9
9
  reload_routes!
10
10
  end
11
11
 
12
- include Rails.application.routes.url_helpers
13
-
14
- describe "root" do
15
- before do
16
- pending "Y U NO PASS?"
17
- end
18
- context "when default configuration" do
19
- context "when in admin namespace" do
20
- it "should route the admin dashboard" do
21
- get('/admin').should route_to('admin/dashboard#index')
22
- end
23
- end
24
-
25
- context "when in root namespace" do
26
- before(:each) do
27
- load_resources { ActiveAdmin.register(Post, :namespace => false) }
28
- reload_routes!
29
- end
30
-
31
- it "should route the root dashboard" do
32
- pending "Y U NO PASS?"
33
-
34
- get('/').should route_to('dashboard#index')
35
- end
36
- end
37
- end
38
-
39
- context "when customized configuration to root to post#index" do
40
- before do
41
- @original_root = ActiveAdmin.application.root_to
42
- ActiveAdmin.application.root_to = "posts#index"
43
- end
44
-
45
- after do
46
- ActiveAdmin.application.root_to = @original_root
47
- reload_routes!
48
- end
49
-
50
- context "when in admin namespace" do
51
- before do
52
- load_resources { ActiveAdmin.register(Post) }
53
- end
54
-
55
- it "should route to admin/posts#index" do
56
- get('/admin').should route_to('admin/posts#index')
57
- end
58
- end
59
-
60
- context "when in root namespace" do
61
- before do
62
- load_resources { ActiveAdmin.register(Post, :namespace => false) }
63
- end
64
-
65
- it "should route to posts#index" do
66
- pending "Y U NO PASS?"
12
+ it "should only have the namespaces necessary for route testing" do
13
+ ActiveAdmin.application.namespaces.keys.should eq [:admin, :root]
14
+ end
67
15
 
68
- get('/').should route_to('posts#index')
69
- end
70
- end
71
- end
16
+ it "should route to the admin dashboard" do
17
+ get('/admin').should route_to 'admin/dashboard#index'
72
18
  end
73
19
 
74
20
  describe "standard resources" do
@@ -115,7 +61,7 @@ describe ActiveAdmin, "Routing", :type => :routing do
115
61
  context "with member action" do
116
62
  context "without an http verb" do
117
63
  before do
118
- load_resources do
64
+ load_resources do
119
65
  ActiveAdmin.register(Post){ member_action "do_something" }
120
66
  end
121
67
  end
@@ -128,7 +74,7 @@ describe ActiveAdmin, "Routing", :type => :routing do
128
74
 
129
75
  context "with one http verb" do
130
76
  before do
131
- load_resources do
77
+ load_resources do
132
78
  ActiveAdmin.register(Post){ member_action "do_something", :method => :post }
133
79
  end
134
80
  end
@@ -140,7 +86,7 @@ describe ActiveAdmin, "Routing", :type => :routing do
140
86
 
141
87
  context "with two http verbs" do
142
88
  before do
143
- load_resources do
89
+ load_resources do
144
90
  ActiveAdmin.register(Post){ member_action "do_something", :method => [:put, :delete] }
145
91
  end
146
92
  end
@@ -149,8 +95,8 @@ describe ActiveAdmin, "Routing", :type => :routing do
149
95
  {:put => "/admin/posts/1/do_something"}.should be_routable
150
96
  end
151
97
 
152
- it "should properly route the second verb" do
153
- {:delete => "/admin/posts/1/do_something"}.should be_routable
98
+ it "should properly route the second verb" do
99
+ {:delete => "/admin/posts/1/do_something"}.should be_routable
154
100
  end
155
101
  end
156
102
  end
@@ -72,6 +72,25 @@ describe ActiveAdmin::Scope do
72
72
 
73
73
  end
74
74
 
75
+ describe "#default" do
76
+
77
+ it "should accept a boolean" do
78
+ scope = ActiveAdmin::Scope.new(:method, nil, :default => true)
79
+ scope.default_block.should == true
80
+ end
81
+
82
+ it "should default to a false #default_block" do
83
+ scope = ActiveAdmin::Scope.new(:method, nil)
84
+ scope.default_block.call.should == false
85
+ end
86
+
87
+ it "should store the :default proc" do
88
+ scope = ActiveAdmin::Scope.new(:with_block, nil, :default => proc{ true })
89
+ scope.default_block.call.should == true
90
+ end
91
+
92
+ end
93
+
75
94
  describe "show_count" do
76
95
 
77
96
  it "should allow setting of show_count to prevent showing counts" do
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActiveAdmin::Settings do
4
+
5
+ subject{ Class.new{ include ActiveAdmin::Settings } }
6
+
7
+ it{ should respond_to :setting }
8
+ it{ should respond_to :deprecated_setting }
9
+ it{ should respond_to :default_settings }
10
+
11
+ describe "class API" do
12
+ it "should create settings" do
13
+ subject.setting :foo, 'bar'
14
+ subject.default_settings[:foo].should eq 'bar'
15
+ end
16
+
17
+ it "should create deprecated settings" do
18
+ ActiveAdmin::Deprecation.should_receive(:deprecate).twice
19
+ subject.deprecated_setting :baz, 32
20
+ subject.default_settings[:baz].should eq 32
21
+ end
22
+ end
23
+
24
+ describe "instance API" do
25
+
26
+ before do
27
+ subject.setting :foo, 'bar'
28
+ subject.deprecated_setting :baz, 32
29
+ end
30
+ let(:instance) { subject.new }
31
+
32
+ it "should have access to a default value" do
33
+ instance.foo.should eq 'bar'
34
+ instance.foo = 'qqq'
35
+ instance.foo.should eq 'qqq'
36
+ end
37
+
38
+ it "should have access to a deprecated value" do
39
+ ActiveAdmin::Deprecation.should_receive(:warn).exactly(3).times
40
+ instance.baz.should eq 32
41
+ instance.baz = [45]
42
+ instance.baz.should eq [45]
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+
49
+ describe ActiveAdmin::Settings::Inheritance do
50
+
51
+ subject do
52
+ Class.new do
53
+ include ActiveAdmin::Settings
54
+ include ActiveAdmin::Settings::Inheritance
55
+ end
56
+ end
57
+
58
+ it{ should respond_to :settings_inherited_by }
59
+ it{ should respond_to :inheritable_setting }
60
+ it{ should respond_to :deprecated_inheritable_setting }
61
+
62
+ let(:heir) { Class.new }
63
+
64
+ before do
65
+ subject.settings_inherited_by heir
66
+ end
67
+
68
+ describe "class API" do
69
+ it "should add setting to an heir" do
70
+ subject.inheritable_setting :one, 2
71
+ heir.default_settings[:one].should eq 2
72
+ end
73
+
74
+ it "should add deprecated setting to an heir" do
75
+ ActiveAdmin::Deprecation.should_receive(:deprecate).exactly(4).times
76
+ subject.deprecated_inheritable_setting :three, 4
77
+ heir.default_settings[:three].should eq 4
78
+ end
79
+ end
80
+
81
+ describe "instance API" do
82
+ before{ subject.inheritable_setting :left, :right }
83
+ it "should work" do
84
+ heir.new.left.should eq :right
85
+ end
86
+ end
87
+
88
+ end
@@ -9,6 +9,7 @@ end
9
9
  describe ActiveAdmin::ViewFactory do
10
10
 
11
11
  it_should_have_view :global_navigation, ActiveAdmin::Views::TabbedNavigation
12
+ it_should_have_view :utility_navigation, ActiveAdmin::Views::TabbedNavigation
12
13
  it_should_have_view :site_title, ActiveAdmin::Views::SiteTitle
13
14
  it_should_have_view :action_items, ActiveAdmin::Views::ActionItems
14
15
  it_should_have_view :header, ActiveAdmin::Views::Header
@@ -11,10 +11,20 @@ describe "Breadcrumbs" do
11
11
  # Mock link to and return a hash
12
12
  def link_to(name, url); {:name => name, :path => url}; end
13
13
 
14
+ let(:post) { mock(:display_name => 'Hello World') }
15
+
16
+ let(:post_config) { stub(find_resource: post) }
17
+
18
+ let :active_admin_config do
19
+ active_admin_config = stub
20
+ active_admin_config.stub_chain(:belongs_to_config, :target).and_return post_config
21
+ active_admin_config
22
+ end
23
+
14
24
  let(:trail) { breadcrumb_links(path) }
15
25
 
16
26
  context "when request '/admin'" do
17
- let(:path){ "/admin" }
27
+ let(:path) { "/admin" }
18
28
 
19
29
  it "should not have any items" do
20
30
  trail.size.should == 0
@@ -65,6 +75,7 @@ describe "Breadcrumbs" do
65
75
  end
66
76
 
67
77
  context "when Post.find(1) doesn't exist" do
78
+ before { post_config.stub(find_resource: nil) }
68
79
  it "should have a link to /admin/posts/1" do
69
80
  trail[2][:name].should == "1"
70
81
  trail[2][:path].should == "/admin/posts/1"
@@ -72,9 +83,6 @@ describe "Breadcrumbs" do
72
83
  end
73
84
 
74
85
  context "when Post.find(1) does exist" do
75
- before do
76
- Post.stub!(:find_by_id).and_return{ mock(:display_name => "Hello World") }
77
- end
78
86
  it "should have a link to /admin/posts/1 using display name" do
79
87
  trail[2][:name].should == "Hello World"
80
88
  trail[2][:path].should == "/admin/posts/1"
@@ -98,6 +106,7 @@ describe "Breadcrumbs" do
98
106
  end
99
107
 
100
108
  context "when Post.find(4e24d6249ccf967313000000) doesn't exist" do
109
+ before { post_config.stub(find_resource: nil) }
101
110
  it "should have a link to /admin/posts/4e24d6249ccf967313000000" do
102
111
  trail[2][:name].should == "4e24d6249ccf967313000000"
103
112
  trail[2][:path].should == "/admin/posts/4e24d6249ccf967313000000"
@@ -106,10 +115,10 @@ describe "Breadcrumbs" do
106
115
 
107
116
  context "when Post.find(4e24d6249ccf967313000000) does exist" do
108
117
  before do
109
- Post.stub!(:find_by_id).with('4e24d6249ccf967313000000').and_return{ mock(:display_name => "Hello World") }
118
+ post_config.stub(:find_resource => mock(:display_name => 'Hello :)'))
110
119
  end
111
120
  it "should have a link to /admin/posts/4e24d6249ccf967313000000 using display name" do
112
- trail[2][:name].should == "Hello World"
121
+ trail[2][:name].should == "Hello :)"
113
122
  trail[2][:path].should == "/admin/posts/4e24d6249ccf967313000000"
114
123
  end
115
124
  end
@@ -130,7 +139,7 @@ describe "Breadcrumbs" do
130
139
  trail[1][:path].should == "/admin/posts"
131
140
  end
132
141
  it "should have a link to /admin/posts/1" do
133
- trail[2][:name].should == "1"
142
+ trail[2][:name].should == "Hello World"
134
143
  trail[2][:path].should == "/admin/posts/1"
135
144
  end
136
145
  it "should have a link to /admin/posts/1/comments" do
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe "display_name" do
4
+
5
+ include ActiveAdmin::ViewHelpers
6
+
7
+ [:display_name, :full_name, :name, :username, :login, :title, :email, :to_s].each do |m|
8
+ it "should return #{m} when defined" do
9
+ r = Class.new do
10
+ define_method m do
11
+ m.to_s
12
+ end
13
+ end.new
14
+ display_name(r).should == m.to_s
15
+ end
16
+ end
17
+
18
+ it "should memeoize the result for the class" do
19
+ subject { Class.new.new }
20
+ subject.should_receive(:name).twice.and_return "My Name"
21
+ display_name(subject).should == "My Name"
22
+ ActiveAdmin.application.should_not_receive(:display_name_methods)
23
+ display_name(subject).should == "My Name"
24
+ end
25
+
26
+ it "should not call a method if it's an association" do
27
+ subject { Class.new.new }
28
+ subject.stub_chain(:class, :reflect_on_all_associations).and_return [ mock(:name => :login) ]
29
+ subject.stub :login
30
+ subject.should_not_receive :login
31
+ subject.stub(:email).and_return 'foo@bar.baz'
32
+ display_name(subject).should == 'foo@bar.baz'
33
+ end
34
+
35
+ [nil, false].each do |type|
36
+ it "should return nil when the passed object is #{type.inspect}" do
37
+ display_name(type).should eq nil
38
+ end
39
+ end
40
+
41
+ end
@@ -1,11 +1,45 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveAdmin::ViewHelpers::FormHelper do
4
+
5
+ describe '.active_admin_form_for' do
6
+ let(:view) { action_view }
7
+ let(:resource) { stub('resource') }
8
+ let(:default_options) { { builder: ActiveAdmin::FormBuilder } }
9
+
10
+ it 'calls semantic_form_for with the ActiveAdmin form builder' do
11
+ view.should_receive(:semantic_form_for).with(resource, builder: ActiveAdmin::FormBuilder)
12
+ view.active_admin_form_for(resource)
13
+ end
14
+
15
+ it 'allows the form builder to be customized' do
16
+ # We can't use a stub here because options gets marshalled, and a new
17
+ # instance built. Any constant will work.
18
+ custom_builder = Object
19
+ view.should_receive(:semantic_form_for).with(resource, builder: custom_builder)
20
+ view.active_admin_form_for(resource, builder: custom_builder)
21
+ end
22
+
23
+ context 'with a decorated resource' do
24
+ let(:decorated) { stub('decorated_resource', model: resource) }
25
+
26
+ it 'can disable automatic decoration' do
27
+ view.should_receive(:semantic_form_for).with(resource, default_options.merge(decorate: false))
28
+ view.active_admin_form_for(decorated, decorate: false)
29
+ end
30
+
31
+ it 'can enable automatic decoration' do
32
+ view.should_receive(:semantic_form_for).with(decorated, default_options.merge(decorate: true))
33
+ view.active_admin_form_for(decorated, decorate: true)
34
+ end
35
+ end
36
+ end
37
+
4
38
  describe ".hidden_field_tags_for" do
5
39
  let(:view) { action_view }
6
40
 
7
41
  it "should render hidden field tags for params" do
8
- view.hidden_field_tags_for(:scope => "All", :filter => "None").should ==
42
+ view.hidden_field_tags_for(:scope => "All", :filter => "None").should ==
9
43
  %{<input id="hidden_active_admin_scope" name="scope" type="hidden" value="All" />\n<input id="hidden_active_admin_filter" name="filter" type="hidden" value="None" />}
10
44
  end
11
45
 
@@ -14,7 +48,7 @@ describe ActiveAdmin::ViewHelpers::FormHelper do
14
48
  end
15
49
 
16
50
  it "should filter out the field passed via the option :except" do
17
- view.hidden_field_tags_for({:scope => "All", :filter => "None"}, :except => :filter).should ==
51
+ view.hidden_field_tags_for({:scope => "All", :filter => "None"}, :except => :filter).should ==
18
52
  %{<input id="hidden_active_admin_scope" name="scope" type="hidden" value="All" />}
19
53
  end
20
54
  end
@@ -46,8 +46,16 @@ describe ActiveAdmin::Views::AttributesTable do
46
46
  row("Body") { post.body }
47
47
  end
48
48
  }
49
- }
50
-
49
+ },
50
+ "when you create each row with a custom block that returns nil" => proc {
51
+ render_arbre_component(assigns) {
52
+ attributes_table_for post do
53
+ row("Id") { text_node post.id; nil }
54
+ row("Title"){ text_node post.title; nil }
55
+ row("Body") { text_node post.body; nil }
56
+ end
57
+ }
58
+ },
51
59
  }.each do |context_title, table_decleration|
52
60
  context context_title do
53
61
  let(:table) { instance_eval &table_decleration }
@@ -68,15 +76,15 @@ describe ActiveAdmin::Views::AttributesTable do
68
76
 
69
77
  describe "rendering the rows" do
70
78
  [
71
- ["Id" , "2"],
79
+ ["Id" , "1"],
72
80
  ["Title" , "Hello World"],
73
81
  ["Body" , "<span class=\"empty\">Empty</span>"]
74
82
  ].each_with_index do |set, i|
75
- let(:title){ set[0] }
76
- let(:content){ set[1] }
77
- let(:current_row){ table.find_by_tag("tr")[i] }
78
-
79
83
  describe "for #{set[0]}" do
84
+ let(:title){ set[0] }
85
+ let(:content){ set[1] }
86
+ let(:current_row){ table.find_by_tag("tr")[i] }
87
+
80
88
  it "should have the title '#{set[0]}'" do
81
89
  current_row.find_by_tag("th").first.content.should == title
82
90
  end
@@ -111,11 +119,11 @@ describe ActiveAdmin::Views::AttributesTable do
111
119
  end
112
120
 
113
121
  it "should check if an association exists when an attribute has id in it" do
114
- post.author = User.new(:username => "john_doe")
122
+ post.author = User.new :username => 'john_doe', :first_name => 'John', :last_name => 'Doe'
115
123
  table = render_arbre_component(assigns) {
116
124
  attributes_table_for post, :author_id
117
125
  }
118
- table.find_by_tag("td").first.content.should == "john_doe"
126
+ table.find_by_tag('td').first.content.should == 'John Doe'
119
127
  end
120
128
 
121
129
  end