/
registering_pages.feature
229 lines (204 loc) · 6.02 KB
/
registering_pages.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
Feature: Registering Pages
Registering pages within Active Admin
Background:
Given I am logged in
Scenario: Registering a page
Given a configuration of:
"""
ActiveAdmin.register_page "Status" do
content do
"I love chocolate."
end
end
"""
When I go to the dashboard
And I follow "Status"
Then I should see the page title "Status"
And I should see the content "I love chocolate."
Scenario: Registering a page with a complex name
Given a configuration of:
"""
ActiveAdmin.register_page "Chocolate I lØve You!" do
content do
"I love chocolate."
end
end
"""
When I go to the dashboard
And I follow "Chocolate I lØve You!"
Then I should see the page title "Chocolate I lØve You!"
And I should see the content "I love chocolate."
Scenario: Registering an empty page
Given a configuration of:
"""
ActiveAdmin.register_page "Status"
"""
When I go to the dashboard
And I follow "Status"
Then I should see the page title "Status"
Scenario: Registering a page with a custom title as a string
Given a configuration of:
"""
ActiveAdmin.register_page "Status" do
content title: "Custom Page Title" do
"I love chocolate."
end
end
"""
When I go to the dashboard
And I follow "Status"
Then I should see the page title "Custom Page Title"
Scenario: Registering a page with a custom title as a proc
Given a configuration of:
"""
ActiveAdmin.register_page "Status" do
content title: proc{ "Custom Page Title from Proc" } do
"I love chocolate."
end
end
"""
When I go to the dashboard
And I follow "Status"
Then I should see the page title "Custom Page Title from Proc"
Scenario: Adding a sidebar section to a page
Given a configuration of:
"""
ActiveAdmin.register_page "Status" do
sidebar :help do
"Need help? Email us at help@example.com"
end
content do
"I love chocolate."
end
end
"""
When I go to the dashboard
And I follow "Status"
Then I should see "Need help? Email us at help@example.com"
Scenario: Adding an action item to a page
Given a configuration of:
"""
ActiveAdmin.register_page "Status" do
action_item :visit do
link_to "Visit", "/"
end
content do
"I love chocolate."
end
end
"""
When I go to the dashboard
And I follow "Status"
Then I should see an action item link to "Visit"
Scenario: Adding a page action to a page with multiple http methods
Given a configuration of:
"""
ActiveAdmin.register_page "Status" do
page_action :check, method: [:get, :post] do
redirect_to admin_status_path, notice: "Checked via #{request.method}"
end
action_item :post_check do
link_to "Post Check", admin_status_check_path, method: :post
end
action_item :get_check do
link_to "Get Check", admin_status_check_path
end
content do
"I love chocolate."
end
end
"""
When I go to the dashboard
And I follow "Status"
And I follow "Post Check"
Then I should see "Checked via POST"
When I follow "Get Check"
Then I should see "Checked via GET"
Scenario: Adding a page action to a page
Given a configuration of:
"""
ActiveAdmin.register_page "Status" do
page_action :check do
redirect_to admin_status_path
end
content do
("Chocolate I lØve You!" + link_to("Check", admin_status_check_path)).html_safe
end
end
"""
When I go to the dashboard
And I follow "Status"
And I follow "Check"
Then I should see the content "Chocolate I lØve You!"
@changes-filesystem
Scenario: Adding a page action to a page with erb view
Given a configuration of:
"""
ActiveAdmin.register_page "Status" do
page_action :check do
end
content do
("Chocolate I lØve You!" + link_to("Check", admin_status_check_path)).html_safe
end
end
"""
And "app/views/admin/status/check.html.erb" contains:
"""
<div>Chocolate lØves You Too!</div>
"""
When I go to the dashboard
And I follow "Status"
And I follow "Check"
Then I should see the content "Chocolate lØves You Too!"
Scenario: Registering a page with paginated index table for a collection Array
Given a user named "John Doe" exists
And a configuration of:
"""
ActiveAdmin.register_page "Special users" do
content do
collection = Kaminari.paginate_array(User.all).page(params.fetch(:page, 1))
table_for(collection) do
column :first_name
column :last_name
end
paginated_collection(collection, entry_name: "Special users")
end
end
"""
When I go to the dashboard
And I follow "Special users"
Then I should see the page title "Special users"
And I should see 1 user in the table
Scenario: Displaying parent information from a belongs_to page
Given a configuration of:
"""
ActiveAdmin.register Post
ActiveAdmin.register_page "Status" do
belongs_to :post
content do
"Status page for #{helpers.parent.title}"
end
end
"""
And 1 post with the title "Post 1" exists
When I go to the first post custom status page
Then I should see the content "Status page for Post 1"
And I should see a link to "Post 1" in the breadcrumb
Scenario: Rendering sortable table_for within page
Given a configuration of:
"""
ActiveAdmin.register Post
ActiveAdmin.register_page "Last Posts" do
content do
table_for Post.last(2), sortable: true do
column :id
column :title
column :author
end
end
end
"""
And a post with the title "Hello World" written by "Jane Doe" exists
When I go to the last posts page
Then I should see the page title "Last Posts"
And I should see 1 post in the table