edit_page.feature 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. Feature: Edit Page
  2. Customizing the form to edit resources
  3. Background:
  4. Given a category named "Music" exists
  5. And a user named "John Doe" exists
  6. And a post with the title "Hello World" written by "John Doe" exists
  7. And I am logged in
  8. Given a configuration of:
  9. """
  10. ActiveAdmin.register Post
  11. """
  12. When I am on the index page for posts
  13. Scenario: Default form with no config
  14. Given I follow "Edit"
  15. Then the "Title" field should contain "Hello World"
  16. And the "Body" field should contain ""
  17. And the "Category" field should contain ""
  18. And the "Author" field should contain the option "John Doe"
  19. When I fill in "Title" with "Hello World from update"
  20. When I press "Update Post"
  21. Then I should see "Post was successfully updated."
  22. And I should see the attribute "Title" with "Hello World from update"
  23. And I should see the attribute "Author" with "John Doe"
  24. Scenario: Generating a custom form
  25. Given a configuration of:
  26. """
  27. ActiveAdmin.register Post do
  28. form do |f|
  29. f.inputs "Your Post" do
  30. f.input :title
  31. f.input :body
  32. end
  33. f.inputs "Publishing" do
  34. f.input :published_at
  35. end
  36. f.buttons
  37. end
  38. end
  39. """
  40. Given I follow "Edit"
  41. Then I should see a fieldset titled "Your Post"
  42. And I should see a fieldset titled "Publishing"
  43. And the "Title" field should contain "Hello World"
  44. And the "Body" field should contain ""
  45. When I fill in "Title" with "Hello World from update"
  46. When I press "Update Post"
  47. Then I should see "Post was successfully updated."
  48. And I should see the attribute "Title" with "Hello World from update"
  49. And I should see the attribute "Author" with "John Doe"
  50. Scenario: Generating a custom form with :html set, visiting the new page first (bug probing issue #109)
  51. Given a configuration of:
  52. """
  53. ActiveAdmin.register Post do
  54. form :html => {} do |f|
  55. f.inputs "Your Post" do
  56. f.input :title
  57. f.input :body
  58. end
  59. f.inputs "Publishing" do
  60. f.input :published_at
  61. end
  62. f.buttons
  63. end
  64. end
  65. """
  66. Given I follow "New"
  67. Then I follow "Posts"
  68. Then I follow "Edit"
  69. Then I should see a fieldset titled "Your Post"
  70. And I should see a fieldset titled "Publishing"
  71. And the "Title" field should contain "Hello World"
  72. And the "Body" field should contain ""
  73. When I fill in "Title" with "Hello World from update"
  74. When I press "Update Post"
  75. Then I should see "Post was successfully updated."
  76. And I should see the attribute "Title" with "Hello World from update"
  77. And I should see the attribute "Author" with "John Doe"
  78. Scenario: Generating a form from a partial
  79. Given "app/views/admin/posts/_form.html.erb" contains:
  80. """
  81. <% url = @post.new_record? ? admin_posts_path : admin_post_path(@post) %>
  82. <%= active_admin_form_for @post, :url => url do |f|
  83. f.inputs :title, :body
  84. f.buttons
  85. end %>
  86. """
  87. Given a configuration of:
  88. """
  89. ActiveAdmin.register Post do
  90. form :partial => "form"
  91. end
  92. """
  93. Given I follow "Edit"
  94. Then the "Title" field should contain "Hello World"
  95. And the "Body" field should contain ""
  96. When I fill in "Title" with "Hello World from update"
  97. When I press "Update Post"
  98. Then I should see "Post was successfully updated."
  99. And I should see the attribute "Title" with "Hello World from update"
  100. And I should see the attribute "Author" with "John Doe"