js-routes 2.2.4 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.js +1 -1
- data/.github/workflows/ci.yml +36 -0
- data/Appraisals +2 -4
- data/CHANGELOG.md +6 -0
- data/Readme.md +54 -46
- data/gemfiles/rails50_sprockets_3.gemfile +1 -1
- data/gemfiles/rails51_sprockets_3.gemfile +1 -1
- data/gemfiles/rails52_sprockets_3.gemfile +1 -1
- data/gemfiles/rails70_sprockets_4.gemfile +8 -0
- data/lib/js_routes/engine.rb +6 -1
- data/lib/js_routes/generators/base.rb +16 -0
- data/lib/js_routes/generators/middleware.rb +9 -8
- data/lib/js_routes/generators/webpacker.rb +3 -1
- data/lib/js_routes/instance.rb +1 -1
- data/lib/js_routes/version.rb +1 -1
- data/lib/routes.d.ts +1 -0
- data/lib/routes.js +10 -3
- data/lib/routes.ts +22 -15
- data/package.json +7 -6
- data/spec/js_routes/default_serializer_spec.rb +1 -1
- data/spec/js_routes/module_types/amd_spec.rb +2 -2
- data/spec/js_routes/module_types/dts/routes.spec.d.ts +1 -0
- data/spec/js_routes/module_types/dts_spec.rb +1 -1
- data/spec/js_routes/module_types/umd_spec.rb +1 -1
- data/spec/js_routes/options_spec.rb +2 -2
- data/spec/js_routes/rails_routes_compatibility_spec.rb +4 -2
- data/spec/js_routes/route_specification_spec.rb +1 -1
- data/spec/js_routes/zzz_last_post_rails_init_spec.rb +8 -2
- data/spec/spec_helper.rb +1 -5
- data/yarn.lock +760 -448
- metadata +6 -10
- data/.travis.yml +0 -67
- data/gemfiles/rails40_sprockets_2.gemfile +0 -8
- data/gemfiles/rails40_sprockets_3.gemfile +0 -8
- data/gemfiles/rails41_sprockets_2.gemfile +0 -8
- data/gemfiles/rails41_sprockets_3.gemfile +0 -8
- data/gemfiles/rails42_sprockets_2.gemfile +0 -8
- data/gemfiles/rails42_sprockets_3.gemfile +0 -8
@@ -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(
|
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
|
-
|
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(
|
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['
|
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
|