-
Notifications
You must be signed in to change notification settings - Fork 0
/
sidebar_sections.feature
210 lines (177 loc) · 5.98 KB
/
sidebar_sections.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
Feature: Sidebar Sections
Creating and Configuring sidebar sections
Background:
Given I am logged in
And a post with the title "Hello World" exists
Scenario: Create a sidebar for all actions
Given a configuration of:
"""
ActiveAdmin.register Post do
sidebar :help do
"Need help? Email us at [email protected]"
end
end
"""
When I am on the index page for posts
Then I should see a sidebar titled "Help"
Then I should see "Need help" within the "Help" sidebar
When I follow "View"
Then I should see a sidebar titled "Help"
When I follow "Edit Post"
Then I should see a sidebar titled "Help"
When I am on the index page for posts
When I follow "New Post"
Then I should see a sidebar titled "Help"
Scenario: Create a sidebar for only one action
Given a configuration of:
"""
ActiveAdmin.register Post do
sidebar :help, :only => :index do
"Need help? Email us at [email protected]"
end
end
"""
When I am on the index page for posts
Then I should see a sidebar titled "Help"
Then I should see "Need help" within the "Help" sidebar
When I follow "View"
Then I should not see a sidebar titled "Help"
When I follow "Edit Post"
Then I should not see a sidebar titled "Help"
When I am on the index page for posts
When I follow "New Post"
Then I should not see a sidebar titled "Help"
Scenario: Create a sidebar for all except one action
Given a configuration of:
"""
ActiveAdmin.register Post do
sidebar :help, :except => :index do
"Need help? Email us at [email protected]"
end
end
"""
When I am on the index page for posts
Then I should not see a sidebar titled "Help"
When I follow "View"
Then I should see a sidebar titled "Help"
When I follow "Edit Post"
Then I should see a sidebar titled "Help"
When I am on the index page for posts
When I follow "New Post"
Then I should see a sidebar titled "Help"
Scenario: Create a sidebar for only one action with if clause that returns false
Given a configuration of:
"""
ActiveAdmin.register Post do
sidebar :help, :only => :index, :if => proc{ current_active_admin_user.nil? } do
"Need help? Email us at [email protected]"
end
end
"""
When I am on the index page for posts
Then I should not see a sidebar titled "Help"
When I follow "View"
Then I should not see a sidebar titled "Help"
When I follow "Edit Post"
Then I should not see a sidebar titled "Help"
When I am on the index page for posts
When I follow "New Post"
Then I should not see a sidebar titled "Help"
Scenario: Create a sidebar for only one action with if clause with method symbol
Given a configuration of:
"""
module SidebarHelper
def can_sidebar?; false; end
end
ActiveAdmin.register Post do
controller { helper SidebarHelper }
sidebar :help, :only => :index, :if => :can_sidebar? do
"Need help? Email us at [email protected]"
end
end
"""
When I am on the index page for posts
Then I should not see a sidebar titled "Help"
When I follow "View"
Then I should not see a sidebar titled "Help"
When I follow "Edit Post"
Then I should not see a sidebar titled "Help"
When I am on the index page for posts
When I follow "New Post"
Then I should not see a sidebar titled "Help"
Scenario: Create a sidebar for only one action with if clause that returns true
Given a configuration of:
"""
ActiveAdmin.register Post do
sidebar :help, :only => :show, :if => proc{ !current_active_admin_user.nil? } do
"Need help? Email us at [email protected]"
end
end
"""
When I am on the index page for posts
Then I should not see a sidebar titled "Help"
When I follow "View"
Then I should see a sidebar titled "Help"
Then I should see "Need help" within the "Help" sidebar
When I follow "Edit Post"
Then I should not see a sidebar titled "Help"
When I am on the index page for posts
When I follow "New Post"
Then I should not see a sidebar titled "Help"
Scenario: Create a sidebar with deep content
Given a configuration of:
"""
ActiveAdmin.register Post do
sidebar :help do
ul do
li "First List First Item"
li "First List Second Item"
end
ul do
li "Second List First Item"
li "Second List Second Item"
end
end
end
"""
When I am on the index page for posts
Then I should see a sidebar titled "Help"
And I should see "First List First Item" within the "Help" sidebar
And I should see "Second List Second Item" within the "Help" sidebar
Scenario: Rendering sidebar by default without a block or partial name
Given "app/views/admin/posts/_help_sidebar.html.erb" contains:
"""
<p>Hello World from a partial</p>
"""
Given a configuration of:
"""
ActiveAdmin.register Post do
sidebar :help
end
"""
When I am on the index page for posts
Then I should see "Hello World from a partial" within the "Help" sidebar
Scenario: Rendering a partial as the sidebar content
Given "app/views/admin/posts/_custom_help_partial.html.erb" contains:
"""
<p>Hello World from a custom partial</p>
"""
Given a configuration of:
"""
ActiveAdmin.register Post do
sidebar :help, :partial => "custom_help_partial"
end
"""
When I am on the index page for posts
Then I should see "Hello World from a custom partial" within the "Help" sidebar
Scenario: Position sidebar at the top using priority option
Given a configuration of:
"""
ActiveAdmin.register Post do
sidebar :help, priority: 0 do
"Need help? Email us at [email protected]"
end
end
"""
When I am on the index page for posts
Then I should see a sidebar titled "Help" above sidebar titled "Filters"