123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- Feature: Edit Page
- Customizing the form to edit resources
- Background:
- Given a category named "Music" exists
- And a user named "John Doe" exists
- And a post with the title "Hello World" written by "John Doe" exists
- And I am logged in
- Given a configuration of:
- """
- ActiveAdmin.register Post
- """
- When I am on the index page for posts
- Scenario: Default form with no config
- Given I follow "Edit"
- Then the "Title" field should contain "Hello World"
- And the "Body" field should contain ""
- And the "Category" field should contain ""
- And the "Author" field should contain the option "John Doe"
- When I fill in "Title" with "Hello World from update"
- When I press "Update Post"
- Then I should see "Post was successfully updated."
- And I should see the attribute "Title" with "Hello World from update"
- And I should see the attribute "Author" with "John Doe"
- Scenario: Generating a custom form
- Given a configuration of:
- """
- ActiveAdmin.register Post do
- form do |f|
- f.inputs "Your Post" do
- f.input :title
- f.input :body
- end
- f.inputs "Publishing" do
- f.input :published_at
- end
- f.buttons
- end
- end
- """
- Given I follow "Edit"
- Then I should see a fieldset titled "Your Post"
- And I should see a fieldset titled "Publishing"
- And the "Title" field should contain "Hello World"
- And the "Body" field should contain ""
- When I fill in "Title" with "Hello World from update"
- When I press "Update Post"
- Then I should see "Post was successfully updated."
- And I should see the attribute "Title" with "Hello World from update"
- And I should see the attribute "Author" with "John Doe"
- Scenario: Generating a custom form with :html set, visiting the new page first (bug probing issue #109)
- Given a configuration of:
- """
- ActiveAdmin.register Post do
- form :html => {} do |f|
- f.inputs "Your Post" do
- f.input :title
- f.input :body
- end
- f.inputs "Publishing" do
- f.input :published_at
- end
- f.buttons
- end
- end
- """
- Given I follow "New"
- Then I follow "Posts"
- Then I follow "Edit"
- Then I should see a fieldset titled "Your Post"
- And I should see a fieldset titled "Publishing"
- And the "Title" field should contain "Hello World"
- And the "Body" field should contain ""
- When I fill in "Title" with "Hello World from update"
- When I press "Update Post"
- Then I should see "Post was successfully updated."
- And I should see the attribute "Title" with "Hello World from update"
- And I should see the attribute "Author" with "John Doe"
- Scenario: Generating a form from a partial
- Given "app/views/admin/posts/_form.html.erb" contains:
- """
- <% url = @post.new_record? ? admin_posts_path : admin_post_path(@post) %>
- <%= active_admin_form_for @post, :url => url do |f|
- f.inputs :title, :body
- f.buttons
- end %>
- """
- Given a configuration of:
- """
- ActiveAdmin.register Post do
- form :partial => "form"
- end
- """
- Given I follow "Edit"
- Then the "Title" field should contain "Hello World"
- And the "Body" field should contain ""
- When I fill in "Title" with "Hello World from update"
- When I press "Update Post"
- Then I should see "Post was successfully updated."
- And I should see the attribute "Title" with "Hello World from update"
- And I should see the attribute "Author" with "John Doe"
|