|
6 | 6 | evaljs(_presetup) if _presetup
|
7 | 7 | with_warnings(_warnings) do
|
8 | 8 | evaljs(JsRoutes.generate(_options))
|
| 9 | + App.routes.default_url_options = _options[:default_url_options] || {} |
9 | 10 | end
|
10 | 11 | end
|
11 | 12 |
|
| 13 | + after(:each) do |
| 14 | + App.routes.default_url_options = {} |
| 15 | + end |
| 16 | + |
12 | 17 | let(:_presetup) { nil }
|
13 | 18 | let(:_options) { {} }
|
14 | 19 | let(:_warnings) { true }
|
|
135 | 140 | let(:_warnings) { nil }
|
136 | 141 |
|
137 | 142 | it "should render routing with default_format" do
|
138 |
| - expect(evaljs("Routes.inbox_path(1)")).to eq(test_routes.inbox_path(1, :format => "json")) |
| 143 | + expect(evaljs("Routes.inbox_path(1)")).to eq(test_routes.inbox_path(1)) |
139 | 144 | end
|
140 | 145 |
|
141 | 146 | it "should render routing with default_format and zero object" do
|
142 |
| - expect(evaljs("Routes.inbox_path(0)")).to eq(test_routes.inbox_path(0, :format => "json")) |
| 147 | + expect(evaljs("Routes.inbox_path(0)")).to eq(test_routes.inbox_path(0)) |
143 | 148 | end
|
144 | 149 |
|
145 | 150 | it "should override default_format when spefified implicitly" do
|
146 | 151 | expect(evaljs("Routes.inbox_path(1, {format: 'xml'})")).to eq(test_routes.inbox_path(1, :format => "xml"))
|
147 | 152 | end
|
148 | 153 |
|
149 | 154 | it "should override nullify implicitly when specified implicitly" do
|
150 |
| - expect(evaljs("Routes.inbox_path(1, {format: null})")).to eq(test_routes.inbox_path(1)) |
| 155 | + expect(evaljs("Routes.inbox_path(1, {format: null})")).to eq(test_routes.inbox_path(1, format: nil)) |
151 | 156 | end
|
152 | 157 |
|
153 | 158 |
|
154 | 159 | it "shouldn't require the format" do
|
155 | 160 | pending if Rails.version < "4.0"
|
156 |
| - expect(evaljs("Routes.json_only_path()")).to eq(test_routes.json_only_path(:format => 'json')) |
| 161 | + expect(evaljs("Routes.json_only_path()")).to eq(test_routes.json_only_path) |
157 | 162 | end
|
158 | 163 | end
|
159 | 164 |
|
|
201 | 206 | context "provided" do
|
202 | 207 | let(:_options) { { :default_url_options => { :optional_id => "12", :format => "json" } } }
|
203 | 208 | it "should use this opions to fill optional parameters" do
|
204 |
| - expect(evaljs("Routes.things_path()")).to eq(test_routes.things_path(:optional_id => 12, :format => "json")) |
| 209 | + expect(evaljs("Routes.things_path()")).to eq(test_routes.things_path) |
205 | 210 | end
|
206 | 211 | end
|
207 | 212 |
|
208 | 213 | context "not provided" do
|
209 | 214 | let(:_options) { { :default_url_options => { :format => "json" } } }
|
210 | 215 | it "breaks" do
|
211 |
| - expect(evaljs("Routes.foo_all_path()")).to eq(test_routes.foo_all_path(:format => "json")) |
| 216 | + expect(evaljs("Routes.foo_all_path()")).to eq(test_routes.foo_all_path) |
212 | 217 | end
|
213 | 218 | end
|
214 | 219 | end
|
215 | 220 |
|
216 | 221 | context "with required route parts" do
|
217 | 222 | let(:_options) { {:default_url_options => {:inbox_id => "12"}} }
|
218 | 223 | it "should use this opions to fill optional parameters" do
|
219 |
| - expect(evaljs("Routes.inbox_messages_path()")).to eq(test_routes.inbox_messages_path(:inbox_id => 12)) |
| 224 | + expect(evaljs("Routes.inbox_messages_path()")).to eq(test_routes.inbox_messages_path) |
220 | 225 | end
|
221 | 226 | end
|
222 | 227 |
|
|
248 | 253 | end
|
249 | 254 |
|
250 | 255 | it "should remove it by params" do
|
251 |
| - expect(evaljs("Routes.inbox_path(1, {trailing_slash: false})")).to eq(test_routes.inbox_path(1)) |
| 256 | + expect(evaljs("Routes.inbox_path(1, {trailing_slash: false})")).to eq(test_routes.inbox_path(1, trailing_slash: false)) |
252 | 257 | end
|
253 | 258 | end
|
254 | 259 |
|
|
0 commit comments