|
7 | 7 |
|
8 | 8 | context "using default configuration" do
|
9 | 9 | describe "on GET to /pages/exists" do
|
10 |
| - before { get :show, id: "exists" } |
| 10 | + before { get :show, params: { id: "exists" } } |
11 | 11 |
|
12 | 12 | it "responds with success and render template" do
|
13 | 13 | expect(response).to be_successful
|
|
20 | 20 | end
|
21 | 21 |
|
22 | 22 | describe "on GET to /pages/dir/nested" do
|
23 |
| - before { get :show, id: "dir/nested" } |
| 23 | + before { get :show, params: { id: "dir/nested" } } |
24 | 24 |
|
25 | 25 | it "responds with success and render template" do
|
26 | 26 | expect(response).to be_successful
|
|
29 | 29 | end
|
30 | 30 |
|
31 | 31 | it "raises a routing error for an invalid page" do
|
32 |
| - expect { get :show, id: "invalid" }. |
| 32 | + expect { get :show, params: { id: "invalid" } }. |
33 | 33 | to raise_error(ActionController::RoutingError)
|
34 | 34 | end
|
35 | 35 |
|
36 | 36 | it "raises a routing error for a page in another directory" do
|
37 |
| - expect { get :show, id: "../other/wrong" }. |
| 37 | + expect { get :show, params: { id: "../other/wrong" } }. |
38 | 38 | to raise_error(ActionController::RoutingError)
|
39 | 39 | end
|
40 | 40 |
|
41 | 41 | it "raises a missing template error for valid page with invalid partial" do
|
42 |
| - expect { get :show, id: "exists_but_references_nonexistent_partial" }. |
| 42 | + expect { nonexistent_partial_request }. |
43 | 43 | to raise_error(ActionView::MissingTemplate)
|
44 | 44 | end
|
| 45 | + |
| 46 | + def nonexistent_partial_request |
| 47 | + get :show, params: { |
| 48 | + id: "exists_but_references_nonexistent_partial", |
| 49 | + } |
| 50 | + end |
45 | 51 | end
|
46 | 52 |
|
47 | 53 | context "using custom layout" do
|
|
50 | 56 | end
|
51 | 57 |
|
52 | 58 | describe "on GET to /pages/exists" do
|
53 |
| - before { get :show, id: "exists" } |
| 59 | + before { get :show, params: { id: "exists" } } |
54 | 60 |
|
55 | 61 | it "uses the custom configured layout" do
|
56 | 62 | expect(response).not_to render_template("layouts/application")
|
|
66 | 72 | end
|
67 | 73 |
|
68 | 74 | describe "on GET to /other_pages/also_exists" do
|
69 |
| - before { get :show, id: "also_exists" } |
| 75 | + before { get :show, params: { id: "also_exists" } } |
70 | 76 |
|
71 | 77 | it "responds with success and render template" do
|
72 | 78 | expect(response).to be_successful
|
|
75 | 81 | end
|
76 | 82 |
|
77 | 83 | describe "on GET to /other_pages/also_dir/nested" do
|
78 |
| - before { get :show, id: "also_dir/also_nested" } |
| 84 | + before { get :show, params: { id: "also_dir/also_nested" } } |
79 | 85 |
|
80 | 86 | it "responds with success and render template" do
|
81 | 87 | expect(response).to be_successful
|
|
84 | 90 | end
|
85 | 91 |
|
86 | 92 | it "raises a routing error for an invalid page" do
|
87 |
| - expect { get :show, id: "also_invalid" }. |
| 93 | + expect { get :show, params: { id: "also_invalid" } }. |
88 | 94 | to raise_error(ActionController::RoutingError)
|
89 | 95 |
|
90 |
| - expect { get :show, id: "√®ø" }. |
| 96 | + expect { get :show, params: { id: "√®ø" } }. |
91 | 97 | to raise_error(ActionController::RoutingError)
|
92 | 98 | end
|
93 | 99 |
|
94 | 100 | context "page in another directory" do
|
95 | 101 | it "raises a routing error" do
|
96 |
| - expect { get :show, id: "../other_wrong" }. |
| 102 | + expect { get :show, params: { id: "../other_wrong" } }. |
97 | 103 | to raise_error(ActionController::RoutingError)
|
98 | 104 | end
|
99 | 105 |
|
100 | 106 | it "raises a routing error when using a Unicode exploit" do
|
101 |
| - expect { get :show, id: "/\\../other/wrong" }. |
| 107 | + expect { get :show, params: { id: "/\\../other/wrong" } }. |
102 | 108 | to raise_error(ActionController::RoutingError)
|
103 | 109 | end
|
104 | 110 | end
|
105 | 111 |
|
106 | 112 | it "raises a missing template error for valid page with invalid partial" do
|
107 | 113 | id = "also_exists_but_references_nonexistent_partial"
|
108 | 114 |
|
109 |
| - expect { get :show, id: id }. |
| 115 | + expect { get :show, params: { id: id } }. |
110 | 116 | to raise_error(ActionView::MissingTemplate)
|
111 | 117 | end
|
112 | 118 | end
|
|
0 commit comments