-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_page.feature
117 lines (108 loc) · 4.08 KB
/
edit_page.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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 do
if Rails::VERSION::MAJOR == 4
permit_params :custom_category_id, :author_id, :title,
:body, :position, :published_at, :starred
end
end
"""
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
permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR == 4
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.actions
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
permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR == 4
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.actions
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.actions
end %>
"""
Given a configuration of:
"""
ActiveAdmin.register Post do
permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR == 4
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"