File tree Expand file tree Collapse file tree 2 files changed +34
-8
lines changed
lib/active_admin/resource_controller Expand file tree Collapse file tree 2 files changed +34
-8
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ def index
15
15
yield ( format ) if block_given?
16
16
end
17
17
end
18
+ alias :index! :index
18
19
19
20
protected
20
21
Original file line number Diff line number Diff line change 5
5
before do
6
6
load_resources { ActiveAdmin . register Post }
7
7
@controller = Admin ::PostsController . new
8
+ end
8
9
9
- @controller . instance_eval do
10
- def index
11
- super do
12
- render body : "Rendered from passed block"
13
- return
10
+ context "with the call super" do
11
+ before do
12
+ @controller . instance_eval do
13
+ def index
14
+ super do |format |
15
+ format . html { render body : "Rendered from passed block" }
16
+ end
14
17
end
15
18
end
16
19
end
20
+
21
+ it "should call block passed to overridden index" do
22
+ get :index
23
+ expect ( response . body ) . to eq "Rendered from passed block"
24
+ end
25
+
26
+ it "can CSV responses" do
27
+ get :index , format : :csv
28
+ expect ( response . header [ "Content-Type" ] ) . to eq "text/csv; charset=utf-8"
29
+ end
17
30
end
18
31
19
- it "should call block passed to overridden index" do
20
- get :index
21
- expect ( response . body ) . to eq "Rendered from passed block"
32
+ context "with the call alias method" do
33
+ before do
34
+ @controller . instance_eval do
35
+ def index
36
+ index! do
37
+ # Do nothing
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ it "can CSV responses" do
44
+ get :index , format : :csv
45
+ expect ( response . header [ "Content-Type" ] ) . to eq "text/csv; charset=utf-8"
46
+ end
22
47
end
23
48
end
You can’t perform that action at this time.
0 commit comments