Skip to content
Newer
Older
100644 76 lines (70 sloc) 2.43 KB
d8911af @gregbell Refactored new view specs into cukes
gregbell authored
1 Feature: New Page
2
3 Customizing the form to create new resources
4
5 Background:
6 Given a category named "Music" exists
7 Given a user named "John Doe" exists
8 And I am logged in
9 Given a configuration of:
10 """
11 ActiveAdmin.register Post
12 """
13 When I am on the index page for posts
14
15 Scenario: Default form with no config
16 Given I follow "New Post"
17 When I fill in "Title" with "Hello World"
18 And I fill in "Body" with "This is the body"
19 And I select "Music" from "Category"
20 And I select "John Doe" from "Author"
21 And I press "Create Post"
22 Then I should see "Post was successfully created."
23 And I should see the attribute "Title" with "Hello World"
24 And I should see the attribute "Body" with "This is the body"
25 And I should see the attribute "Category" with "Music"
26 And I should see the attribute "Author" with "John Doe"
27
28 Scenario: Generating a custom form
29 Given a configuration of:
30 """
31 ActiveAdmin.register Post do
32 form do |f|
33 f.inputs "Your Post" do
34 f.input :title
35 f.input :body
36 end
37 f.inputs "Publishing" do
38 f.input :published_at
39 end
40 f.buttons
41 end
42 end
43 """
44 Given I follow "New Post"
45 Then I should see a fieldset titled "Your Post"
46 And I should see a fieldset titled "Publishing"
47 When I fill in "Title" with "Hello World"
48 And I fill in "Body" with "This is the body"
49 And I press "Create Post"
50 Then I should see "Post was successfully created."
51 And I should see the attribute "Title" with "Hello World"
52 And I should see the attribute "Body" with "This is the body"
53
54 Scenario: Generating a form from a partial
55 Given "app/views/admin/posts/_form.html.erb" contains:
56 """
e974723 @gregbell Refactored the new and edit pages to use arb templates
gregbell authored
57 <% url = @post.new_record? ? admin_posts_path : admin_post_path(@post) %>
58 <%= active_admin_form_for @post, :url => url do |f|
d8911af @gregbell Refactored new view specs into cukes
gregbell authored
59 f.inputs :title, :body
60 f.buttons
61 end %>
62 """
63 Given a configuration of:
64 """
65 ActiveAdmin.register Post do
66 form :partial => "form"
67 end
68 """
69 Given I follow "New Post"
70 When I fill in "Title" with "Hello World"
71 And I fill in "Body" with "This is the body"
72 And I press "Create Post"
73 Then I should see "Post was successfully created."
74 And I should see the attribute "Title" with "Hello World"
75 And I should see the attribute "Body" with "This is the body"
Something went wrong with that request. Please try again.