js-routes 2.2.4 → 2.2.6

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.js +1 -1
  3. data/.github/workflows/ci.yml +36 -0
  4. data/Appraisals +2 -4
  5. data/CHANGELOG.md +6 -0
  6. data/Readme.md +54 -46
  7. data/gemfiles/rails50_sprockets_3.gemfile +1 -1
  8. data/gemfiles/rails51_sprockets_3.gemfile +1 -1
  9. data/gemfiles/rails52_sprockets_3.gemfile +1 -1
  10. data/gemfiles/rails70_sprockets_4.gemfile +8 -0
  11. data/lib/js_routes/engine.rb +6 -1
  12. data/lib/js_routes/generators/base.rb +16 -0
  13. data/lib/js_routes/generators/middleware.rb +9 -8
  14. data/lib/js_routes/generators/webpacker.rb +3 -1
  15. data/lib/js_routes/instance.rb +1 -1
  16. data/lib/js_routes/version.rb +1 -1
  17. data/lib/routes.d.ts +1 -0
  18. data/lib/routes.js +10 -3
  19. data/lib/routes.ts +22 -15
  20. data/package.json +7 -6
  21. data/spec/js_routes/default_serializer_spec.rb +1 -1
  22. data/spec/js_routes/module_types/amd_spec.rb +2 -2
  23. data/spec/js_routes/module_types/dts/routes.spec.d.ts +1 -0
  24. data/spec/js_routes/module_types/dts_spec.rb +1 -1
  25. data/spec/js_routes/module_types/umd_spec.rb +1 -1
  26. data/spec/js_routes/options_spec.rb +2 -2
  27. data/spec/js_routes/rails_routes_compatibility_spec.rb +4 -2
  28. data/spec/js_routes/route_specification_spec.rb +1 -1
  29. data/spec/js_routes/zzz_last_post_rails_init_spec.rb +8 -2
  30. data/spec/spec_helper.rb +1 -5
  31. data/yarn.lock +760 -448
  32. metadata +6 -10
  33. data/.travis.yml +0 -67
  34. data/gemfiles/rails40_sprockets_2.gemfile +0 -8
  35. data/gemfiles/rails40_sprockets_3.gemfile +0 -8
  36. data/gemfiles/rails41_sprockets_2.gemfile +0 -8
  37. data/gemfiles/rails41_sprockets_3.gemfile +0 -8
  38. data/gemfiles/rails42_sprockets_2.gemfile +0 -8
  39. data/gemfiles/rails42_sprockets_3.gemfile +0 -8
@@ -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)
@@ -2,6 +2,8 @@
2
2
  # because it cause unrevertable changes to runtime
3
3
  # what is why I added "zzz_last" in the beginning
4
4
 
5
+ require "sprockets"
6
+ require "sprockets/railtie"
5
7
  require 'spec_helper'
6
8
  require "fileutils"
7
9
 
@@ -12,6 +14,10 @@ describe "after Rails initialization", :slow do
12
14
  Sprockets::VERSION.to_i >= 3
13
15
  end
14
16
 
17
+ def sprockets_v4?
18
+ Sprockets::VERSION.to_i >= 4
19
+ end
20
+
15
21
  def sprockets_context(environment, name, filename)
16
22
  if sprockets_v3?
17
23
  Sprockets::Context.new(environment: environment, name: name, filename: filename.to_s, metadata: {})
@@ -35,6 +41,7 @@ describe "after Rails initialization", :slow do
35
41
  end
36
42
 
37
43
  before(:all) do
44
+ JsRoutes::Engine.install_sprockets!
38
45
  Rails.configuration.eager_load = false
39
46
  Rails.application.initialize!
40
47
  end
@@ -73,7 +80,7 @@ describe "after Rails initialization", :slow do
73
80
  context "the preprocessor" do
74
81
  before(:each) do
75
82
  path = Rails.root.join('config','routes.rb').to_s
76
- if sprockets_v3?
83
+ if sprockets_v3? || sprockets_v4?
77
84
  expect_any_instance_of(Sprockets::Context).to receive(:depend_on).with(path)
78
85
  else
79
86
  expect(ctx).to receive(:depend_on).with(path)
@@ -86,7 +93,6 @@ describe "after Rails initialization", :slow do
86
93
  end
87
94
 
88
95
  context "when dealing with js-routes.js" do
89
-
90
96
  context "with Rails" do
91
97
  context "and initialize on precompile" do
92
98
  before(:each) do
data/spec/spec_helper.rb CHANGED
@@ -7,7 +7,7 @@ require 'rails/all'
7
7
  require 'js-routes'
8
8
  require 'active_support/core_ext/hash/slice'
9
9
 
10
- unless ENV['TRAVIS_CI']
10
+ unless ENV['CI']
11
11
  code = system("yarn build")
12
12
  unless code
13
13
  exit(1)
@@ -94,10 +94,6 @@ end
94
94
 
95
95
 
96
96
  class ::App < Rails::Application
97
- # Enable the asset pipeline
98
- config.assets.enabled = true
99
- # initialize_on_precompile
100
- config.assets.initialize_on_precompile = true
101
97
  config.paths['config/routes.rb'] << 'spec/config/routes.rb'
102
98
  config.root = File.expand_path('../dummy', __FILE__)
103
99
  end