|
116 | 116 | end |
117 | 117 | end |
118 | 118 |
|
119 | | - context "when prefix with trailing slash is specified" do |
| 119 | + describe "prefix option" do |
| 120 | + around do |e| |
| 121 | + JsRoutes::Utils.deprecator.silence do |
| 122 | + e.run |
| 123 | + end |
| 124 | + end |
120 | 125 |
|
121 | | - let(:_options) { {:prefix => "/myprefix/" } } |
| 126 | + context "with trailing slash is specified" do |
| 127 | + let(:_options) { {:prefix => "/myprefix/" } } |
122 | 128 |
|
123 | | - it "should render routing with prefix" do |
| 129 | + it "should render routing with prefix" do |
124 | 130 | expectjs("Routes.inbox_path(1)").to eq("/myprefix#{test_routes.inbox_path(1)}") |
125 | | - end |
| 131 | + end |
126 | 132 |
|
127 | | - it "should render routing with prefix set in JavaScript" do |
128 | | - evaljs("Routes.configure({prefix: '/newprefix/'})") |
129 | | - expectjs("Routes.config().prefix").to eq("/newprefix/") |
130 | | - expectjs("Routes.inbox_path(1)").to eq("/newprefix#{test_routes.inbox_path(1)}") |
| 133 | + it "should render routing with prefix set in JavaScript" do |
| 134 | + evaljs("Routes.configure({prefix: '/newprefix/'})") |
| 135 | + expectjs("Routes.config().prefix").to eq("/newprefix/") |
| 136 | + expectjs("Routes.inbox_path(1)").to eq("/newprefix#{test_routes.inbox_path(1)}") |
| 137 | + end |
131 | 138 | end |
132 | 139 |
|
133 | | - end |
134 | | - |
135 | | - context "when prefix with http:// is specified" do |
136 | | - |
137 | | - let(:_options) { {:prefix => "http://localhost:3000" } } |
| 140 | + context "with http:// is specified" do |
| 141 | + let(:_options) { {:prefix => "http://localhost:3000" } } |
138 | 142 |
|
139 | | - it "should render routing with prefix" do |
140 | | - expectjs("Routes.inbox_path(1)").to eq(_options[:prefix] + test_routes.inbox_path(1)) |
| 143 | + it "should render routing with prefix" do |
| 144 | + expectjs("Routes.inbox_path(1)").to eq(_options[:prefix] + test_routes.inbox_path(1)) |
| 145 | + end |
141 | 146 | end |
142 | | - end |
143 | 147 |
|
144 | | - context "when prefix without trailing slash is specified" do |
| 148 | + context "without trailing slash is specified" do |
| 149 | + let(:_options) { {:prefix => "/myprefix" } } |
145 | 150 |
|
146 | | - let(:_options) { {:prefix => "/myprefix" } } |
| 151 | + it "should render routing with prefix" do |
| 152 | + expectjs("Routes.inbox_path(1)").to eq("/myprefix#{test_routes.inbox_path(1)}") |
| 153 | + end |
147 | 154 |
|
148 | | - it "should render routing with prefix" do |
149 | | - expectjs("Routes.inbox_path(1)").to eq("/myprefix#{test_routes.inbox_path(1)}") |
| 155 | + it "should render routing with prefix set in JavaScript" do |
| 156 | + evaljs("Routes.configure({prefix: '/newprefix/'})") |
| 157 | + expectjs("Routes.inbox_path(1)").to eq("/newprefix#{test_routes.inbox_path(1)}") |
| 158 | + end |
150 | 159 | end |
151 | 160 |
|
152 | | - it "should render routing with prefix set in JavaScript" do |
153 | | - evaljs("Routes.configure({prefix: '/newprefix/'})") |
154 | | - expectjs("Routes.inbox_path(1)").to eq("/newprefix#{test_routes.inbox_path(1)}") |
| 161 | + context "combined with url links and default_url_options" do |
| 162 | + let(:_options) { { :prefix => "/api", :url_links => true, :default_url_options => {:host => 'example.com'} } } |
| 163 | + it "should generate path and url links" do |
| 164 | + expectjs("Routes.inbox_url(1)").to eq("http://example.com/api#{test_routes.inbox_path(1)}") |
| 165 | + end |
155 | 166 | end |
156 | | - |
157 | 167 | end |
158 | 168 |
|
159 | 169 | context "when default format is specified" do |
|
381 | 391 | end |
382 | 392 | end |
383 | 393 |
|
384 | | - context "with prefix option" do |
385 | | - let(:_options) { { :prefix => "/api", :url_links => true, :default_url_options => {:host => 'example.com'} } } |
386 | | - it "should generate path and url links" do |
387 | | - expectjs("Routes.inbox_url(1)").to eq("http://example.com/api#{test_routes.inbox_path(1)}") |
388 | | - end |
389 | | - end |
390 | | - |
391 | 394 | context "with compact option" do |
392 | 395 | let(:_options) { { :compact => true, :url_links => true, :default_url_options => {:host => 'example.com'} } } |
393 | 396 | it "does not affect url helpers" do |
|
0 commit comments