specifying_actions.feature 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. Feature: Specifying Actions
  2. Specifying which actions to allow on my resource
  3. Scenario: Only creating the index action
  4. Given a configuration of:
  5. """
  6. ActiveAdmin.register Post do
  7. actions :index
  8. index do
  9. column do |post|
  10. link_to "View", admin_post_path(post)
  11. end
  12. end
  13. end
  14. """
  15. And I am logged in
  16. And a post with the title "Hello World" exists
  17. When I am on the index page for posts
  18. Then an "AbstractController::ActionNotFound" exception should be raised when I follow "View"
  19. Scenario: Specify a custom collection action with template
  20. Given a configuration of:
  21. """
  22. ActiveAdmin.register Post do
  23. action_item(:only => :index) do
  24. link_to('Import Posts', import_admin_posts_path)
  25. end
  26. collection_action :import
  27. end
  28. """
  29. Given "app/views/admin/posts/import.html.erb" contains:
  30. """
  31. <p>We are currently working on this feature...</p>
  32. """
  33. And I am logged in
  34. When I am on the index page for posts
  35. And I follow "Import"
  36. Then I should see "We are currently working on this feature"
  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. member_action :review do
  45. @post = Post.find(params[:id])
  46. end
  47. end
  48. """
  49. Given "app/views/admin/posts/review.html.erb" contains:
  50. """
  51. <h1>Review: <%= @post.title %></h1>
  52. """
  53. And I am logged in
  54. And a post with the title "Hello World" exists
  55. When I am on the index page for posts
  56. And I follow "View"
  57. And I follow "Review"
  58. Then I should see "Review: Hello World"
  59. And I should see the page title "Review"
  60. And I should see the Active Admin layout
  61. Scenario: Specify a custom member action with template using arb
  62. Given a configuration of:
  63. """
  64. ActiveAdmin.register Post do
  65. action_item(:only => :show) do
  66. link_to('Review', review_admin_post_path)
  67. end
  68. member_action :review do
  69. @post = Post.find(params[:id])
  70. end
  71. end
  72. """
  73. Given "app/views/admin/posts/review.html.arb" contains:
  74. """
  75. h1 "Review: #{@post.title}"
  76. """
  77. And I am logged in
  78. And a post with the title "Hello World" exists
  79. When I am on the index page for posts
  80. And I follow "View"
  81. And I follow "Review"
  82. Then I should see "Review: Hello World"
  83. And I should see the page title "Review"
  84. And I should see the Active Admin layout