js-routes 2.2.4 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66ff94f5c78d966f76e2a9f47d1c838c757c3e243c37f03599b24c286b15b9b7
4
- data.tar.gz: c5803e4a35b99923769970149f07a6893a84c6343f10f76c8a89645974dce959
3
+ metadata.gz: d0fd81f6f8575bb26353c7e485f0551cc62420a266e22d5503739332b5762037
4
+ data.tar.gz: b84d4ad0f70f8e1f454bdd2c6fb8b77a316376b3407a3fd0b6c681d87b87ada9
5
5
  SHA512:
6
- metadata.gz: a34c75f950a02a6634687889e4072f7d88f37520a6dc2ba5bfd2ccbbb71962159a70170bf7ac55b22db45de2727f7c573dfce8c80debc33f34abbd9cb1132c1f
7
- data.tar.gz: 779b340c9dac721c8b427a16011ed961a05dde4d15594838649fb0860bac42e60344a682718a0b94f35f785350126ca59c7f739dac43cb47e0a7b84e45fa468a
6
+ metadata.gz: 23db2ecfc872d470727b60d7c63148aa15d9d5b76d6eaedbf7bbe5ee964ae5ca5abfb09f69199dd813fcd0b09b12d0920fcb0abf9b09a1bb2a6dbfbaf7884e75
7
+ data.tar.gz: faf0d713243b705277604493bdf2f5d9f61c5cd953ef9bcfbcd1f2d88fdfd850d27ed48e0740f0fa4c0f4492a310bec13d6a76fc070113703ab7e7750e812b0c
data/.eslintrc.js CHANGED
@@ -4,7 +4,7 @@
4
4
  'eslint:recommended',
5
5
  'plugin:@typescript-eslint/eslint-recommended',
6
6
  'plugin:@typescript-eslint/recommended',
7
- 'prettier/@typescript-eslint',
7
+ 'prettier',
8
8
  ],
9
9
  parser: '@typescript-eslint/parser',
10
10
  plugins: ['@typescript-eslint'],
@@ -0,0 +1,36 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby: ["2.7"]
15
+ gemfile:
16
+ - gemfiles/rails50_sprockets_3.gemfile
17
+ - gemfiles/rails51_sprockets_3.gemfile
18
+ - gemfiles/rails52_sprockets_3.gemfile
19
+ - gemfiles/rails70_sprockets_4.gemfile
20
+
21
+ env:
22
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby }}
28
+ - uses: actions/setup-node@v3
29
+ with:
30
+ node-version: "16"
31
+ - name: install dependencies
32
+ run: |
33
+ bundle install --jobs 3 --retry 3
34
+ yarn install
35
+ - name: test
36
+ run: bundle exec rake spec
data/Appraisals CHANGED
@@ -8,12 +8,10 @@ def define_appraisal(rails, version, sprockets)
8
8
  end
9
9
 
10
10
  [
11
- [:rails40, '4.0.13', [2, 3]],
12
- [:rails41, '4.1.16', [2, 3]],
13
- [:rails42, '4.2.9', [2, 3]],
14
11
  [:rails50, '5.0.5', [3]],
15
12
  [:rails51, '5.1.3', [3]],
16
- [:rails52, '5.2.3', [3]]
13
+ [:rails52, '5.2.3', [3]],
14
+ [:rails70, '7.0.3.1', [4]]
17
15
  ].each do |name, version, sprockets|
18
16
  define_appraisal(name, version, sprockets)
19
17
  end
data/CHANGELOG.md CHANGED
@@ -1,7 +1,9 @@
1
1
  ## master
2
2
 
3
+
3
4
  ## v2.2.5
4
5
 
6
+ * Upgraded eslint and prettier versions [#304](https://github.com/railsware/js-routes/issues/304)
5
7
  * Fix middleware generator [#300](https://github.com/railsware/js-routes/issues/300)
6
8
  * Support `params` special parameter
7
9
 
data/Readme.md CHANGED
@@ -1,10 +1,8 @@
1
1
  # JsRoutes
2
- [![Build Status](https://travis-ci.org/railsware/js-routes.svg?branch=master)](https://travis-ci.org/railsware/js-routes)
3
- [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Frailsware%2Fjs-routes.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Frailsware%2Fjs-routes?ref=badge_shield)
4
2
 
5
- Generates javascript file that defines all Rails named routes as javascript helpers
3
+ [![CI](https://github.com/railsware/js-routes/actions/workflows/ci.yml/badge.svg)](https://github.com/railsware/js-routes/actions/workflows/ci.yml)
6
4
 
7
- [UPGRADE TO 2.0](./VERSION_2_UPGRADE.md)
5
+ Generates javascript file that defines all Rails named routes as javascript helpers
8
6
 
9
7
  ## Intallation
10
8
 
@@ -54,12 +52,12 @@ Add the following to `config/environments/development.rb`:
54
52
  config.middleware.use(JsRoutes::Middleware)
55
53
  ```
56
54
 
57
- Use it in `app/javascript/packs/application.js`:
55
+ Use it in any JS file:
58
56
 
59
57
  ``` javascript
60
- import * as Routes from '../routes';
61
- // window.Routes = Routes;
62
- alert(Routes.post_path(1))
58
+ import {post_path} from '../routes';
59
+
60
+ alert(post_path(1))
63
61
  ```
64
62
 
65
63
  Upgrade `rake assets:precompile` to update js-routes files in `Rakefile`:
@@ -133,11 +131,12 @@ Create routes file `app/javascript/routes.js.erb`:
133
131
  <%= JsRoutes.generate() %>
134
132
  ```
135
133
 
136
- Use routes wherever you need them `app/javascript/packs/application.js`:
134
+ Use routes wherever you need them:
137
135
 
138
136
  ``` javascript
139
- import * as Routes from 'routes.js.erb';
140
- window.Routes = Routes;
137
+ import {post_path} from 'routes.js.erb';
138
+
139
+ alert(post_path(2));
141
140
  ```
142
141
 
143
142
  <div id='advanced-setup'></div>
@@ -175,14 +174,20 @@ You can manipulate the generated helper manually by injecting ruby into javascri
175
174
  export const routes = <%= JsRoutes.generate(module_type: nil, namespace: nil) %>
176
175
  ```
177
176
 
178
- If you want to generate the routes files outside of the asset pipeline, you can use `JsRoutes.generate!`:
177
+ If you want to generate the routes files manually with custom options, you can use `JsRoutes.generate!`:
179
178
 
180
179
  ``` ruby
181
180
  path = Rails.root.join("app/javascript")
182
181
 
183
- JsRoutes.generate!("#{path}/app_routes.js", exclude: [/^admin_/, /^api_/])
184
- JsRoutes.generate!("#{path}/adm_routes.js", include: /^admin_/)
185
- JsRoutes.generate!("#{path}/api_routes.js", include: /^api_/, default_url_options: {format: "json"})
182
+ JsRoutes.generate!(
183
+ "#{path}/app_routes.js", exclude: [/^admin_/, /^api_/]
184
+ )
185
+ JsRoutes.generate!(
186
+ "#{path}/adm_routes.js", include: /^admin_/
187
+ )
188
+ JsRoutes.generate!(
189
+ "#{path}/api_routes.js", include: /^api_/, default_url_options: {format: "json"}
190
+ )
186
191
  ```
187
192
 
188
193
  <div id='definitions'></div>
@@ -252,11 +257,12 @@ end
252
257
  Or dynamically in JavaScript, although only [Formatter Options](#formatter-options) are supported:
253
258
 
254
259
  ``` js
255
- import * as Routes from 'routes'
256
- Routes.configure({
260
+ import {configure, config} from 'routes'
261
+
262
+ configure({
257
263
  option: value
258
264
  });
259
- Routes.config(); // current config
265
+ config(); // current config
260
266
  ```
261
267
 
262
268
  ### Available Options
@@ -290,7 +296,7 @@ Options to configure JavaScript file generator. These options are only available
290
296
  * Note: generated URLs will first use the protocol, host, and port options specified in the route definition. Otherwise, the URL will be based on the option specified in the `default_url_options` config. If no default option has been set, then the URL will fallback to the current URL based on `window.location`.
291
297
  * `compact` - Remove `_path` suffix in path routes(`*_url` routes stay untouched if they were enabled)
292
298
  * Default: `false`
293
- * Sample route call when option is set to true: Routes.users() => `/users`
299
+ * Sample route call when option is set to true: `users() // => /users`
294
300
  * `application` - a key to specify which rails engine you want to generate routes too.
295
301
  * This option allows to only generate routes for a specific rails engine, that is mounted into routes instead of all Rails app routes
296
302
  * Default: `Rails.application`
@@ -323,41 +329,44 @@ Options to configure routes formatting. These options are available both in Ruby
323
329
  Configuration above will create a nice javascript file with `Routes` object that has all the rails routes available:
324
330
 
325
331
  ``` js
326
- import * as Routes from 'routes';
332
+ import {
333
+ user_path, user_project_path, company_path
334
+ } as Routes from 'routes';
327
335
 
328
- Routes.users_path()
336
+ users_path()
329
337
  // => "/users"
330
338
 
331
- Routes.user_path(1)
339
+ user_path(1)
332
340
  // => "/users/1"
333
341
 
334
- Routes.user_path(1, {format: 'json'})
342
+ user_path(1, {format: 'json'})
335
343
  // => "/users/1.json"
336
344
 
337
- Routes.user_path(1, {anchor: 'profile'})
345
+ user_path(1, {anchor: 'profile'})
338
346
  // => "/users/1#profile"
339
347
 
340
- Routes.new_user_project_path(1, {format: 'json'})
348
+ new_user_project_path(1, {format: 'json'})
341
349
  // => "/users/1/projects/new.json"
342
350
 
343
- Routes.user_project_path(1,2, {q: 'hello', custom: true})
351
+ user_project_path(1,2, {q: 'hello', custom: true})
344
352
  // => "/users/1/projects/2?q=hello&custom=true"
345
353
 
346
- Routes.user_project_path(1,2, {hello: ['world', 'mars']})
354
+ user_project_path(1,2, {hello: ['world', 'mars']})
347
355
  // => "/users/1/projects/2?hello%5B%5D=world&hello%5B%5D=mars"
348
356
 
349
357
  var google = {id: 1, name: "Google"};
350
- Routes.company_path(google)
358
+ company_path(google)
351
359
  // => "/companies/1"
352
360
 
353
361
  var google = {id: 1, name: "Google", to_param: "google"};
354
- Routes.company_path(google)
362
+ company_path(google)
355
363
  // => "/companies/google"
356
364
  ```
357
365
 
358
366
  In order to make routes helpers available globally:
359
367
 
360
368
  ``` js
369
+ import * as Routes from '../routes';
361
370
  jQuery.extend(window, Routes)
362
371
  ```
363
372
 
@@ -366,22 +375,18 @@ jQuery.extend(window, Routes)
366
375
  Possible to get `spec` of route by function `toString`:
367
376
 
368
377
  ```js
369
- Routes.users_path.toString() // => "/users(.:format)"
370
- Routes.user_path.toString() // => "/users/:id(.:format)"
371
- ```
372
-
373
- This function allow to get the same `spec` for route, if you will get string representation of the route function:
378
+ import {user_path, users_path} from '../routes'
374
379
 
375
- ```js
376
- '' + Routes.users_path // => "/users(.:format)", a string representation of the object
377
- '' + Routes.user_path // => "/users/:id(.:format)"
380
+ users_path.toString() // => "/users(.:format)"
381
+ user_path.toString() // => "/users/:id(.:format)"
378
382
  ```
379
383
 
384
+
380
385
  Route function also contain method `requiredParams` inside which returns required param names array:
381
386
 
382
387
  ```js
383
- Routes.users_path.requiredParams() // => []
384
- Routes.user_path.requiredParams() // => ['id']
388
+ users_path.requiredParams() // => []
389
+ user_path.requiredParams() // => ['id']
385
390
  ```
386
391
 
387
392
 
@@ -395,8 +400,10 @@ Sometimes the destinction between JS Hash and Object can not be found by JsRoute
395
400
  In this case you would need to pass a special key to help:
396
401
 
397
402
  ``` js
398
- Routes.company_project_path({company_id: 1, id: 2}) // => Not enough parameters
399
- Routes.company_project_path({company_id: 1, id: 2, _options: true}) // => "/companies/1/projects/2"
403
+ import {company_project_path} from '../routes'
404
+
405
+ company_project_path({company_id: 1, id: 2}) // => Not enough parameters
406
+ company_project_path({company_id: 1, id: 2, _options: true}) // => "/companies/1/projects/2"
400
407
  ```
401
408
 
402
409
 
@@ -417,7 +424,7 @@ import {
417
424
  inbox_message_path,
418
425
  inbox_attachment_path,
419
426
  user_path,
420
- } from 'routes.js.erb'
427
+ } from '../routes'
421
428
  ```
422
429
 
423
430
  Such import structure allows for moddern JS bundlers like [Webpack](https://webpack.js.org/) to only include explicitly imported routes into JS bundle file.
@@ -5,4 +5,4 @@ source "http://rubygems.org"
5
5
  gem "railties", "~> 5.0.5"
6
6
  gem "sprockets", "~> 3.0"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -5,4 +5,4 @@ source "http://rubygems.org"
5
5
  gem "railties", "~> 5.1.3"
6
6
  gem "sprockets", "~> 3.0"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -5,4 +5,4 @@ source "http://rubygems.org"
5
5
  gem "railties", "~> 5.2.3"
6
6
  gem "sprockets", "~> 3.0"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "railties", "~> 7.0.3.1"
6
+ gem "sprockets", "~> 4.0"
7
+
8
+ gemspec path: "../"
@@ -29,7 +29,8 @@ end
29
29
 
30
30
 
31
31
  class Engine < ::Rails::Engine
32
- if defined?(::Sprockets::Railtie)
32
+ def self.install_sprockets!
33
+ return if defined?(@installed_sprockets)
33
34
  require 'sprockets/version'
34
35
  v2 = Gem::Dependency.new('', ' ~> 2')
35
36
  vgte3 = Gem::Dependency.new('', ' >= 3')
@@ -58,6 +59,10 @@ class Engine < ::Rails::Engine
58
59
  raise StandardError, "Sprockets version #{sprockets_version} is not supported"
59
60
  end
60
61
  end
62
+ @installed_sprockets = true
63
+ end
64
+ if defined?(::Sprockets::Railtie)
65
+ install_sprockets!
61
66
  end
62
67
  end
63
68
  end
@@ -55,7 +55,7 @@ module JsRoutes
55
55
  'ROUTES_OBJECT' => routes_object,
56
56
  'RAILS_VERSION' => ActionPack.version,
57
57
  'DEPRECATED_GLOBBING_BEHAVIOR' => ActionPack::VERSION::MAJOR == 4 && ActionPack::VERSION::MINOR == 0,
58
-
58
+ 'DEPRECATED_FALSE_PARAMETER_BEHAVIOR' => ActionPack::VERSION::MAJOR < 7,
59
59
  'APP_CLASS' => application.class.to_s,
60
60
  'DEFAULT_URL_OPTIONS' => json(@configuration.default_url_options),
61
61
  'PREFIX' => json(@configuration.prefix),
@@ -1,3 +1,3 @@
1
1
  module JsRoutes
2
- VERSION = "2.2.4"
2
+ VERSION = "2.2.5"
3
3
  end
data/lib/routes.d.ts CHANGED
@@ -64,6 +64,7 @@ declare type ModuleType = "CJS" | "AMD" | "UMD" | "ESM" | "DTS" | "NIL";
64
64
  declare const RubyVariables: {
65
65
  PREFIX: string;
66
66
  DEPRECATED_GLOBBING_BEHAVIOR: boolean;
67
+ DEPRECATED_FALSE_PARAMETER_BEHAVIOR: boolean;
67
68
  SPECIAL_OPTIONS_KEY: string;
68
69
  DEFAULT_URL_OPTIONS: RouteParameters;
69
70
  SERIALIZER: Serializer;
data/lib/routes.js CHANGED
@@ -2,7 +2,10 @@
2
2
  * File generated by js-routes RubyVariables.GEM_VERSION
3
3
  * Based on Rails RubyVariables.RAILS_VERSION routes of RubyVariables.APP_CLASS
4
4
  */
5
- RubyVariables.WRAPPER(() => {
5
+ // eslint-disable-next-line
6
+ RubyVariables.WRAPPER(
7
+ // eslint-disable-next-line
8
+ () => {
6
9
  const hasProp = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
7
10
  let NodeTypes;
8
11
  (function (NodeTypes) {
@@ -176,7 +179,11 @@ RubyVariables.WRAPPER(() => {
176
179
  }
177
180
  path_identifier(object) {
178
181
  const result = this.unwrap_path_identifier(object);
179
- return this.is_nullable(result) || result === false ? "" : "" + result;
182
+ return this.is_nullable(result) ||
183
+ (RubyVariables.DEPRECATED_FALSE_PARAMETER_BEHAVIOR &&
184
+ result === false)
185
+ ? ""
186
+ : "" + result;
180
187
  }
181
188
  unwrap_path_identifier(object) {
182
189
  let result = object;
@@ -262,7 +269,7 @@ RubyVariables.WRAPPER(() => {
262
269
  return { keyword_parameters, query_parameters };
263
270
  }
264
271
  build_route(parts, required_params, default_options, route, absolute, args) {
265
- const { keyword_parameters, query_parameters, } = this.partition_parameters(parts, required_params, default_options, args);
272
+ const { keyword_parameters, query_parameters } = this.partition_parameters(parts, required_params, default_options, args);
266
273
  const missing_params = required_params.filter((param) => !hasProp(query_parameters, param) ||
267
274
  this.is_nullable(query_parameters[param]));
268
275
  if (missing_params.length) {
data/lib/routes.ts CHANGED
@@ -82,6 +82,7 @@ type ModuleType = "CJS" | "AMD" | "UMD" | "ESM" | "DTS" | "NIL";
82
82
  declare const RubyVariables: {
83
83
  PREFIX: string;
84
84
  DEPRECATED_GLOBBING_BEHAVIOR: boolean;
85
+ DEPRECATED_FALSE_PARAMETER_BEHAVIOR: boolean;
85
86
  SPECIAL_OPTIONS_KEY: string;
86
87
  DEFAULT_URL_OPTIONS: RouteParameters;
87
88
  SERIALIZER: Serializer;
@@ -96,7 +97,9 @@ declare const define:
96
97
 
97
98
  declare const module: { exports: any } | undefined;
98
99
 
100
+ // eslint-disable-next-line
99
101
  RubyVariables.WRAPPER(
102
+ // eslint-disable-next-line
100
103
  (): RouterExposedMethods => {
101
104
  const hasProp = (value: unknown, key: string) =>
102
105
  Object.prototype.hasOwnProperty.call(value, key);
@@ -223,7 +226,7 @@ RubyVariables.WRAPPER(
223
226
  "port",
224
227
  "protocol",
225
228
  ] as const;
226
- type ReservedOption = typeof ReservedOptions[any];
229
+ type ReservedOption = (typeof ReservedOptions)[any];
227
230
 
228
231
  class UtilsClass {
229
232
  configuration: Configuration = {
@@ -234,7 +237,7 @@ RubyVariables.WRAPPER(
234
237
  RubyVariables.SERIALIZER || this.default_serializer.bind(this),
235
238
  };
236
239
 
237
- default_serializer(value: any, prefix?: string | null): string {
240
+ default_serializer(value: unknown, prefix?: string | null): string {
238
241
  if (this.is_nullable(value)) {
239
242
  return "";
240
243
  }
@@ -293,14 +296,16 @@ RubyVariables.WRAPPER(
293
296
  }
294
297
  return {
295
298
  args: args.slice(0, args.length - 1),
296
- options: (last_el as any) as RouteOptions,
299
+ options: last_el as unknown as RouteOptions,
297
300
  };
298
301
  } else {
299
302
  return { args, options: {} };
300
303
  }
301
304
  }
302
305
 
303
- looks_like_serialized_model(object: any): object is ModelRouteParameter {
306
+ looks_like_serialized_model(
307
+ object: unknown
308
+ ): object is ModelRouteParameter {
304
309
  return (
305
310
  this.is_object(object) &&
306
311
  !(this.configuration.special_options_key in object) &&
@@ -310,11 +315,15 @@ RubyVariables.WRAPPER(
310
315
 
311
316
  path_identifier(object: QueryRouteParameter): string {
312
317
  const result = this.unwrap_path_identifier(object);
313
- return this.is_nullable(result) || result === false ? "" : "" + result;
318
+ return this.is_nullable(result) ||
319
+ (RubyVariables.DEPRECATED_FALSE_PARAMETER_BEHAVIOR &&
320
+ result === false)
321
+ ? ""
322
+ : "" + result;
314
323
  }
315
324
 
316
325
  unwrap_path_identifier(object: QueryRouteParameter): unknown {
317
- let result: any = object;
326
+ let result: unknown = object;
318
327
  if (!this.is_object(object)) {
319
328
  return object;
320
329
  }
@@ -411,15 +420,13 @@ RubyVariables.WRAPPER(
411
420
  absolute: boolean,
412
421
  args: OptionalRouteParameter[]
413
422
  ): string {
414
- const {
415
- keyword_parameters,
416
- query_parameters,
417
- } = this.partition_parameters(
418
- parts,
419
- required_params,
420
- default_options,
421
- args
422
- );
423
+ const { keyword_parameters, query_parameters } =
424
+ this.partition_parameters(
425
+ parts,
426
+ required_params,
427
+ default_options,
428
+ args
429
+ );
423
430
  const missing_params = required_params.filter(
424
431
  (param) =>
425
432
  !hasProp(query_parameters, param) ||
data/package.json CHANGED
@@ -12,13 +12,13 @@
12
12
  "dependencies": {
13
13
  "@typescript-eslint/eslint-plugin": "^4.9.0",
14
14
  "@typescript-eslint/parser": "^4.9.0",
15
- "eslint": "^7.14.0",
16
- "eslint-config-prettier": "^6.15.0",
17
- "eslint-plugin-import": "^2.22.1",
15
+ "eslint": "^8.35.0",
16
+ "eslint-config-prettier": "^8.7.0",
17
+ "eslint-plugin-import": "^2.27.5",
18
18
  "husky": "^4.3.0",
19
19
  "lint-staged": "^10.5.2",
20
20
  "pinst": "^2.1.1",
21
- "prettier": "^2.2.1"
21
+ "prettier": "^2.8.4"
22
22
  },
23
23
  "scripts": {
24
24
  "build": "tsc && yarn lint:fix",
@@ -31,7 +31,8 @@
31
31
  }
32
32
  },
33
33
  "lint-staged": {
34
- "./lib/routes.ts": ["yarn lint:fix" ]
34
+ "./lib/routes.ts": [
35
+ "yarn lint:fix"
36
+ ]
35
37
  }
36
-
37
38
  }
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe JsRoutes, "#serialize" do
4
4
 
5
5
  before(:each) do
6
- evaljs(JsRoutes.generate({module_type: nil, namespace: 'Routes'}))
6
+ evaljs(JsRoutes.generate(module_type: nil, namespace: 'Routes'))
7
7
  end
8
8
 
9
9
  it "should provide this method" do
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe JsRoutes, "compatibility with AMD/require.js" do
4
4
 
5
5
  before(:each) do
6
- evaljs("var global = this;", {force: true})
6
+ evaljs("var global = this;", force: true)
7
7
  evaljs("global.GlobalCheck = {};")
8
8
  evaljs("global.define = function (requirs, callback) { global.GlobalCheck['js-routes'] = callback.call(this); return global.GlobalCheck['js-routes']; };")
9
9
  evaljs("global.define.amd = { jQuery: true };")
@@ -25,7 +25,7 @@ describe JsRoutes, "compatibility with AMD/require.js" do
25
25
  };
26
26
  EOF
27
27
  evaljs(strRequire)
28
- evaljs(JsRoutes.generate({module_type: 'AMD'}))
28
+ evaljs(JsRoutes.generate(module_type: 'AMD'))
29
29
  end
30
30
 
31
31
  it "should working from require" do
@@ -64,6 +64,7 @@ declare type ModuleType = "CJS" | "AMD" | "UMD" | "ESM" | "DTS" | "NIL";
64
64
  declare const RubyVariables: {
65
65
  PREFIX: string;
66
66
  DEPRECATED_GLOBBING_BEHAVIOR: boolean;
67
+ DEPRECATED_FALSE_PARAMETER_BEHAVIOR: boolean;
67
68
  SPECIAL_OPTIONS_KEY: string;
68
69
  DEFAULT_URL_OPTIONS: RouteParameters;
69
70
  SERIALIZER: Serializer;
@@ -12,7 +12,7 @@ describe JsRoutes, "compatibility with DTS" do
12
12
  end
13
13
 
14
14
  let(:generated_js) do
15
- JsRoutes.generate({**OPTIONS, **extra_options})
15
+ JsRoutes.generate(**OPTIONS, **extra_options)
16
16
  end
17
17
 
18
18
  context "when file is generated" do
@@ -67,7 +67,7 @@ DOC
67
67
 
68
68
  before(:each) do
69
69
  FileUtils.rm_f(name)
70
- JsRoutes.generate!({:file => name})
70
+ JsRoutes.generate!(file: name)
71
71
  end
72
72
 
73
73
  after(:each) do
@@ -3,11 +3,11 @@ require 'spec_helper'
3
3
  describe JsRoutes, "options" do
4
4
 
5
5
  let(:generated_js) do
6
- JsRoutes.generate({
6
+ JsRoutes.generate(
7
7
  module_type: nil,
8
8
  namespace: 'Routes',
9
9
  **_options
10
- })
10
+ )
11
11
  end
12
12
 
13
13
  before(:each) do
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe JsRoutes, "compatibility with Rails" do
4
4
 
5
5
  let(:generated_js) do
6
- JsRoutes.generate({module_type: nil, namespace: 'Routes'})
6
+ JsRoutes.generate(module_type: nil, namespace: 'Routes')
7
7
  end
8
8
  before(:each) do
9
9
  evaljs(generated_js)
@@ -267,7 +267,9 @@ describe JsRoutes, "compatibility with Rails" do
267
267
  end
268
268
 
269
269
  it "treats false as absent optional part" do
270
- pending("https://github.com/rails/rails/issues/42280")
270
+ if Rails.version < "7.0"
271
+ pending("https://github.com/rails/rails/issues/42280")
272
+ end
271
273
  expectjs("Routes.things_path(false)").to eq(test_routes.things_path(false))
272
274
  end
273
275
 
@@ -4,7 +4,7 @@ require "spec_helper"
4
4
  describe JsRoutes, "compatibility with Rails" do
5
5
 
6
6
  let(:generated_js) do
7
- JsRoutes.generate({module_type: nil, namespace: 'Routes'})
7
+ JsRoutes.generate(module_type: nil, namespace: 'Routes')
8
8
  end
9
9
  before(:each) do
10
10
  evaljs(generated_js)