activeadmin 0.2.2 → 0.3.0

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 (277) hide show
  1. data/.gitignore +34 -0
  2. data/.travis.yml +4 -0
  3. data/.yardopts +8 -0
  4. data/CHANGELOG.md +177 -0
  5. data/Gemfile +21 -32
  6. data/Guardfile +8 -0
  7. data/README.rdoc +75 -14
  8. data/Rakefile +7 -100
  9. data/activeadmin.gemspec +21 -353
  10. data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/admin_notes_icon.png +0 -0
  11. data/app/assets/images/active_admin/datepicker/datepicker-header-bg.png +0 -0
  12. data/app/assets/images/active_admin/datepicker/datepicker-input-icon.png +0 -0
  13. data/app/assets/images/active_admin/datepicker/datepicker-next-link-icon.png +0 -0
  14. data/app/assets/images/active_admin/datepicker/datepicker-nipple.png +0 -0
  15. data/app/assets/images/active_admin/datepicker/datepicker-prev-link-icon.png +0 -0
  16. data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/loading.gif +0 -0
  17. data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/nested_menu_arrow.gif +0 -0
  18. data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/nested_menu_arrow_dark.gif +0 -0
  19. data/{lib/generators/active_admin/install/templates/images → app/assets/images/active_admin}/orderable.png +0 -0
  20. data/app/assets/javascripts/active_admin/base.js +12 -0
  21. data/{lib/generators/active_admin/install/templates/active_admin_vendor.js → app/assets/javascripts/active_admin/vendor.js} +0 -0
  22. data/{lib/active_admin/stylesheets/active_admin.scss → app/assets/stylesheets/active_admin/_base.css.scss} +58 -82
  23. data/{lib/active_admin/stylesheets/active_admin/_forms.scss → app/assets/stylesheets/active_admin/_forms.css.scss} +94 -5
  24. data/{lib/active_admin/stylesheets/active_admin/_header.scss → app/assets/stylesheets/active_admin/_header.css.scss} +13 -11
  25. data/app/assets/stylesheets/active_admin/_mixins.css.scss +1 -0
  26. data/{lib/active_admin/stylesheets/active_admin/_typography.scss → app/assets/stylesheets/active_admin/_typography.css.scss} +0 -0
  27. data/{lib/active_admin/stylesheets/active_admin/_comments.scss → app/assets/stylesheets/active_admin/components/_comments.css.scss} +0 -0
  28. data/app/assets/stylesheets/active_admin/components/_date_picker.css.scss +123 -0
  29. data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +38 -0
  30. data/{lib/active_admin/stylesheets/active_admin/mixins/_all.scss → app/assets/stylesheets/active_admin/mixins/_all.css.scss} +0 -0
  31. data/{lib/active_admin/stylesheets/active_admin/mixins/_buttons.scss → app/assets/stylesheets/active_admin/mixins/_buttons.css.scss} +0 -0
  32. data/{lib/active_admin/stylesheets/active_admin/mixins/_gradients.scss → app/assets/stylesheets/active_admin/mixins/_gradients.css.scss} +8 -0
  33. data/{lib/active_admin/stylesheets/active_admin/mixins/_icons.scss → app/assets/stylesheets/active_admin/mixins/_icons.css.scss} +0 -0
  34. data/{lib/active_admin/stylesheets/active_admin/mixins/_reset.scss → app/assets/stylesheets/active_admin/mixins/_reset.css.scss} +0 -0
  35. data/{lib/active_admin/stylesheets/active_admin/mixins/_rounded.scss → app/assets/stylesheets/active_admin/mixins/_rounded.css.scss} +0 -0
  36. data/{lib/active_admin/stylesheets/active_admin/mixins/_sections.scss → app/assets/stylesheets/active_admin/mixins/_sections.css.scss} +9 -2
  37. data/{lib/active_admin/stylesheets/active_admin/mixins/_shadows.scss → app/assets/stylesheets/active_admin/mixins/_shadows.css.scss} +1 -1
  38. data/{lib/active_admin/stylesheets/active_admin/mixins/_variables.scss → app/assets/stylesheets/active_admin/mixins/_variables.css.scss} +12 -3
  39. data/{lib/active_admin/views/templates/active_admin_dashboard → app/views/active_admin/dashboard}/index.html.arb +0 -0
  40. data/{lib/active_admin/views/templates → app/views}/active_admin/devise/mailer/reset_password_instructions.html.erb +0 -0
  41. data/{lib/active_admin/views/templates → app/views}/active_admin/devise/mailer/unlock_instructions.html.erb +0 -0
  42. data/{lib/active_admin/views/templates → app/views}/active_admin/devise/passwords/edit.html.erb +0 -0
  43. data/{lib/active_admin/views/templates → app/views}/active_admin/devise/passwords/new.html.erb +0 -0
  44. data/{lib/active_admin/views/templates → app/views}/active_admin/devise/sessions/new.html.erb +1 -1
  45. data/{lib/active_admin/views/templates → app/views}/active_admin/devise/shared/_links.erb +0 -0
  46. data/{lib/active_admin/views/templates → app/views}/active_admin/devise/unlocks/new.html.erb +0 -0
  47. data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/edit.html.arb +0 -0
  48. data/app/views/active_admin/resource/index.csv.erb +20 -0
  49. data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/index.html.arb +0 -0
  50. data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/new.html.arb +0 -0
  51. data/{lib/active_admin/views/templates/active_admin_default → app/views/active_admin/resource}/show.html.arb +0 -0
  52. data/app/views/layouts/active_admin.html.arb +1 -0
  53. data/{lib/active_admin/views/templates → app/views}/layouts/active_admin_logged_out.html.erb +8 -4
  54. data/docs/0-installation.md +50 -0
  55. data/docs/1-general-configuration.md +43 -0
  56. data/docs/2-resource-customization.md +35 -0
  57. data/docs/3-index-pages.md +55 -0
  58. data/docs/3-index-pages/index-as-block.md +16 -0
  59. data/docs/3-index-pages/index-as-blog.md +61 -0
  60. data/docs/3-index-pages/index-as-grid.md +21 -0
  61. data/docs/3-index-pages/index-as-table.md +90 -0
  62. data/docs/4-csv-format.md +14 -0
  63. data/docs/5-forms.md +39 -0
  64. data/docs/6-show-screens.md +22 -0
  65. data/docs/7-sidebars.md +35 -0
  66. data/docs/8-custom-actions.md +123 -0
  67. data/features/comments/commenting.feature +31 -4
  68. data/features/edit_page.feature +30 -1
  69. data/features/index/filters.feature +35 -0
  70. data/features/index/format_as_csv.feature +46 -0
  71. data/features/index/formats.feature +2 -0
  72. data/features/index/index_as_block.feature +1 -1
  73. data/features/index/index_as_grid.feature +1 -1
  74. data/features/index/index_as_table.feature +2 -0
  75. data/features/index/index_blank_slate.feature +56 -0
  76. data/features/index/pagination.feature +0 -6
  77. data/features/registering_assets.feature +2 -2
  78. data/features/sidebar_sections.feature +7 -8
  79. data/features/specifying_actions.feature +72 -1
  80. data/features/step_definitions/action_item_steps.rb +2 -2
  81. data/features/step_definitions/additional_web_steps.rb +26 -16
  82. data/features/step_definitions/attribute_steps.rb +5 -7
  83. data/features/step_definitions/configuration_steps.rb +9 -9
  84. data/features/step_definitions/factory_steps.rb +4 -3
  85. data/features/step_definitions/format_steps.rb +29 -1
  86. data/features/step_definitions/layout_steps.rb +3 -0
  87. data/features/step_definitions/menu_steps.rb +2 -2
  88. data/features/step_definitions/sidebar_steps.rb +1 -5
  89. data/features/step_definitions/user_steps.rb +8 -2
  90. data/features/step_definitions/web_steps.rb +82 -90
  91. data/features/sti_resource.feature +12 -0
  92. data/features/support/env.rb +12 -10
  93. data/features/support/paths.rb +2 -0
  94. data/features/support/selectors.rb +45 -0
  95. data/lib/active_admin.rb +33 -263
  96. data/lib/active_admin/application.rb +228 -0
  97. data/lib/active_admin/arbre.rb +10 -10
  98. data/lib/active_admin/arbre/{html.rb → builder.rb} +29 -2
  99. data/lib/active_admin/arbre/context.rb +8 -0
  100. data/lib/active_admin/arbre/{attributes.rb → html/attributes.rb} +0 -0
  101. data/lib/active_admin/arbre/{class_list.rb → html/class_list.rb} +0 -0
  102. data/lib/active_admin/arbre/{collection.rb → html/collection.rb} +0 -0
  103. data/lib/active_admin/arbre/{document.rb → html/document.rb} +0 -0
  104. data/lib/active_admin/arbre/{element.rb → html/element.rb} +6 -6
  105. data/lib/active_admin/arbre/{html5_elements.rb → html/html5_elements.rb} +0 -0
  106. data/lib/active_admin/arbre/{tag.rb → html/tag.rb} +0 -0
  107. data/lib/active_admin/arbre/{text_node.rb → html/text_node.rb} +0 -0
  108. data/lib/active_admin/asset_registration.rb +1 -1
  109. data/lib/active_admin/callbacks.rb +5 -3
  110. data/lib/active_admin/comments.rb +3 -3
  111. data/lib/active_admin/comments/comment.rb +6 -0
  112. data/lib/active_admin/comments/configuration.rb +8 -6
  113. data/lib/active_admin/comments/namespace_helper.rb +1 -1
  114. data/lib/active_admin/comments/views/active_admin_comments.rb +1 -1
  115. data/lib/active_admin/csv_builder.rb +45 -0
  116. data/lib/active_admin/dashboards.rb +1 -1
  117. data/lib/active_admin/dashboards/dashboard_controller.rb +3 -10
  118. data/lib/active_admin/dependency_checker.rb +28 -0
  119. data/lib/active_admin/deprecation.rb +36 -0
  120. data/lib/active_admin/devise.rb +14 -3
  121. data/lib/active_admin/dsl.rb +26 -4
  122. data/lib/active_admin/engine.rb +4 -0
  123. data/lib/active_admin/form_builder.rb +18 -9
  124. data/lib/active_admin/helpers/scope_chain.rb +23 -0
  125. data/lib/active_admin/helpers/settings.rb +70 -0
  126. data/lib/active_admin/locales/cs.yml +34 -0
  127. data/lib/active_admin/locales/da.yml +28 -0
  128. data/lib/active_admin/locales/en.yml +40 -0
  129. data/lib/active_admin/locales/es.yml +40 -0
  130. data/lib/active_admin/locales/fr.yml +40 -0
  131. data/lib/active_admin/locales/it.yml +39 -0
  132. data/lib/active_admin/locales/pl.yml +34 -0
  133. data/lib/active_admin/locales/pt-BR.yml +41 -0
  134. data/lib/active_admin/locales/ru.yml +40 -0
  135. data/lib/active_admin/locales/zh_cn.yml +40 -0
  136. data/lib/active_admin/menu_item.rb +6 -0
  137. data/lib/active_admin/namespace.rb +14 -5
  138. data/lib/active_admin/reloader.rb +30 -0
  139. data/lib/active_admin/renderer.rb +1 -1
  140. data/lib/active_admin/resource.rb +45 -88
  141. data/lib/active_admin/resource/action_items.rb +88 -0
  142. data/lib/active_admin/resource/menu.rb +45 -0
  143. data/lib/active_admin/resource/naming.rb +46 -0
  144. data/lib/active_admin/resource/scopes.rb +33 -0
  145. data/lib/active_admin/resource/sidebars.rb +36 -0
  146. data/lib/active_admin/resource_controller.rb +32 -37
  147. data/lib/active_admin/resource_controller/action_builder.rb +1 -1
  148. data/lib/active_admin/resource_controller/actions.rb +66 -40
  149. data/lib/active_admin/resource_controller/callbacks.rb +1 -1
  150. data/lib/active_admin/resource_controller/collection.rb +9 -14
  151. data/lib/active_admin/resource_controller/filters.rb +1 -1
  152. data/lib/active_admin/resource_controller/form.rb +1 -1
  153. data/lib/active_admin/resource_controller/menu.rb +1 -1
  154. data/lib/active_admin/resource_controller/page_configurations.rb +2 -2
  155. data/lib/active_admin/resource_controller/scoping.rb +1 -1
  156. data/lib/active_admin/resource_controller/sidebars.rb +1 -21
  157. data/lib/active_admin/router.rb +85 -0
  158. data/lib/active_admin/sass/active_admin.scss +3 -0
  159. data/lib/active_admin/sass/css_loader.rb +16 -0
  160. data/lib/active_admin/sass/helpers.rb +45 -0
  161. data/lib/active_admin/scope.rb +16 -2
  162. data/lib/active_admin/sidebar_section.rb +41 -0
  163. data/lib/active_admin/stylesheets/active_admin/mixins/_utilities.scss +0 -0
  164. data/lib/active_admin/version.rb +1 -1
  165. data/lib/active_admin/view_factory.rb +5 -3
  166. data/lib/active_admin/view_helpers.rb +1 -2
  167. data/lib/active_admin/view_helpers/active_admin_application_helper.rb +12 -0
  168. data/lib/active_admin/view_helpers/auto_link_helper.rb +2 -1
  169. data/lib/active_admin/view_helpers/display_helper.rb +1 -1
  170. data/lib/active_admin/view_helpers/filter_form_helper.rb +26 -14
  171. data/lib/active_admin/view_helpers/form_helper.rb +1 -0
  172. data/lib/active_admin/view_helpers/view_factory_helper.rb +1 -1
  173. data/lib/active_admin/views/components/attributes_table.rb +2 -2
  174. data/lib/active_admin/views/components/blank_slate.rb +17 -0
  175. data/lib/active_admin/views/components/columns.rb +1 -3
  176. data/lib/active_admin/views/components/paginated_collection.rb +26 -8
  177. data/lib/active_admin/views/components/scopes.rb +13 -8
  178. data/lib/active_admin/views/components/sidebar_section.rb +1 -3
  179. data/lib/active_admin/views/components/status_tag.rb +55 -0
  180. data/lib/active_admin/views/components/table_for.rb +25 -6
  181. data/lib/active_admin/views/header_renderer.rb +20 -4
  182. data/lib/active_admin/views/index_as_block.rb +12 -7
  183. data/lib/active_admin/views/index_as_blog.rb +61 -21
  184. data/lib/active_admin/views/index_as_grid.rb +22 -1
  185. data/lib/active_admin/views/index_as_table.rb +97 -6
  186. data/lib/active_admin/views/pages/base.rb +20 -9
  187. data/lib/active_admin/views/pages/dashboard.rb +7 -4
  188. data/lib/active_admin/views/pages/edit.rb +3 -2
  189. data/lib/active_admin/views/pages/index.rb +30 -5
  190. data/lib/active_admin/views/pages/layout.rb +26 -0
  191. data/lib/active_admin/views/pages/new.rb +3 -2
  192. data/lib/active_admin/views/pages/show.rb +1 -1
  193. data/lib/active_admin/views/tabbed_navigation.rb +94 -0
  194. data/lib/generators/active_admin/assets/assets_generator.rb +21 -0
  195. data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +427 -0
  196. data/lib/generators/active_admin/assets/templates/3.1/active_admin.css.scss +6 -0
  197. data/lib/generators/active_admin/assets/templates/3.1/active_admin.js +1 -0
  198. data/lib/generators/active_admin/assets/templates/dashboards.rb +36 -0
  199. data/lib/generators/active_admin/install/install_generator.rb +2 -4
  200. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +26 -4
  201. data/lib/generators/active_admin/install/templates/dashboards.rb +4 -2
  202. data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +2 -2
  203. data/script/local +44 -0
  204. data/script/use_rails +46 -0
  205. data/spec/integration/belongs_to_spec.rb +1 -1
  206. data/spec/integration/default_namespace.rb +77 -0
  207. data/spec/integration/javascript_spec.rb +20 -0
  208. data/spec/integration/stylesheets_spec.rb +41 -0
  209. data/spec/spec_helper.rb +21 -11
  210. data/spec/support/detect_rails_version.rb +10 -0
  211. data/spec/support/integration_example_group.rb +1 -1
  212. data/spec/support/jslint.yml +80 -0
  213. data/spec/support/rails_template.rb +1 -1
  214. data/spec/support/rails_template_with_data.rb +2 -1
  215. data/spec/support/templates/cucumber.rb +0 -4
  216. data/spec/unit/active_admin_spec.rb +8 -44
  217. data/spec/unit/application_spec.rb +78 -0
  218. data/spec/unit/arbre/context_spec.rb +22 -0
  219. data/spec/unit/arbre/html/element_finder_methods_spec.rb +2 -2
  220. data/spec/unit/arbre/html/element_spec.rb +2 -3
  221. data/spec/unit/arbre/html/tag_attributes_spec.rb +2 -2
  222. data/spec/unit/arbre/html/tag_spec.rb +2 -2
  223. data/spec/unit/arbre/html_spec.rb +2 -3
  224. data/spec/unit/auto_link_spec.rb +2 -1
  225. data/spec/unit/belongs_to_spec.rb +2 -1
  226. data/spec/unit/comments_spec.rb +43 -39
  227. data/spec/unit/controller_filters_spec.rb +11 -3
  228. data/spec/unit/csv_builder_spec.rb +83 -0
  229. data/spec/unit/devise_spec.rb +66 -0
  230. data/spec/unit/display_name_spec.rb +2 -2
  231. data/spec/unit/filter_form_builder_spec.rb +6 -3
  232. data/spec/unit/form_builder_spec.rb +20 -2
  233. data/spec/unit/generators/install_rails_3_1_spec.rb +16 -0
  234. data/spec/unit/helpers/scope_chain_spec.rb +36 -0
  235. data/spec/unit/helpers/settings_spec.rb +30 -0
  236. data/spec/unit/menu_item_spec.rb +6 -0
  237. data/spec/unit/namespace_spec.rb +68 -19
  238. data/spec/unit/rails_spec.rb +43 -0
  239. data/spec/unit/registration_spec.rb +18 -27
  240. data/spec/unit/reloader_spec.rb +28 -0
  241. data/spec/unit/resource/action_items_spec.rb +62 -0
  242. data/spec/unit/resource/menu_spec.rb +80 -0
  243. data/spec/unit/resource/naming_spec.rb +64 -0
  244. data/spec/unit/resource/scopes_spec.rb +30 -0
  245. data/spec/unit/resource/sidebars_spec.rb +50 -0
  246. data/spec/unit/resource_controller/collection_spec.rb +1 -1
  247. data/spec/unit/resource_controller_spec.rb +29 -24
  248. data/spec/unit/resource_spec.rb +78 -94
  249. data/spec/unit/sass/helpers_spec.rb +47 -0
  250. data/spec/unit/scope_spec.rb +11 -1
  251. data/spec/unit/view_factory_spec.rb +4 -1
  252. data/spec/unit/{components → views/components}/attributes_table_spec.rb +2 -2
  253. data/spec/unit/views/components/blank_slate_spec.rb +15 -0
  254. data/spec/unit/{components → views/components}/columns_spec.rb +2 -2
  255. data/spec/unit/{components → views/components}/panel_spec.rb +1 -3
  256. data/spec/unit/{components → views/components}/sidebar_section_spec.rb +3 -3
  257. data/spec/unit/views/components/status_tag_spec.rb +79 -0
  258. data/spec/unit/{components → views/components}/table_for_spec.rb +2 -1
  259. data/spec/unit/views/pages/layout_spec.rb +22 -0
  260. data/spec/unit/views/tabbed_navigation_spec.rb +125 -0
  261. data/tasks/docs.rake +39 -0
  262. data/tasks/test.rake +55 -0
  263. data/tasks/yard.rake +6 -0
  264. metadata +310 -189
  265. data/CHANGELOG.rdoc +0 -76
  266. data/lib/active_admin/action_items.rb +0 -37
  267. data/lib/active_admin/sidebar.rb +0 -39
  268. data/lib/active_admin/stylesheets/active_admin/_flash_messages.scss +0 -13
  269. data/lib/active_admin/view_helpers/status_tag_helper.rb +0 -13
  270. data/lib/active_admin/view_helpers/table_helper.rb +0 -12
  271. data/lib/active_admin/views/tabs_renderer.rb +0 -52
  272. data/lib/active_admin/views/templates/active_admin_default/index.csv.erb +0 -2
  273. data/lib/active_admin/views/templates/layouts/active_admin.html.erb +0 -39
  274. data/lib/generators/active_admin/install/templates/active_admin.js +0 -51
  275. data/spec/controllers/index_as_csv_spec.rb +0 -35
  276. data/spec/unit/action_items_spec.rb +0 -27
  277. data/spec/unit/tabs_renderer_spec.rb +0 -56
@@ -6,16 +6,20 @@ Feature: Commenting
6
6
 
7
7
  Background:
8
8
  Given a post with the title "Hello World" written by "Jane Doe" exists
9
+
10
+ Scenario: View a resource with no comments
9
11
  Given a show configuration of:
10
12
  """
11
13
  ActiveAdmin.register Post
12
14
  """
13
-
14
- Scenario: View a resource with no comments
15
15
  Then I should see "Comments (0)"
16
16
  And I should see "No comments yet."
17
17
 
18
18
  Scenario: Create a new comment
19
+ Given a show configuration of:
20
+ """
21
+ ActiveAdmin.register Post
22
+ """
19
23
  When I add a comment "Hello from Comment"
20
24
  Then I should see a flash with "Comment was successfully created"
21
25
  And I should be in the resource section for posts
@@ -37,6 +41,7 @@ Feature: Commenting
37
41
  """
38
42
  ActiveAdmin.register Post, :namespace => :new_namespace
39
43
  """
44
+ Given I am logged in
40
45
  When I am on the index page for posts in the new_namespace namespace
41
46
  And I follow "View"
42
47
  Then I should not see "Comments"
@@ -44,7 +49,7 @@ Feature: Commenting
44
49
  Scenario: Creating a comment in one namespace does not create it in another
45
50
  Given a show configuration of:
46
51
  """
47
- ActiveAdmin.allow_comments_in << :public
52
+ ActiveAdmin.application.allow_comments_in << :public
48
53
  ActiveAdmin.register Post
49
54
  ActiveAdmin.register Post, :namespace => :public
50
55
  """
@@ -67,6 +72,7 @@ Feature: Commenting
67
72
  """
68
73
  ActiveAdmin.register Post, :as => "Article"
69
74
  """
75
+ Given I am logged in
70
76
  When I am on the index page for articles
71
77
  And I follow "View"
72
78
  When I add a comment "Hello from Comment"
@@ -74,12 +80,33 @@ Feature: Commenting
74
80
  And I should be in the resource section for articles
75
81
 
76
82
  Scenario: Create an empty comment
83
+ Given a show configuration of:
84
+ """
85
+ ActiveAdmin.register Post
86
+ """
77
87
  When I add a comment ""
78
88
  Then I should see a flash with "Comment wasn't saved, text was empty."
79
89
  And I should see "Comments (0)"
80
90
 
81
91
  Scenario: Viewing all commments for a namespace
92
+ Given a show configuration of:
93
+ """
94
+ ActiveAdmin.register Post
95
+ """
82
96
  When I add a comment "Hello from Comment"
83
97
  When I am on the index page for comments
84
- Then I should see a table header for "Body"
98
+ Then I should see a table header with "Body"
85
99
  And I should see "Hello from Comment"
100
+
101
+ Scenario: Commenting on a STI subclass
102
+ Given a configuration of:
103
+ """
104
+ ActiveAdmin.register User
105
+ """
106
+ Given I am logged in
107
+ And a publisher named "Pragmatic Publishers" exists
108
+ When I am on the index page for users
109
+ And I follow "View"
110
+ When I add a comment "Hello World"
111
+ Then I should see a flash with "Comment was successfully created"
112
+ And I should be in the resource section for users
@@ -18,7 +18,7 @@ Feature: Edit Page
18
18
  Then the "Title" field should contain "Hello World"
19
19
  And the "Body" field should contain ""
20
20
  And the "Category" field should contain ""
21
- And the "Author" field should contain "John Doe"
21
+ And the "Author" field should contain the option "John Doe"
22
22
  When I fill in "Title" with "Hello World from update"
23
23
  When I press "Update Post"
24
24
  Then I should see "Post was successfully updated."
@@ -52,6 +52,35 @@ Feature: Edit Page
52
52
  And I should see the attribute "Title" with "Hello World from update"
53
53
  And I should see the attribute "Author" with "John Doe"
54
54
 
55
+ Scenario: Generating a custom form with :html set, visiting the new page first (bug probing issue #109)
56
+ Given a configuration of:
57
+ """
58
+ ActiveAdmin.register Post do
59
+ form :html => {} do |f|
60
+ f.inputs "Your Post" do
61
+ f.input :title
62
+ f.input :body
63
+ end
64
+ f.inputs "Publishing" do
65
+ f.input :published_at
66
+ end
67
+ f.buttons
68
+ end
69
+ end
70
+ """
71
+ Given I follow "New"
72
+ Then I follow "Posts"
73
+ Then I follow "Edit"
74
+ Then I should see a fieldset titled "Your Post"
75
+ And I should see a fieldset titled "Publishing"
76
+ And the "Title" field should contain "Hello World"
77
+ And the "Body" field should contain ""
78
+ When I fill in "Title" with "Hello World from update"
79
+ When I press "Update Post"
80
+ Then I should see "Post was successfully updated."
81
+ And I should see the attribute "Title" with "Hello World from update"
82
+ And I should see the attribute "Author" with "John Doe"
83
+
55
84
  Scenario: Generating a form from a partial
56
85
  Given "app/views/admin/posts/_form.html.erb" contains:
57
86
  """
@@ -0,0 +1,35 @@
1
+ Feature: Index Pagination
2
+
3
+ Background:
4
+ Given an index configuration of:
5
+ """
6
+ ActiveAdmin.register Post
7
+ """
8
+ Scenario: Filtering posts
9
+ Given 20 posts exist
10
+ When I am on the index page for posts
11
+ Then I should see "Displaying all 20 Posts"
12
+ And I should see "Author" within ".filter_form"
13
+ And I should see "Category" within ".filter_form"
14
+ And I should see "Search Title" within ".filter_form"
15
+ And I should see "Search Body" within ".filter_form"
16
+ And I should see "Published at" within ".filter_form"
17
+ And I should see "Created at" within ".filter_form"
18
+ And I should see "Updated at" within ".filter_form"
19
+
20
+ When I fill in "Search Title" with "Hello World 17"
21
+ And I press "Filter"
22
+ And I should see 1 posts in the table
23
+ And I should see "Hello World 17" within ".index_table"
24
+
25
+ Scenario: Filtering posts with no results
26
+ Given 20 posts exist
27
+ When I am on the index page for posts
28
+ Then I should see "Displaying all 20 Posts"
29
+ When I fill in "Search Title" with "THIS IS NOT AN EXISTING TITLE!!"
30
+ And I press "Filter"
31
+
32
+ And I should not see ".index_table"
33
+ Then I should not see a sortable table header
34
+ And I should not see pagination
35
+ And I should see "No Posts found"
@@ -0,0 +1,46 @@
1
+ Feature: Format as CSV
2
+
3
+ Background:
4
+ Given I am logged in
5
+
6
+ Scenario: Default
7
+ Given a configuration of:
8
+ """
9
+ ActiveAdmin.register Post
10
+ """
11
+ And a post with the title "Hello World" exists
12
+ When I am on the index page for posts
13
+ And I follow "CSV"
14
+ And I should download a CSV file for "posts" containing:
15
+ | Id | Title | Body | Published At | Created At | Updated At |
16
+ | \d+ | Hello World | | | (.*) | (.*) |
17
+
18
+ Scenario: Default with alias
19
+ Given a configuration of:
20
+ """
21
+ ActiveAdmin.register Post, :as => "MyArticle"
22
+ """
23
+ And 1 post exists
24
+ When I am on the index page for my_articles
25
+ And I follow "CSV"
26
+ And I should download a CSV file for "my-articles" containing:
27
+ | Id | Title | Body | Published At | Created At | Updated At |
28
+
29
+ Scenario: With CSV format customization
30
+ Given a configuration of:
31
+ """
32
+ ActiveAdmin.register Post do
33
+ csv do
34
+ column :title
35
+ column("Last update") { |post| post.updated_at }
36
+ column("Copyright") { "Greg Bell" }
37
+ end
38
+ end
39
+ """
40
+ And a post with the title "Hello, World" exists
41
+ When I am on the index page for posts
42
+ And I follow "CSV"
43
+ And I should download a CSV file for "posts" containing:
44
+ | Title | Last update | Copyright |
45
+ | Hello, World | (.*) | Greg Bell |
46
+
@@ -5,6 +5,8 @@ Feature: Index Formats
5
5
  """
6
6
  ActiveAdmin.register Post
7
7
  """
8
+ And 1 post exists
9
+ When I am on the index page for posts
8
10
  Then I should see a link to download "CSV"
9
11
  And I should see a link to download "XML"
10
12
  And I should see a link to download "JSON"
@@ -12,4 +12,4 @@ Feature: Index as Block
12
12
  end
13
13
  end
14
14
  """
15
- Then I should see "Hello World from Block" within "a"
15
+ Then I should see "Hello World from Block" within ".index_as_block"
@@ -14,7 +14,7 @@ Feature: Index as Grid
14
14
  """
15
15
  Then the table ".index_grid" should have 3 rows
16
16
  And the table ".index_grid" should have 3 columns
17
- And there should be 9 "a" tags within "table.index_grid"
17
+ And there should be 9 "a" tags within index grid
18
18
 
19
19
  Scenario: Viewing index as a grid and set the number of columns
20
20
  Given 9 posts exist
@@ -7,6 +7,8 @@ Feature: Index as Table
7
7
  """
8
8
  ActiveAdmin.register Post
9
9
  """
10
+ And 1 post exists
11
+ When I am on the index page for posts
10
12
  Then I should see a sortable table header with "ID"
11
13
  And I should see a sortable table header with "Title"
12
14
 
@@ -0,0 +1,56 @@
1
+ Feature: Index Blank Slate
2
+
3
+ Viewing an index page with no resources yet
4
+
5
+ Scenario: Viewing the default table with no resources
6
+ Given an index configuration of:
7
+ """
8
+ ActiveAdmin.register Post
9
+ """
10
+ Then I should not see a sortable table header
11
+ And I should see "There are no Posts yet. Create one"
12
+ And I should not see ".index_table"
13
+ And I should not see pagination
14
+ When I follow "Create one"
15
+ Then I should be on the new post page
16
+
17
+ Scenario: Viewing the default table with no resources and no 'new' action
18
+ Given an index configuration of:
19
+ """
20
+ ActiveAdmin.register Post do
21
+ actions :index, :show
22
+ end
23
+ """
24
+ And I should see "There are no Posts yet."
25
+ And I should not see "Create one"
26
+
27
+ Scenario: Viewing a index using a grid with no resources
28
+ Given an index configuration of:
29
+ """
30
+ ActiveAdmin.register Post do
31
+ index :as => :grid do |post|
32
+ h2 auto_link(post)
33
+ end
34
+ end
35
+ """
36
+ And I should see "There are no Posts yet. Create one"
37
+
38
+ Scenario: Viewing a index using blocks with no resources
39
+ Given an index configuration of:
40
+ """
41
+ ActiveAdmin.register Post do
42
+ index :as => :block do |post|
43
+ span(link_to(post.title, admin_post_path(post)))
44
+ end
45
+ end
46
+ """
47
+ And I should see "There are no Posts yet. Create one"
48
+
49
+ Scenario: Viewing a blog with no resources
50
+ Given an index configuration of:
51
+ """
52
+ ActiveAdmin.register Post do
53
+ index :as => :blog
54
+ end
55
+ """
56
+ And I should see "There are no Posts yet. Create one"
@@ -5,12 +5,6 @@ Feature: Index Pagination
5
5
  """
6
6
  ActiveAdmin.register Post
7
7
  """
8
-
9
- Scenario: Viewing index when no resources exist
10
- When I am on the index page for posts
11
- Then I should see "No Posts found"
12
- And I should not see pagination
13
-
14
8
  Scenario: Viewing index when one page of resources exist
15
9
  Given 20 posts exist
16
10
  When I am on the index page for posts
@@ -19,7 +19,7 @@ Feature: Registering Assets
19
19
  Scenario: Registering a CSS file
20
20
  Given a configuration of:
21
21
  """
22
- ActiveAdmin.register_stylesheet "some-random-css.css"
22
+ ActiveAdmin.application.register_stylesheet "some-random-css.css"
23
23
  ActiveAdmin.register Post
24
24
  """
25
25
  When I am on the index page for posts
@@ -28,7 +28,7 @@ Feature: Registering Assets
28
28
  Scenario: Registering a JS file
29
29
  Given a configuration of:
30
30
  """
31
- ActiveAdmin.register_javascript "some-random-js.js"
31
+ ActiveAdmin.application.register_javascript "some-random-js.js"
32
32
  ActiveAdmin.register Post
33
33
  """
34
34
  When I am on the index page for posts
@@ -17,7 +17,7 @@ Feature: Sidebar Sections
17
17
  """
18
18
  When I am on the index page for posts
19
19
  Then I should see a sidebar titled "Help"
20
- Then I should see /Need help/ within the sidebar "Help"
20
+ Then I should see /Need help/ within the "Help" sidebar
21
21
 
22
22
  When I follow "View"
23
23
  Then I should see a sidebar titled "Help"
@@ -41,7 +41,7 @@ Feature: Sidebar Sections
41
41
  """
42
42
  When I am on the index page for posts
43
43
  Then I should see a sidebar titled "Help"
44
- Then I should see /Need help/ within the sidebar "Help"
44
+ Then I should see /Need help/ within the "Help" sidebar
45
45
 
46
46
  When I follow "View"
47
47
  Then I should not see a sidebar titled "Help"
@@ -94,8 +94,8 @@ Feature: Sidebar Sections
94
94
  """
95
95
  When I am on the index page for posts
96
96
  Then I should see a sidebar titled "Help"
97
- And I should see "First List First Item" within "ul li"
98
- And I should see "Second List Second Item" within "ul li"
97
+ And I should see "First List First Item" within the "Help" sidebar
98
+ And I should see "Second List Second Item" within the "Help" sidebar
99
99
 
100
100
  Scenario: Rendering sidebar by default without a block or partial name
101
101
  Given "app/views/admin/posts/_help_sidebar.html.erb" contains:
@@ -109,12 +109,12 @@ Feature: Sidebar Sections
109
109
  end
110
110
  """
111
111
  When I am on the index page for posts
112
- Then I should see "Hello World from a partial" within ".sidebar_section"
112
+ Then I should see "Hello World from a partial" within the "Help" sidebar
113
113
 
114
114
  Scenario: Rendering a partial as the sidebar content
115
115
  Given "app/views/admin/posts/_custom_help_partial.html.erb" contains:
116
116
  """
117
- <p>Hello World from a partial</p>
117
+ <p>Hello World from a custom partial</p>
118
118
  """
119
119
  Given a configuration of:
120
120
  """
@@ -123,6 +123,5 @@ Feature: Sidebar Sections
123
123
  end
124
124
  """
125
125
  When I am on the index page for posts
126
- Then I should see "Hello World from a partial" within ".sidebar_section"
127
-
126
+ Then I should see "Hello World from a custom partial" within the "Help" sidebar
128
127
 
@@ -2,7 +2,6 @@ Feature: Specifying Actions
2
2
 
3
3
  Specifying which actions to allow on my resource
4
4
 
5
- @allow-rescue
6
5
  Scenario: Only creating the index action
7
6
  Given a configuration of:
8
7
  """
@@ -14,3 +13,75 @@ Feature: Specifying Actions
14
13
  And a post with the title "Hello World" exists
15
14
  When I am on the index page for posts
16
15
  Then an "AbstractController::ActionNotFound" exception should be raised when I follow "View"
16
+
17
+ Scenario: Specify a custom collection action with template
18
+ Given a configuration of:
19
+ """
20
+ ActiveAdmin.register Post do
21
+ action_item(:only => :index) do
22
+ link_to('Import Posts', import_admin_posts_path)
23
+ end
24
+
25
+ collection_action :import
26
+ end
27
+ """
28
+ Given "app/views/admin/posts/import.html.erb" contains:
29
+ """
30
+ <p>We are currently working on this feature...</p>
31
+ """
32
+ And I am logged in
33
+ When I am on the index page for posts
34
+ And I follow "Import"
35
+ Then I should see "We are currently working on this feature"
36
+
37
+ Scenario: Specify a custom member action with template
38
+ Given a configuration of:
39
+ """
40
+ ActiveAdmin.register Post do
41
+ action_item(:only => :show) do
42
+ link_to('Review', review_admin_post_path)
43
+ end
44
+
45
+ member_action :review do
46
+ @post = Post.find(params[:id])
47
+ end
48
+ end
49
+ """
50
+ Given "app/views/admin/posts/review.html.erb" contains:
51
+ """
52
+ <h1>Review: <%= @post.title %></h1>
53
+ """
54
+ And I am logged in
55
+ And a post with the title "Hello World" exists
56
+ When I am on the index page for posts
57
+ And I follow "View"
58
+ And I follow "Review"
59
+ Then I should see "Review: Hello World"
60
+ And I should see the page title "Review"
61
+ And I should see the Active Admin layout
62
+
63
+ Scenario: Specify a custom member action with template using arb
64
+ Given a configuration of:
65
+ """
66
+ ActiveAdmin.register Post do
67
+ action_item(:only => :show) do
68
+ link_to('Review', review_admin_post_path)
69
+ end
70
+
71
+ member_action :review do
72
+ @post = Post.find(params[:id])
73
+ end
74
+ end
75
+ """
76
+ Given "app/views/admin/posts/review.html.arb" contains:
77
+ """
78
+ h1 "Review: #{@post.title}"
79
+ """
80
+ And I am logged in
81
+ And a post with the title "Hello World" exists
82
+ When I am on the index page for posts
83
+ And I follow "View"
84
+ And I follow "Review"
85
+ Then I should see "Review: Hello World"
86
+ And I should see the page title "Review"
87
+ And I should see the Active Admin layout