activeadmin 0.4.4 → 0.5.0.pre

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 (310) hide show
  1. data/.gitignore +3 -0
  2. data/.travis.yml +5 -0
  3. data/CHANGELOG.md +50 -0
  4. data/CONTRIBUTING.md +2 -4
  5. data/Gemfile +10 -4
  6. data/Guardfile +0 -1
  7. data/LICENSE +1 -1
  8. data/README.rdoc +19 -8
  9. data/Rakefile +10 -1
  10. data/activeadmin.gemspec +2 -1
  11. data/app/assets/javascripts/active_admin/application.js +3 -9
  12. data/app/assets/javascripts/active_admin/base.js +1 -0
  13. data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +64 -0
  14. data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +107 -0
  15. data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +100 -0
  16. data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +27 -0
  17. data/app/assets/javascripts/active_admin/lib/namespace.js.coffee +3 -0
  18. data/app/assets/javascripts/active_admin/pages/application.js.coffee +13 -0
  19. data/app/assets/javascripts/active_admin/pages/batch_actions.js.coffee +26 -0
  20. data/app/assets/stylesheets/active_admin/_base.css.scss +32 -26
  21. data/app/assets/stylesheets/active_admin/_forms.css.scss +12 -5
  22. data/app/assets/stylesheets/active_admin/_header.css.scss +1 -2
  23. data/app/assets/stylesheets/active_admin/_typography.css.scss +1 -1
  24. data/app/assets/stylesheets/active_admin/components/_batch_actions.css.scss +11 -0
  25. data/app/assets/stylesheets/active_admin/components/_buttons.scss +1 -2
  26. data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +151 -0
  27. data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +3 -3
  28. data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +123 -0
  29. data/app/assets/stylesheets/active_admin/components/_status_tags.scss +1 -1
  30. data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +20 -27
  31. data/app/assets/stylesheets/active_admin/components/_tables.css.scss +1 -0
  32. data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +38 -36
  33. data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +5 -5
  34. data/app/assets/stylesheets/active_admin/mixins/_icons.css.scss +7 -3
  35. data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +19 -17
  36. data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +2 -2
  37. data/app/assets/stylesheets/active_admin/print.css.scss +290 -0
  38. data/app/views/active_admin/dashboard/index.html.arb +1 -1
  39. data/app/views/active_admin/devise/passwords/edit.html.erb +17 -14
  40. data/app/views/active_admin/devise/passwords/new.html.erb +4 -4
  41. data/app/views/active_admin/devise/sessions/new.html.erb +6 -6
  42. data/app/views/active_admin/devise/shared/_links.erb +6 -6
  43. data/app/views/active_admin/page/index.html.arb +1 -1
  44. data/app/views/active_admin/resource/edit.html.arb +1 -1
  45. data/app/views/active_admin/resource/index.csv.erb +1 -1
  46. data/app/views/active_admin/resource/index.html.arb +1 -1
  47. data/app/views/active_admin/resource/new.html.arb +1 -1
  48. data/app/views/active_admin/resource/show.html.arb +1 -1
  49. data/app/views/layouts/active_admin.html.arb +1 -1
  50. data/app/views/layouts/active_admin_logged_out.html.erb +2 -2
  51. data/cucumber.yml +1 -1
  52. data/docs/0-installation.md +10 -1
  53. data/docs/{9-custom-pages.md → 10-custom-pages.md} +0 -0
  54. data/docs/2-resource-customization.md +19 -1
  55. data/docs/3-index-pages.md +31 -0
  56. data/docs/4-csv-format.md +9 -0
  57. data/docs/6-show-screens.md +1 -1
  58. data/docs/9-batch-actions.md +161 -0
  59. data/features/dashboard.feature +31 -8
  60. data/features/development_reloading.feature +1 -1
  61. data/features/edit_page.feature +3 -3
  62. data/features/i18n.feature +35 -0
  63. data/features/index/batch_actions.feature +98 -0
  64. data/features/index/filters.feature +26 -0
  65. data/features/index/format_as_csv.feature +35 -0
  66. data/features/index/index_as_table.feature +30 -2
  67. data/features/index/index_blank_slate.feature +8 -3
  68. data/features/index/index_scopes.feature +130 -24
  69. data/features/index/page_title.feature +12 -0
  70. data/features/new_page.feature +3 -3
  71. data/features/registering_pages.feature +61 -0
  72. data/features/root_to.feature +17 -0
  73. data/features/show/default_content.feature +1 -1
  74. data/features/show/page_title.feature +14 -0
  75. data/features/sidebar_sections.feature +26 -0
  76. data/features/site_title.feature +1 -1
  77. data/features/specifying_actions.feature +7 -6
  78. data/features/step_definitions/action_link_steps.rb +1 -1
  79. data/features/step_definitions/additional_web_steps.rb +7 -1
  80. data/features/step_definitions/batch_action_steps.rb +94 -0
  81. data/features/step_definitions/configuration_steps.rb +30 -8
  82. data/features/step_definitions/factory_steps.rb +12 -0
  83. data/features/step_definitions/format_steps.rb +6 -2
  84. data/features/step_definitions/i18n_steps.rb +3 -0
  85. data/features/step_definitions/table_steps.rb +114 -0
  86. data/features/step_definitions/user_steps.rb +30 -4
  87. data/features/support/env.rb +54 -15
  88. data/features/support/paths.rb +2 -0
  89. data/features/users/logging_in.feature +1 -1
  90. data/features/users/logging_out.feature +2 -1
  91. data/features/users/resetting_password.feature +34 -0
  92. data/lib/active_admin.rb +46 -7
  93. data/lib/active_admin/application.rb +30 -15
  94. data/lib/active_admin/base_controller/menu.rb +3 -3
  95. data/lib/active_admin/batch_actions.rb +17 -0
  96. data/lib/active_admin/batch_actions/controller.rb +25 -0
  97. data/lib/active_admin/batch_actions/resource_extension.rb +126 -0
  98. data/lib/active_admin/batch_actions/views/batch_action_form.rb +35 -0
  99. data/lib/active_admin/batch_actions/views/batch_action_popover.rb +28 -0
  100. data/lib/active_admin/batch_actions/views/batch_action_selector.rb +63 -0
  101. data/lib/active_admin/batch_actions/views/selection_cells.rb +37 -0
  102. data/lib/active_admin/comments.rb +5 -2
  103. data/lib/active_admin/comments/comment.rb +4 -3
  104. data/lib/active_admin/comments/views/active_admin_comments.rb +5 -5
  105. data/lib/active_admin/component.rb +1 -18
  106. data/lib/active_admin/csv_builder.rb +8 -3
  107. data/lib/active_admin/dashboards.rb +21 -4
  108. data/lib/active_admin/dashboards/dashboard_controller.rb +1 -5
  109. data/lib/active_admin/dependency_checker.rb +1 -1
  110. data/lib/active_admin/dsl.rb +61 -4
  111. data/lib/active_admin/engine.rb +1 -1
  112. data/lib/active_admin/filters.rb +8 -0
  113. data/lib/active_admin/filters/dsl.rb +12 -0
  114. data/lib/active_admin/filters/forms.rb +93 -0
  115. data/lib/active_admin/filters/resource_extension.rb +92 -0
  116. data/lib/active_admin/form_builder.rb +88 -33
  117. data/lib/active_admin/helpers/collection.rb +23 -0
  118. data/lib/active_admin/helpers/optional_display.rb +1 -1
  119. data/lib/active_admin/inputs/filter_select_input.rb +1 -1
  120. data/lib/active_admin/locales/bg.yml +37 -1
  121. data/lib/active_admin/locales/ca.yml +36 -0
  122. data/lib/active_admin/locales/cs.yml +36 -0
  123. data/lib/active_admin/locales/da.yml +36 -0
  124. data/lib/active_admin/locales/de.yml +42 -0
  125. data/lib/active_admin/locales/en.yml +27 -2
  126. data/lib/active_admin/locales/es.yml +45 -4
  127. data/lib/active_admin/locales/fr.yml +22 -0
  128. data/lib/active_admin/locales/{he_il.yml → he.yml} +37 -2
  129. data/lib/active_admin/locales/hr.yml +49 -5
  130. data/lib/active_admin/locales/hu.yml +21 -0
  131. data/lib/active_admin/locales/it.yml +36 -1
  132. data/lib/active_admin/locales/ja.yml +36 -0
  133. data/lib/active_admin/locales/ko.yml +36 -1
  134. data/lib/active_admin/locales/lv.yml +28 -2
  135. data/lib/active_admin/locales/nl.yml +42 -1
  136. data/lib/active_admin/locales/no-NB.yml +15 -0
  137. data/lib/active_admin/locales/pl.yml +45 -1
  138. data/lib/active_admin/locales/pt-BR.yml +36 -1
  139. data/lib/active_admin/locales/ro.yml +67 -0
  140. data/lib/active_admin/locales/ru.yml +43 -3
  141. data/lib/active_admin/locales/sv-SE.yml +41 -1
  142. data/lib/active_admin/locales/tr.yml +80 -0
  143. data/lib/active_admin/locales/vi.yml +80 -0
  144. data/lib/active_admin/locales/{zh_cn.yml → zh-CN.yml} +42 -2
  145. data/lib/active_admin/locales/zh-TW.yml +36 -1
  146. data/lib/active_admin/menu.rb +55 -30
  147. data/lib/active_admin/menu_builder.rb +65 -0
  148. data/lib/active_admin/menu_item.rb +55 -14
  149. data/lib/active_admin/namespace.rb +25 -55
  150. data/lib/active_admin/page.rb +15 -10
  151. data/lib/active_admin/resource.rb +9 -0
  152. data/lib/active_admin/resource/action_items.rb +4 -4
  153. data/lib/active_admin/resource/controllers.rb +1 -1
  154. data/lib/active_admin/resource/menu.rb +19 -21
  155. data/lib/active_admin/resource/naming.rb +55 -45
  156. data/lib/active_admin/resource/sidebars.rb +0 -13
  157. data/lib/active_admin/resource_collection.rb +10 -10
  158. data/lib/active_admin/resource_controller.rb +5 -5
  159. data/lib/active_admin/resource_controller/actions.rb +2 -0
  160. data/lib/active_admin/resource_controller/collection.rb +13 -4
  161. data/lib/active_admin/resource_dsl.rb +12 -6
  162. data/lib/active_admin/router.rb +27 -8
  163. data/lib/active_admin/scope.rb +1 -0
  164. data/lib/active_admin/sidebar_section.rb +2 -6
  165. data/lib/active_admin/version.rb +1 -1
  166. data/lib/active_admin/view_factory.rb +18 -13
  167. data/lib/active_admin/view_helpers.rb +0 -2
  168. data/lib/active_admin/view_helpers/auto_link_helper.rb +2 -1
  169. data/lib/active_admin/view_helpers/breadcrumb_helper.rb +24 -25
  170. data/lib/active_admin/view_helpers/display_helper.rb +1 -1
  171. data/lib/active_admin/view_helpers/fields_for.rb +44 -0
  172. data/lib/active_admin/view_helpers/form_helper.rb +6 -0
  173. data/lib/active_admin/view_helpers/view_factory_helper.rb +1 -1
  174. data/lib/active_admin/views/components/action_list_popover.rb +29 -0
  175. data/lib/active_admin/views/components/attributes_table.rb +6 -2
  176. data/lib/active_admin/views/components/dropdown_menu.rb +73 -0
  177. data/lib/active_admin/views/components/paginated_collection.rb +13 -14
  178. data/lib/active_admin/views/components/popover.rb +27 -0
  179. data/lib/active_admin/views/components/scopes.rb +8 -13
  180. data/lib/active_admin/views/components/sidebar_section.rb +1 -1
  181. data/lib/active_admin/views/components/site_title.rb +55 -0
  182. data/lib/active_admin/views/components/status_tag.rb +4 -4
  183. data/lib/active_admin/views/components/table_for.rb +18 -18
  184. data/lib/active_admin/views/dashboard_section_renderer.rb +1 -1
  185. data/lib/active_admin/views/footer.rb +18 -0
  186. data/lib/active_admin/views/header.rb +31 -0
  187. data/lib/active_admin/views/index_as_block.rb +3 -0
  188. data/lib/active_admin/views/index_as_blog.rb +4 -0
  189. data/lib/active_admin/views/index_as_grid.rb +2 -0
  190. data/lib/active_admin/views/index_as_table.rb +19 -6
  191. data/lib/active_admin/views/pages/base.rb +14 -48
  192. data/lib/active_admin/views/pages/form.rb +3 -3
  193. data/lib/active_admin/views/pages/index.rb +56 -24
  194. data/lib/active_admin/views/pages/layout.rb +2 -2
  195. data/lib/active_admin/views/pages/page.rb +10 -4
  196. data/lib/active_admin/views/pages/show.rb +11 -8
  197. data/lib/active_admin/views/tabbed_navigation.rb +3 -3
  198. data/lib/active_admin/views/title_bar.rb +50 -0
  199. data/lib/active_admin/views/utility_nav.rb +41 -0
  200. data/lib/generators/active_admin/assets/assets_generator.rb +1 -1
  201. data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +1 -0
  202. data/lib/generators/active_admin/assets/templates/3.1/active_admin.css.scss +26 -3
  203. data/lib/generators/active_admin/devise/devise_generator.rb +2 -2
  204. data/lib/generators/active_admin/install/install_generator.rb +10 -10
  205. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +21 -1
  206. data/lib/generators/active_admin/install/templates/admin_user.rb.erb +20 -0
  207. data/lib/generators/active_admin/install/templates/dashboard.rb +33 -0
  208. data/lib/generators/active_admin/resource/templates/admin.rb +1 -1
  209. data/spec/integration/memory_spec.rb +1 -11
  210. data/spec/javascripts/coffeescripts/jquery.aa.checkbox-toggler-spec.js.coffee +50 -0
  211. data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +82 -0
  212. data/spec/javascripts/coffeescripts/jquery.aa.table-checkbox-toggler-spec.js.coffee +34 -0
  213. data/spec/javascripts/compiled/jquery.aa.checkbox-toggler-spec.js +60 -0
  214. data/spec/javascripts/compiled/jquery.aa.popover-spec.js +106 -0
  215. data/spec/javascripts/compiled/jquery.aa.table-checkbox-toggler-spec.js +37 -0
  216. data/spec/javascripts/fixtures/checkboxes.html +9 -0
  217. data/spec/javascripts/fixtures/table_checkboxes.html +17 -0
  218. data/spec/javascripts/helpers/SpecHelper.js +3 -0
  219. data/spec/javascripts/helpers/vendor/jasmine-fixture-0.0.5.js +108 -0
  220. data/spec/javascripts/helpers/vendor/jasmine-jquery.js +288 -0
  221. data/spec/javascripts/helpers/vendor/sinon-1.2.0.js +2915 -0
  222. data/spec/javascripts/support/jasmine.yml +74 -0
  223. data/spec/javascripts/support/jasmine_config.rb +23 -0
  224. data/spec/javascripts/support/jasmine_runner.rb +32 -0
  225. data/spec/javascripts/support/jquery-ui-1.8.16.custom.min.js +34 -0
  226. data/spec/javascripts/support/jquery.min.js +4 -0
  227. data/spec/spec_helper.rb +13 -13
  228. data/spec/spec_helper_without_rails.rb +2 -3
  229. data/spec/support/detect_rails_version.rb +16 -10
  230. data/spec/support/rails_template.rb +13 -1
  231. data/spec/support/templates/admin/stores.rb +1 -0
  232. data/spec/support/templates/en.yml +6 -0
  233. data/spec/unit/action_builder_spec.rb +38 -0
  234. data/spec/unit/application_spec.rb +12 -16
  235. data/spec/unit/base_controller_shared_examples.rb +3 -6
  236. data/spec/unit/batch_actions/resource_spec.rb +91 -0
  237. data/spec/unit/batch_actions/settings_spec.rb +61 -0
  238. data/spec/unit/breadcrumbs_spec.rb +33 -0
  239. data/spec/unit/comments_spec.rb +6 -0
  240. data/spec/unit/config_shared_examples.rb +17 -64
  241. data/spec/unit/csv_builder_spec.rb +12 -2
  242. data/spec/unit/dashboard_controller_spec.rb +11 -5
  243. data/spec/unit/dsl_include_spec.rb +20 -0
  244. data/spec/unit/{filter_form_builder_spec.rb → filters/filter_form_builder_spec.rb} +10 -7
  245. data/spec/unit/filters/resource_spec.rb +60 -0
  246. data/spec/unit/form_builder_spec.rb +180 -28
  247. data/spec/unit/helpers/collection_spec.rb +65 -0
  248. data/spec/unit/menu_item_spec.rb +48 -53
  249. data/spec/unit/menu_spec.rb +46 -32
  250. data/spec/unit/namespace/register_page_spec.rb +0 -6
  251. data/spec/unit/namespace/register_resource_spec.rb +1 -8
  252. data/spec/unit/namespace_spec.rb +8 -2
  253. data/spec/unit/page_spec.rb +20 -8
  254. data/spec/unit/resource/naming_spec.rb +27 -26
  255. data/spec/unit/resource/sidebars_spec.rb +0 -7
  256. data/spec/unit/resource_collection_spec.rb +11 -11
  257. data/spec/unit/resource_controller/collection_spec.rb +23 -1
  258. data/spec/unit/resource_controller/sidebars_spec.rb +46 -0
  259. data/spec/unit/resource_controller_spec.rb +43 -0
  260. data/spec/unit/resource_registration_spec.rb +2 -13
  261. data/spec/unit/resource_spec.rb +0 -42
  262. data/spec/unit/routing_spec.rb +60 -14
  263. data/spec/unit/scope_spec.rb +7 -0
  264. data/spec/unit/view_factory_spec.rb +9 -6
  265. data/spec/unit/view_helpers/fields_for_spec.rb +41 -0
  266. data/spec/unit/view_helpers/form_helper_spec.rb +18 -0
  267. data/spec/unit/views/components/action_list_popover_spec.rb +30 -0
  268. data/spec/unit/views/components/attributes_table_spec.rb +32 -20
  269. data/spec/unit/views/components/batch_action_popover_spec.rb +33 -0
  270. data/spec/unit/views/components/blank_slate_spec.rb +5 -3
  271. data/spec/unit/views/components/columns_spec.rb +32 -22
  272. data/spec/unit/views/components/paginated_collection_spec.rb +54 -12
  273. data/spec/unit/views/components/panel_spec.rb +11 -6
  274. data/spec/unit/views/components/popover_spec.rb +33 -0
  275. data/spec/unit/views/components/sidebar_section_spec.rb +6 -6
  276. data/spec/unit/views/components/site_title_spec.rb +78 -0
  277. data/spec/unit/views/components/status_tag_spec.rb +17 -10
  278. data/spec/unit/views/components/table_for_spec.rb +37 -17
  279. data/spec/unit/views/pages/layout_spec.rb +51 -10
  280. data/spec/unit/views/tabbed_navigation_spec.rb +44 -23
  281. data/tasks/js.rake +32 -0
  282. data/tasks/test.rake +1 -1
  283. metadata +233 -200
  284. data/lib/active_admin/arbre.rb +0 -22
  285. data/lib/active_admin/arbre/builder.rb +0 -125
  286. data/lib/active_admin/arbre/context.rb +0 -45
  287. data/lib/active_admin/arbre/html/attributes.rb +0 -20
  288. data/lib/active_admin/arbre/html/class_list.rb +0 -24
  289. data/lib/active_admin/arbre/html/collection.rb +0 -27
  290. data/lib/active_admin/arbre/html/document.rb +0 -42
  291. data/lib/active_admin/arbre/html/element.rb +0 -161
  292. data/lib/active_admin/arbre/html/html5_elements.rb +0 -47
  293. data/lib/active_admin/arbre/html/tag.rb +0 -145
  294. data/lib/active_admin/arbre/html/text_node.rb +0 -35
  295. data/lib/active_admin/filter_form_builder.rb +0 -53
  296. data/lib/active_admin/renderer.rb +0 -87
  297. data/lib/active_admin/resource_controller/filters.rb +0 -58
  298. data/lib/active_admin/stylesheets/active_admin/mixins/_utilities.scss +0 -0
  299. data/lib/active_admin/view_helpers/filter_form_helper.rb +0 -36
  300. data/lib/active_admin/view_helpers/renderer_helper.rb +0 -29
  301. data/lib/active_admin/views/header_renderer.rb +0 -82
  302. data/lib/generators/active_admin/assets/templates/dashboards.rb +0 -36
  303. data/lib/generators/active_admin/install/templates/dashboards.rb +0 -44
  304. data/spec/unit/arbre/context_spec.rb +0 -35
  305. data/spec/unit/arbre/html/element_finder_methods_spec.rb +0 -110
  306. data/spec/unit/arbre/html/element_spec.rb +0 -236
  307. data/spec/unit/arbre/html/tag_attributes_spec.rb +0 -61
  308. data/spec/unit/arbre/html/tag_spec.rb +0 -63
  309. data/spec/unit/arbre/html_spec.rb +0 -228
  310. data/spec/unit/renderer_spec.rb +0 -126
@@ -1,17 +1,35 @@
1
1
  Feature: Dashboard
2
2
 
3
- Background:
3
+ @dashboard
4
+ Scenario: With default configuration
5
+ Given a configuration of:
6
+ """
7
+ ActiveAdmin.register_page "Dashboard" do
8
+ content do
9
+ para "Hello world from the dashboard page"
10
+ end
11
+ end
12
+ """
4
13
  Given I am logged in
14
+ When I go to the dashboard
15
+ Then I should see the Active Admin layout
16
+ And I should not see the default welcome message
17
+ And I should see "Hello world from the dashboard page"
5
18
 
6
-
7
- Scenario: With no configuration
19
+ @dashboard
20
+ Scenario: DEPRECATED - With default configuration
8
21
  Given a configuration of:
9
22
  """
23
+ ActiveAdmin::Dashboards.build do
24
+ end
10
25
  """
26
+ Given I am logged in
11
27
  When I go to the dashboard
12
- Then I should see the default welcome message
28
+ Then I should see the Active Admin layout
29
+ And I should see the default welcome message
13
30
 
14
- Scenario: Displaying a dashboard widget
31
+ @dashboard
32
+ Scenario: DEPRECATED - Displaying a dashboard widget
15
33
  Given a configuration of:
16
34
  """
17
35
  ActiveAdmin::Dashboards.build do
@@ -20,12 +38,15 @@ Feature: Dashboard
20
38
  end
21
39
  end
22
40
  """
41
+ Given I am logged in
23
42
  When I go to the dashboard
24
- Then I should not see the default welcome message
43
+ Then I should see the Active Admin layout
44
+ And I should not see the default welcome message
25
45
  And I should see a dashboard widget "Hello World"
26
46
  And I should see "Hello world from the content"
27
47
 
28
- Scenario: Displaying a dashboard widget using the ':if' option
48
+ @dashboard
49
+ Scenario: DEPRECATED - Displaying a dashboard widget using the ':if' option
29
50
  Given a configuration of:
30
51
  """
31
52
  ActiveAdmin::Dashboards.build do
@@ -38,7 +59,9 @@ Feature: Dashboard
38
59
  end
39
60
  end
40
61
  """
62
+ Given I am logged in
41
63
  When I go to the dashboard
42
- Then I should not see the default welcome message
64
+ Then I should see the Active Admin layout
65
+ And I should not see the default welcome message
43
66
  And I should see a dashboard widget "Hello World"
44
67
  And I should not see a dashboard widget "Hidden by If"
@@ -10,7 +10,7 @@ Feature: Development Reloading
10
10
  """
11
11
  ActiveAdmin.register Post
12
12
  """
13
- And I am logged in
13
+ And I am logged in with capybara
14
14
  And I create a new post with the title ""
15
15
  Then I should see a successful create flash
16
16
  Given I add "validates_presence_of :title" to the "post" model
@@ -37,7 +37,7 @@ Feature: Edit Page
37
37
  f.inputs "Publishing" do
38
38
  f.input :published_at
39
39
  end
40
- f.buttons
40
+ f.actions
41
41
  end
42
42
  end
43
43
  """
@@ -64,7 +64,7 @@ Feature: Edit Page
64
64
  f.inputs "Publishing" do
65
65
  f.input :published_at
66
66
  end
67
- f.buttons
67
+ f.actions
68
68
  end
69
69
  end
70
70
  """
@@ -87,7 +87,7 @@ Feature: Edit Page
87
87
  <% url = @post.new_record? ? admin_posts_path : admin_post_path(@post) %>
88
88
  <%= active_admin_form_for @post, :url => url do |f|
89
89
  f.inputs :title, :body
90
- f.buttons
90
+ f.actions
91
91
  end %>
92
92
  """
93
93
  Given a configuration of:
@@ -0,0 +1,35 @@
1
+ Feature: Internationalization
2
+
3
+ ActiveAdmin should use the translations provided by the host app.
4
+
5
+ Scenario: Store's model name was translated to "Bookstore"
6
+ Given I am logged in
7
+ And a store named "Hello words" exists
8
+ When I go to the dashboard
9
+ Then I should see "Bookstores"
10
+ When I follow "Bookstores"
11
+ Then I should see "Hello words"
12
+ When I follow "View"
13
+ Then I should see "Bookstore Details"
14
+ And I should see "Hello words"
15
+ And I should see a link to "Delete Bookstore"
16
+ When I follow "Edit Bookstore"
17
+ Then I should see "Edit Bookstore"
18
+ When I press "Update Bookstore"
19
+ Then I should see a flash with "Bookstore was successfully updated."
20
+
21
+ Scenario: Switching language at runtime
22
+ Given I am logged in
23
+ And a configuration of:
24
+ """
25
+ ActiveAdmin.register Store
26
+ """
27
+ When I set my locale to "fr"
28
+ And I go to the dashboard
29
+ Then I should see "Store"
30
+ Then I should see "Déconnexion"
31
+
32
+ When I set my locale to "en"
33
+ And I go to the dashboard
34
+ Then I should see "Bookstore"
35
+ Then I should see "Logout"
@@ -0,0 +1,98 @@
1
+ Feature: Batch Actions
2
+
3
+ Scenario: Use default (destroy) batch action
4
+ Given 10 posts exist
5
+ And an index configuration of:
6
+ """
7
+ ActiveAdmin.register Post
8
+ """
9
+ Then I should see the batch action button
10
+ And I should see that the batch action button is disabled
11
+ And I should see the batch action popover exists
12
+ And I should see 10 posts in the table
13
+
14
+ When I check the 1st record
15
+ When I check the 2nd record
16
+ And I follow "Batch Actions"
17
+ Then I should see the batch action :destroy "Delete Selected"
18
+
19
+
20
+ Given I submit the batch action form with "destroy"
21
+ Then I should see a flash with "Successfully destroyed 1 post"
22
+ And I should see 9 posts in the table
23
+
24
+ Scenario: Using a custom batch action
25
+ Given 10 posts exist
26
+ And an index configuration of:
27
+ """
28
+ ActiveAdmin.register Post do
29
+ batch_action(:flag) do
30
+ redirect_to collection_path, :notice => "Successfully flagged 10 posts"
31
+ end
32
+ end
33
+ """
34
+ When I check the 1st record
35
+ Given I submit the batch action form with "flag"
36
+ Then I should see a flash with "Successfully flagged 10 posts"
37
+
38
+ Scenario: Disabling batch actions for a resource
39
+ Given 10 posts exist
40
+ And an index configuration of:
41
+ """
42
+ ActiveAdmin.register Post do
43
+ config.batch_actions = false
44
+ end
45
+ """
46
+ Then I should not see the batch actions selector
47
+ And I should not see checkboxes in the table
48
+
49
+ Scenario: Disabling the default destroy batch action
50
+ Given 10 posts exist
51
+ And an index configuration of:
52
+ """
53
+ ActiveAdmin.register Post do
54
+ batch_action :destroy, false
55
+ batch_action(:flag) {}
56
+ end
57
+ """
58
+ Then I should see the batch action "Flag Selected"
59
+ And I should not see the batch action "Delete Selected"
60
+
61
+ Scenario: Optional display of batch actions
62
+ Given 10 posts exist
63
+ And an index configuration of:
64
+ """
65
+ ActiveAdmin.register Post do
66
+ batch_action(:flag, :if => proc { true }) {}
67
+ batch_action(:unflag, :if => proc { false }) {}
68
+ end
69
+ """
70
+ Then I should see the batch action "Flag Selected"
71
+ And I should not see the batch action "Unflag Selected"
72
+
73
+ Scenario: Sort order priority
74
+ Given 10 posts exist
75
+ And an index configuration of:
76
+ """
77
+ ActiveAdmin.register Post do
78
+ batch_action(:test, :priority => 3) {}
79
+ batch_action(:flag, :priority => 2) {}
80
+ batch_action(:unflag, :priority => 1) {}
81
+ end
82
+ """
83
+ Then the 4th batch action should be "Delete Selected"
84
+ And the 3rd batch action should be "Test Selected"
85
+ And the 2nd batch action should be "Flag Selected"
86
+ And the 1st batch action should be "Unflag Selected"
87
+
88
+ Scenario: Complex naming
89
+ Given 10 posts exist
90
+ And an index configuration of:
91
+ """
92
+ ActiveAdmin.register Post do
93
+ batch_action("Very Complex and Time Consuming") {}
94
+ batch_action(:passing_a_symbol) {}
95
+ end
96
+ """
97
+ Then I should see the batch action :very_complex_and_time_consuming "Very Complex and Time Consuming Selected"
98
+ And I should see the batch action :passing_a_symbol "Passing A Symbol Selected"
@@ -38,6 +38,22 @@ Feature: Index Filtering
38
38
  And I should not see pagination
39
39
  And I should see "No Posts found"
40
40
 
41
+ Scenario: Filtering posts while not on the first page
42
+ Given 9 posts exist
43
+ And an index configuration of:
44
+ """
45
+ ActiveAdmin.register Post do
46
+ config.per_page = 5
47
+ end
48
+ """
49
+ When I follow "2"
50
+ Then I should see "Displaying Posts 6 - 9 of 9 in total"
51
+
52
+ When I fill in "Search Title" with "Hello World 2"
53
+ And I press "Filter"
54
+ And I should see 1 posts in the table
55
+ And I should see "Hello World 2" within ".index_table"
56
+
41
57
  Scenario: Checkboxes - Filtering posts written by anyone
42
58
  Given 1 post exists
43
59
  And a post with the title "Hello World" written by "Jane Doe" exists
@@ -66,3 +82,13 @@ Feature: Index Filtering
66
82
  Then I should see 1 posts in the table
67
83
  And I should see "Hello World" within ".index_table"
68
84
  And the "jane_doe" checkbox should be checked
85
+
86
+ Scenario: Disabling filters
87
+ Given an index configuration of:
88
+ """
89
+ ActiveAdmin.register Post do
90
+ config.filters = false
91
+ end
92
+ """
93
+ Then I should not see a sidebar titled "Filters"
94
+
@@ -44,3 +44,38 @@ Feature: Format as CSV
44
44
  | Title | Last update | Copyright |
45
45
  | Hello, World | (.*) | Greg Bell |
46
46
 
47
+ Scenario: With CSV format customization
48
+ Given a configuration of:
49
+ """
50
+ ActiveAdmin.register Post do
51
+ csv :separator => ';' do
52
+ column :title
53
+ column :body
54
+ end
55
+ end
56
+ """
57
+ And a post with the title "Hello, World" exists
58
+ When I am on the index page for posts
59
+ And I follow "CSV"
60
+ And I should download a CSV file with ";" separator for "posts" containing:
61
+ | Title | Body |
62
+ | Hello, World | (.*) |
63
+
64
+ Scenario: With default CSV separator option
65
+ Given a configuration of:
66
+ """
67
+ ActiveAdmin.application.csv_column_separator = ';'
68
+ ActiveAdmin.register Post do
69
+ csv do
70
+ column :title
71
+ column :body
72
+ end
73
+ end
74
+ """
75
+ And a post with the title "Hello, World" exists
76
+ When I am on the index page for posts
77
+ And I follow "CSV"
78
+ And I should download a CSV file with ";" separator for "posts" containing:
79
+ | Title | Body |
80
+ | Hello, World | (.*) |
81
+
@@ -2,14 +2,14 @@ Feature: Index as Table
2
2
 
3
3
  Viewing resources as a table on the index page
4
4
 
5
- Scenario: Viewing the default table with no resources
5
+ Scenario: Viewing the default table with one resources
6
6
  Given an index configuration of:
7
7
  """
8
8
  ActiveAdmin.register Post
9
9
  """
10
10
  And 1 post exists
11
11
  When I am on the index page for posts
12
- Then I should see a sortable table header with "ID"
12
+ Then I should see a sortable table header with "Id"
13
13
  And I should see a sortable table header with "Title"
14
14
 
15
15
  Scenario: Viewing the default table with a resource
@@ -92,4 +92,32 @@ Feature: Index as Table
92
92
  And I should see a member link to "Edit"
93
93
  And I should not see a member link to "Delete"
94
94
 
95
+ Scenario: Associations are not sortable
96
+ Given 1 post exists
97
+ And an index configuration of:
98
+ """
99
+ ActiveAdmin.register Post do
100
+ index do
101
+ column :category
102
+ end
103
+ end
104
+ """
105
+ Then I should not see a sortable table header with "Category"
95
106
 
107
+ Scenario: Sorting
108
+ Given a post with the title "Hello World" and body "From the body" exists
109
+ And a post with the title "Bye bye world" and body "Move your..." exists
110
+ And an index configuration of:
111
+ """
112
+ ActiveAdmin.register Post
113
+ """
114
+ When I am on the index page for posts
115
+ Then I should see the "posts" table:
116
+ | [ ] | Id | Title | Body | Published At | Created At | Updated At | |
117
+ | [ ] | 2 | Bye bye world | Move your... | | /.*/ | /.*/ | ViewEditDelete |
118
+ | [ ] | 1 | Hello World | From the body | | /.*/ | /.*/ | ViewEditDelete |
119
+ When I follow "Id"
120
+ Then I should see the "posts" table:
121
+ | [ ] | Id | Title | Body | Published At | Created At | Updated At | |
122
+ | [ ] | 1 | Hello World | From the body | | /.*/ | /.*/ | ViewEditDelete |
123
+ | [ ] | 2 | Bye bye world | Move your... | | /.*/ | /.*/ | ViewEditDelete |
@@ -5,7 +5,12 @@ Feature: Index Blank Slate
5
5
  Scenario: Viewing the default table with no resources
6
6
  Given an index configuration of:
7
7
  """
8
- ActiveAdmin.register Post
8
+ ActiveAdmin.register Post do
9
+ batch_action :favourite do
10
+ # nothing
11
+ end
12
+ scope :all, :default => true
13
+ end
9
14
  """
10
15
  Then I should not see a sortable table header
11
16
  And I should see "There are no Posts yet. Create one"
@@ -13,7 +18,7 @@ Feature: Index Blank Slate
13
18
  And I should not see pagination
14
19
  When I follow "Create one"
15
20
  Then I should be on the new post page
16
-
21
+
17
22
  Scenario: Viewing the default table with no resources and no 'new' action
18
23
  Given an index configuration of:
19
24
  """
@@ -53,4 +58,4 @@ Feature: Index Blank Slate
53
58
  index :as => :blog
54
59
  end
55
60
  """
56
- And I should see "There are no Posts yet. Create one"
61
+ And I should see "There are no Posts yet. Create one"
@@ -3,7 +3,7 @@ Feature: Index Scoping
3
3
  Viewing resources and scoping them
4
4
 
5
5
  Scenario: Viewing resources with one scope and no default
6
- Given 10 posts exist
6
+ Given 3 posts exist
7
7
  And an index configuration of:
8
8
  """
9
9
  ActiveAdmin.register Post do
@@ -11,11 +11,11 @@ Feature: Index Scoping
11
11
  end
12
12
  """
13
13
  Then I should see the scope "All" not selected
14
- And I should see the scope "All" with the count 10
15
- And I should see 10 posts in the table
14
+ And I should see the scope "All" with the count 3
15
+ And I should see 3 posts in the table
16
16
 
17
17
  Scenario: Viewing resources with one scope as the default
18
- Given 10 posts exist
18
+ Given 3 posts exist
19
19
  And an index configuration of:
20
20
  """
21
21
  ActiveAdmin.register Post do
@@ -23,11 +23,11 @@ Feature: Index Scoping
23
23
  end
24
24
  """
25
25
  Then I should see the scope "All" selected
26
- And I should see the scope "All" with the count 10
27
- And I should see 10 posts in the table
26
+ And I should see the scope "All" with the count 3
27
+ And I should see 3 posts in the table
28
28
 
29
29
  Scenario: Viewing resources with one scope and no results
30
- Given 10 posts exist
30
+ Given 3 posts exist
31
31
  And an index configuration of:
32
32
  """
33
33
  ActiveAdmin.register Post do
@@ -36,7 +36,7 @@ Feature: Index Scoping
36
36
  end
37
37
  """
38
38
 
39
- When I fill in "Search Title" with "Hello World 17"
39
+ When I fill in "Search Title" with "Non Existing Post"
40
40
  And I press "Filter"
41
41
  And I should not see the scope "All"
42
42
 
@@ -44,7 +44,7 @@ Feature: Index Scoping
44
44
  Then I should see the scope "All" selected
45
45
 
46
46
  Scenario: Viewing resources with a scope but scope_count turned off
47
- Given 10 posts exist
47
+ Given 3 posts exist
48
48
  And an index configuration of:
49
49
  """
50
50
  ActiveAdmin.register Post do
@@ -54,11 +54,11 @@ Feature: Index Scoping
54
54
  """
55
55
  Then I should see the scope "All" selected
56
56
  And I should see the scope "All" with no count
57
- And I should see 10 posts in the table
57
+ And I should see 3 posts in the table
58
58
 
59
59
  @scope
60
60
  Scenario: Viewing resources with a scope and scope count turned off for a single scope
61
- Given 10 posts exist
61
+ Given 3 posts exist
62
62
  And an index configuration of:
63
63
  """
64
64
  ActiveAdmin.register Post do
@@ -67,11 +67,11 @@ Feature: Index Scoping
67
67
  """
68
68
  Then I should see the scope "All" selected
69
69
  And I should see the scope "All" with no count
70
- And I should see 10 posts in the table
70
+ And I should see 3 posts in the table
71
71
 
72
72
  Scenario: Viewing resources when scoping
73
- Given 6 posts exist
74
- And 4 published posts exist
73
+ Given 2 posts exist
74
+ And 3 published posts exist
75
75
  And an index configuration of:
76
76
  """
77
77
  ActiveAdmin.register Post do
@@ -81,15 +81,49 @@ Feature: Index Scoping
81
81
  end
82
82
  end
83
83
  """
84
- Then I should see the scope "All" with the count 10
85
- And I should see 10 posts in the table
86
- Then I should see the scope "Published" with the count 4
84
+ Then I should see the scope "All" with the count 5
85
+ And I should see 5 posts in the table
86
+ And I should see the scope "Published" with the count 3
87
87
  When I follow "Published"
88
88
  Then I should see the scope "Published" selected
89
- And I should see 4 posts in the table
89
+ And I should see 3 posts in the table
90
+
91
+ Scenario: Viewing resources when scoping and filtering
92
+ Given 2 posts written by "Daft Punk" exist
93
+ Given 1 published posts written by "Daft Punk" exist
94
+
95
+ Given 1 posts written by "Alfred" exist
96
+ Given 2 published posts written by "Alfred" exist
97
+
98
+ And an index configuration of:
99
+ """
100
+ ActiveAdmin.register Post do
101
+ scope :all, :default => true
102
+ scope :published do |posts|
103
+ posts.where("published_at IS NOT NULL")
104
+ end
105
+ end
106
+ """
107
+ Then I should see the scope "All" with the count 6
108
+ And I should see the scope "Published" with the count 3
109
+ And I should see 6 posts in the table
110
+
111
+ When I follow "Published"
112
+ Then I should see the scope "Published" selected
113
+ And I should see the scope "All" with the count 6
114
+ And I should see the scope "Published" with the count 3
115
+ And I should see 3 posts in the table
116
+
117
+ When I select "daft_punk" from "Author"
118
+ And I press "Filter"
119
+
120
+ Then I should see the scope "Published" selected
121
+ And I should see the scope "All" with the count 3
122
+ And I should see the scope "Published" with the count 1
123
+ And I should see 1 posts in the table
90
124
 
91
125
  Scenario: Viewing resources with optional scopes
92
- Given 10 posts exist
126
+ Given 3 posts exist
93
127
  And an index configuration of:
94
128
  """
95
129
  ActiveAdmin.register Post do
@@ -109,10 +143,10 @@ Feature: Index Scoping
109
143
  And I should not see the scope "All"
110
144
  And I should not see the scope "Today"
111
145
  And I should see the scope "Shown"
112
- And I should see the scope "Default" with the count 10
146
+ And I should see the scope "Default" with the count 3
113
147
 
114
- Scenario: Viewing resources with mulitple scopes as blocks
115
- Given 10 posts exist
148
+ Scenario: Viewing resources with multiple scopes as blocks
149
+ Given 3 posts exist
116
150
  And an index configuration of:
117
151
  """
118
152
  ActiveAdmin.register Post do
@@ -126,12 +160,84 @@ Feature: Index Scoping
126
160
  """
127
161
  Then I should see the scope "Today" selected
128
162
  And I should see the scope "Tomorrow" not selected
129
- And I should see the scope "Today" with the count 10
163
+ And I should see the scope "Today" with the count 3
130
164
  And I should see the scope "Tomorrow" with the count 0
131
- And I should see 10 posts in the table
165
+ And I should see 3 posts in the table
132
166
  And I should see a link to "Tomorrow"
133
167
 
134
168
  When I follow "Tomorrow"
135
169
  Then I should see the scope "Tomorrow" selected
136
170
  And I should see the scope "Today" not selected
137
171
  And I should see a link to "Today"
172
+
173
+ Scenario: Viewing resources with scopes when scoping to user
174
+ Given 2 posts written by "Daft Punk" exist
175
+ And a post with the title "Monkey Wrench" written by "Foo Fighters" exists
176
+ And a post with the title "Everlong" written by "Foo Fighters" exists
177
+ And an index configuration of:
178
+ """
179
+ ActiveAdmin.register Post do
180
+ scope_to :current_user
181
+ scope :all, :default => true
182
+
183
+ filter :title
184
+
185
+ controller do
186
+ def current_user
187
+ User.find_by_username('foo_fighters')
188
+ end
189
+ end
190
+ end
191
+ """
192
+ Then I should see the scope "All" selected
193
+ And I should see the scope "All" with the count 2
194
+ When I fill in "Search Title" with "Monkey"
195
+ And I press "Filter"
196
+ Then I should see the scope "All" selected
197
+ And I should see the scope "All" with the count 1
198
+
199
+ Scenario: Viewing resources when scoping and filtering and group bys and stuff
200
+ Given 2 posts written by "Daft Punk" exist
201
+ Given 1 published posts written by "Daft Punk" exist
202
+
203
+ Given 1 posts written by "Alfred" exist
204
+
205
+ And an index configuration of:
206
+ """
207
+ ActiveAdmin.register Post do
208
+ scope :all, :default => true
209
+ scope :published do |posts|
210
+ posts.where("published_at IS NOT NULL")
211
+ end
212
+
213
+ index do
214
+ column :author_id
215
+ column :count
216
+ end
217
+
218
+ config.sort_order = "author_id_asc"
219
+
220
+ controller do
221
+ def scoped_collection
222
+ Post.select("author_id, count(*) as count").group("author_id")
223
+ end
224
+ end
225
+ end
226
+ """
227
+ Then I should see the scope "All" with the count 2
228
+ And I should see the scope "Published" with the count 1
229
+ And I should see 2 posts in the table
230
+
231
+ When I follow "Published"
232
+ Then I should see the scope "Published" selected
233
+ And I should see the scope "All" with the count 2
234
+ And I should see the scope "Published" with the count 1
235
+ And I should see 1 posts in the table
236
+
237
+ When I select "daft_punk" from "Author"
238
+ And I press "Filter"
239
+
240
+ Then I should see the scope "Published" selected
241
+ And I should see the scope "All" with the count 1
242
+ And I should see the scope "Published" with the count 1
243
+ And I should see 1 posts in the table