shakapacker 6.5.5 → 6.5.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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +11 -7
- data/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
- data/.github/workflows/ruby.yml +3 -1
- data/.gitignore +3 -3
- data/.rspec +1 -0
- data/CHANGELOG.md +18 -2
- data/CONTRIBUTING.md +11 -1
- data/Gemfile.development_dependencies +3 -1
- data/README.md +41 -8
- data/Rakefile +4 -5
- data/gemfiles/Gemfile-rails-edge +1 -1
- data/gemfiles/Gemfile-rails.5.2.x +1 -1
- data/gemfiles/Gemfile-rails.6.0.x +1 -1
- data/gemfiles/Gemfile-rails.6.1.x +1 -1
- data/gemfiles/Gemfile-rails.7.0.x +1 -1
- data/lib/install/template.rb +21 -16
- data/lib/tasks/webpacker/compile.rake +5 -10
- data/lib/webpacker/helper.rb +20 -9
- data/lib/webpacker/version.rb +1 -1
- data/package/rules/__tests__/__utils__/webpack.js +50 -0
- data/package/rules/__tests__/babel.js +63 -0
- data/package/rules/__tests__/esbuild.js +64 -0
- data/package/rules/__tests__/index.js +0 -4
- data/package/rules/__tests__/swc.js +64 -0
- data/package/rules/babel.js +3 -14
- data/package/rules/esbuild.js +2 -13
- data/package/rules/jscommon.js +26 -0
- data/package/rules/swc.js +2 -13
- data/package/utils/helpers.js +1 -1
- data/package.json +8 -2
- data/spec/command_spec.rb +114 -0
- data/spec/compiler_spec.rb +57 -0
- data/spec/compiler_strategy_spec.rb +20 -0
- data/spec/configuration_spec.rb +281 -0
- data/{test/dev_server_runner_test.rb → spec/dev_server_runner_spec.rb} +30 -40
- data/spec/dev_server_spec.rb +45 -0
- data/spec/digest_strategy_spec.rb +33 -0
- data/{test/engine_rake_tasks_test.rb → spec/engine_rake_tasks_spec.rb} +17 -9
- data/spec/env_spec.rb +21 -0
- data/{test → spec}/fixtures/beta_package-lock.v1.json +0 -0
- data/{test → spec}/fixtures/beta_package-lock.v2.json +0 -0
- data/{test → spec}/fixtures/beta_package.json +0 -0
- data/{test → spec}/fixtures/beta_yarn.v1.lock +0 -0
- data/{test → spec}/fixtures/beta_yarn.v2.lock +0 -0
- data/{test → spec}/fixtures/git_url_package-lock.v1.json +0 -0
- data/{test → spec}/fixtures/git_url_package-lock.v2.json +0 -0
- data/{test → spec}/fixtures/git_url_package.json +0 -0
- data/{test → spec}/fixtures/git_url_yarn.v1.lock +0 -0
- data/{test → spec}/fixtures/git_url_yarn.v2.lock +0 -0
- data/{test → spec}/fixtures/github_url_package-lock.v1.json +0 -0
- data/{test → spec}/fixtures/github_url_package-lock.v2.json +0 -0
- data/{test → spec}/fixtures/github_url_package.json +0 -0
- data/{test → spec}/fixtures/github_url_yarn.v1.lock +0 -0
- data/{test → spec}/fixtures/github_url_yarn.v2.lock +0 -0
- data/{test → spec}/fixtures/relative_path_package-lock.v1.json +0 -0
- data/{test → spec}/fixtures/relative_path_package-lock.v2.json +0 -0
- data/{test → spec}/fixtures/relative_path_package.json +0 -0
- data/{test → spec}/fixtures/relative_path_yarn.v1.lock +0 -0
- data/{test → spec}/fixtures/relative_path_yarn.v2.lock +0 -0
- data/{test → spec}/fixtures/semver_caret_package-lock.v1.json +0 -0
- data/{test → spec}/fixtures/semver_caret_package-lock.v2.json +0 -0
- data/{test → spec}/fixtures/semver_caret_package.json +0 -0
- data/{test → spec}/fixtures/semver_caret_yarn.v1.lock +0 -0
- data/{test → spec}/fixtures/semver_caret_yarn.v2.lock +0 -0
- data/{test → spec}/fixtures/semver_exact_package-lock.v1.json +0 -0
- data/{test → spec}/fixtures/semver_exact_package-lock.v2.json +0 -0
- data/{test → spec}/fixtures/semver_exact_package.json +0 -0
- data/{test → spec}/fixtures/semver_exact_yarn.v1.lock +0 -0
- data/{test → spec}/fixtures/semver_exact_yarn.v2.lock +0 -0
- data/{test → spec}/fixtures/semver_tilde_package-lock.v1.json +0 -0
- data/{test → spec}/fixtures/semver_tilde_package-lock.v2.json +0 -0
- data/{test → spec}/fixtures/semver_tilde_package.json +0 -0
- data/{test → spec}/fixtures/semver_tilde_yarn.v1.lock +0 -0
- data/{test → spec}/fixtures/semver_tilde_yarn.v2.lock +0 -0
- data/{test → spec}/fixtures/without_package-lock.v1.json +0 -0
- data/{test → spec}/fixtures/without_package-lock.v2.json +0 -0
- data/{test → spec}/fixtures/without_package.json +0 -0
- data/{test → spec}/fixtures/without_yarn.v1.lock +0 -0
- data/{test → spec}/fixtures/without_yarn.v2.lock +0 -0
- data/spec/helper_spec.rb +241 -0
- data/spec/manifest_spec.rb +98 -0
- data/{test → spec}/mounted_app/Rakefile +0 -0
- data/{test → spec}/mounted_app/test/dummy/Rakefile +0 -0
- data/{test → spec}/mounted_app/test/dummy/bin/rails +0 -0
- data/{test → spec}/mounted_app/test/dummy/bin/rake +0 -0
- data/{test → spec}/mounted_app/test/dummy/config/application.rb +0 -0
- data/{test → spec}/mounted_app/test/dummy/config/environment.rb +0 -0
- data/{test → spec}/mounted_app/test/dummy/config/webpacker.yml +0 -0
- data/{test → spec}/mounted_app/test/dummy/config.ru +0 -0
- data/{test → spec}/mounted_app/test/dummy/package.json +0 -0
- data/spec/mtime_strategy_spec.rb +53 -0
- data/spec/rake_tasks_spec.rb +32 -0
- data/spec/spec_helper.rb +123 -0
- data/{test → spec}/test_app/Rakefile +0 -0
- data/{test → spec}/test_app/app/packs/entrypoints/application.js +0 -0
- data/{test → spec}/test_app/app/packs/entrypoints/generated/something.js +0 -0
- data/{test → spec}/test_app/app/packs/entrypoints/multi_entry.css +0 -0
- data/{test → spec}/test_app/app/packs/entrypoints/multi_entry.js +0 -0
- data/{test → spec}/test_app/bin/webpacker +0 -0
- data/{test → spec}/test_app/bin/webpacker-dev-server +0 -0
- data/{test → spec}/test_app/config/application.rb +0 -0
- data/{test → spec}/test_app/config/environment.rb +0 -0
- data/{test → spec}/test_app/config/initializers/inspect_autoload_paths.rb +0 -0
- data/{test → spec}/test_app/config/webpack/webpack.config.js +0 -0
- data/{test → spec}/test_app/config/webpacker.yml +0 -0
- data/{test → spec}/test_app/config/webpacker_css_extract_ignore_order_warnings.yml +0 -0
- data/{test → spec}/test_app/config/webpacker_defaults_fallback.yml +0 -0
- data/{test → spec}/test_app/config/webpacker_manifest_path.yml +0 -0
- data/{test → spec}/test_app/config/webpacker_nested_entries.yml +0 -0
- data/{test → spec}/test_app/config/webpacker_no_precompile.yml +0 -0
- data/{test → spec}/test_app/config/webpacker_other_location.yml +0 -0
- data/{test → spec}/test_app/config/webpacker_public_root.yml +0 -0
- data/{test → spec}/test_app/config.ru +0 -0
- data/{test → spec}/test_app/package.json +0 -0
- data/{test → spec}/test_app/public/packs/manifest.json +8 -0
- data/{test → spec}/test_app/some.config.js +0 -0
- data/{test → spec}/test_app/yarn.lock +0 -0
- data/spec/version_checker_spec.rb +950 -0
- data/{test/webpack_runner_test.rb → spec/webpack_runner_spec.rb} +12 -15
- data/spec/webpacker_spec.rb +39 -0
- data/yarn.lock +846 -844
- metadata +102 -187
- data/.github/ISSUE_TEMPLATE/feature-request.md +0 -18
- data/lib/tasks/yarn.rake +0 -44
- data/test/command_test.rb +0 -109
- data/test/compiler_strategy_test.rb +0 -27
- data/test/compiler_test.rb +0 -60
- data/test/configuration_test.rb +0 -186
- data/test/dev_server_test.rb +0 -47
- data/test/digest_strategy_test.rb +0 -33
- data/test/env_test.rb +0 -23
- data/test/helper_test.rb +0 -248
- data/test/manifest_test.rb +0 -89
- data/test/mtime_strategy_test.rb +0 -42
- data/test/rake_tasks_test.rb +0 -37
- data/test/test_helper.rb +0 -33
- data/test/version_checker_test.rb +0 -826
- data/test/webpacker_test.rb +0 -49
data/test/configuration_test.rb
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
class ConfigurationTest < Webpacker::Test
|
|
4
|
-
def setup
|
|
5
|
-
@config = Webpacker::Configuration.new(
|
|
6
|
-
root_path: Pathname.new(File.expand_path("test_app", __dir__)),
|
|
7
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/webpacker.yml", __dir__)),
|
|
8
|
-
env: "production"
|
|
9
|
-
)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def test_source_path
|
|
13
|
-
source_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/packs").to_s
|
|
14
|
-
assert_equal source_path, @config.source_path.to_s
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_source_entry_path
|
|
18
|
-
source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/packs", "entrypoints").to_s
|
|
19
|
-
assert_equal @config.source_entry_path.to_s, source_entry_path
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def test_public_root_path
|
|
23
|
-
public_root_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public").to_s
|
|
24
|
-
assert_equal @config.public_path.to_s, public_root_path
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def test_public_output_path
|
|
28
|
-
public_output_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs").to_s
|
|
29
|
-
assert_equal @config.public_output_path.to_s, public_output_path
|
|
30
|
-
|
|
31
|
-
@public_root_config = Webpacker::Configuration.new(
|
|
32
|
-
root_path: @config.root_path,
|
|
33
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/webpacker_public_root.yml", __dir__)),
|
|
34
|
-
env: "production"
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
public_output_path = File.expand_path File.join(File.dirname(__FILE__), "public/packs").to_s
|
|
38
|
-
assert_equal @public_root_config.public_output_path.to_s, public_output_path
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def test_public_manifest_path
|
|
42
|
-
public_manifest_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s
|
|
43
|
-
assert_equal @config.public_manifest_path.to_s, public_manifest_path
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def test_manifest_path
|
|
47
|
-
manifest_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s
|
|
48
|
-
assert_equal @config.manifest_path.to_s, manifest_path
|
|
49
|
-
|
|
50
|
-
@manifest_config = Webpacker::Configuration.new(
|
|
51
|
-
root_path: @config.root_path,
|
|
52
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/webpacker_manifest_path.yml", __dir__)),
|
|
53
|
-
env: "production"
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
manifest_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/packs", "manifest.json").to_s
|
|
57
|
-
assert_equal @manifest_config.manifest_path.to_s, manifest_path
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def test_cache_path
|
|
61
|
-
cache_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/tmp/webpacker").to_s
|
|
62
|
-
assert_equal @config.cache_path.to_s, cache_path
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def test_additional_paths
|
|
66
|
-
assert_equal @config.additional_paths, ["app/assets", "/etc/yarn", "some.config.js", "app/elm"]
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def test_cache_manifest?
|
|
70
|
-
assert @config.cache_manifest?
|
|
71
|
-
|
|
72
|
-
with_rails_env("development") do
|
|
73
|
-
refute Webpacker.config.cache_manifest?
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
with_rails_env("test") do
|
|
77
|
-
refute Webpacker.config.cache_manifest?
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def test_compile?
|
|
82
|
-
refute @config.compile?
|
|
83
|
-
|
|
84
|
-
with_rails_env("development") do
|
|
85
|
-
assert Webpacker.config.compile?
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
with_rails_env("test") do
|
|
89
|
-
assert Webpacker.config.compile?
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def test_nested_entries?
|
|
94
|
-
refute @config.nested_entries?
|
|
95
|
-
|
|
96
|
-
with_rails_env("development") do
|
|
97
|
-
refute Webpacker.config.nested_entries?
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
with_rails_env("test") do
|
|
101
|
-
refute Webpacker.config.nested_entries?
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def test_ensure_consistent_versioning?
|
|
106
|
-
refute @config.ensure_consistent_versioning?
|
|
107
|
-
|
|
108
|
-
with_rails_env("development") do
|
|
109
|
-
assert Webpacker.config.ensure_consistent_versioning?
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
with_rails_env("test") do
|
|
113
|
-
refute Webpacker.config.ensure_consistent_versioning?
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def test_webpacker_precompile
|
|
118
|
-
assert @config.webpacker_precompile?
|
|
119
|
-
|
|
120
|
-
ENV["WEBPACKER_PRECOMPILE"] = "no"
|
|
121
|
-
refute Webpacker.config.webpacker_precompile?
|
|
122
|
-
|
|
123
|
-
ENV["WEBPACKER_PRECOMPILE"] = "yes"
|
|
124
|
-
assert Webpacker.config.webpacker_precompile?
|
|
125
|
-
|
|
126
|
-
ENV["WEBPACKER_PRECOMPILE"] = "false"
|
|
127
|
-
refute Webpacker.config.webpacker_precompile?
|
|
128
|
-
|
|
129
|
-
ENV["WEBPACKER_PRECOMPILE"] = "true"
|
|
130
|
-
assert Webpacker.config.webpacker_precompile?
|
|
131
|
-
|
|
132
|
-
ENV["WEBPACKER_PRECOMPILE"] = "n"
|
|
133
|
-
refute Webpacker.config.webpacker_precompile?
|
|
134
|
-
|
|
135
|
-
ENV["WEBPACKER_PRECOMPILE"] = "y"
|
|
136
|
-
assert Webpacker.config.webpacker_precompile?
|
|
137
|
-
|
|
138
|
-
ENV["WEBPACKER_PRECOMPILE"] = "f"
|
|
139
|
-
refute Webpacker.config.webpacker_precompile?
|
|
140
|
-
|
|
141
|
-
ENV["WEBPACKER_PRECOMPILE"] = "t"
|
|
142
|
-
assert Webpacker.config.webpacker_precompile?
|
|
143
|
-
|
|
144
|
-
@no_precompile_config = Webpacker::Configuration.new(
|
|
145
|
-
root_path: @config.root_path,
|
|
146
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/webpacker_no_precompile.yml", __dir__)),
|
|
147
|
-
env: "production"
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
assert @no_precompile_config.webpacker_precompile?
|
|
151
|
-
|
|
152
|
-
ENV["WEBPACKER_PRECOMPILE"] = nil
|
|
153
|
-
|
|
154
|
-
refute @no_precompile_config.webpacker_precompile?
|
|
155
|
-
|
|
156
|
-
@invalid_path_config = Webpacker::Configuration.new(
|
|
157
|
-
root_path: @config.root_path,
|
|
158
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/invalid_path.yml", __dir__)),
|
|
159
|
-
env: "default"
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
refute @invalid_path_config.webpacker_precompile?
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def test_fall_back_to_bundled_config_with_the_same_name_for_standard_environments
|
|
166
|
-
@no_default_config = Webpacker::Configuration.new(
|
|
167
|
-
root_path: @config.root_path,
|
|
168
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/webpacker_defaults_fallback.yml", __dir__)),
|
|
169
|
-
env: "default"
|
|
170
|
-
)
|
|
171
|
-
|
|
172
|
-
refute @no_default_config.cache_manifest? # fall back to "default" config from bundled file
|
|
173
|
-
refute @no_default_config.webpacker_precompile? # use "default" config from custom file
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
def test_fall_back_to_bundled_production_config_for_custom_environments
|
|
177
|
-
@no_env_config = Webpacker::Configuration.new(
|
|
178
|
-
root_path: @config.root_path,
|
|
179
|
-
config_path: Pathname.new(File.expand_path("./test_app/config/webpacker_defaults_fallback.yml", __dir__)),
|
|
180
|
-
env: "staging"
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
assert @no_env_config.cache_manifest? # fall back to "production" config from bundled file
|
|
184
|
-
refute @no_env_config.webpacker_precompile? # use "staging" config from custom file
|
|
185
|
-
end
|
|
186
|
-
end
|
data/test/dev_server_test.rb
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
class DevServerTest < Webpacker::Test
|
|
4
|
-
def test_running?
|
|
5
|
-
refute Webpacker.dev_server.running?
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def test_host
|
|
9
|
-
with_rails_env("development") do
|
|
10
|
-
assert_equal Webpacker.dev_server.host, "localhost"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def test_port
|
|
15
|
-
with_rails_env("development") do
|
|
16
|
-
assert_equal Webpacker.dev_server.port, 3035
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_https?
|
|
21
|
-
with_rails_env("development") do
|
|
22
|
-
assert_equal Webpacker.dev_server.https?, false
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_protocol
|
|
27
|
-
with_rails_env("development") do
|
|
28
|
-
assert_equal Webpacker.dev_server.protocol, "http"
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_host_with_port
|
|
33
|
-
with_rails_env("development") do
|
|
34
|
-
assert_equal Webpacker.dev_server.host_with_port, "localhost:3035"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def test_pretty?
|
|
39
|
-
with_rails_env("development") do
|
|
40
|
-
refute Webpacker.dev_server.pretty?
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def test_default_env_prefix
|
|
45
|
-
assert_equal Webpacker::DevServer::DEFAULT_ENV_PREFIX, "WEBPACKER_DEV_SERVER"
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
class DigestStrategyTest < Minitest::Test
|
|
4
|
-
def remove_compilation_digest_path
|
|
5
|
-
@digest_strategy.send(:compilation_digest_path).tap do |path|
|
|
6
|
-
path.delete if path.exist?
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def setup
|
|
11
|
-
@digest_strategy = Webpacker::DigestStrategy.new
|
|
12
|
-
remove_compilation_digest_path
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def teardown
|
|
16
|
-
remove_compilation_digest_path
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_freshness
|
|
20
|
-
assert @digest_strategy.stale?
|
|
21
|
-
assert !@digest_strategy.fresh?
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def test_freshness_after_compilation_hook
|
|
25
|
-
@digest_strategy.after_compile_hook
|
|
26
|
-
assert @digest_strategy.fresh?
|
|
27
|
-
assert !@digest_strategy.stale?
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def test_compilation_digest_path
|
|
31
|
-
assert_equal @digest_strategy.send(:compilation_digest_path).basename.to_s, "last-compilation-digest-#{Webpacker.env}"
|
|
32
|
-
end
|
|
33
|
-
end
|
data/test/env_test.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
class EnvTest < Webpacker::Test
|
|
4
|
-
def test_current
|
|
5
|
-
assert_equal Webpacker.env, Rails.env
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def test_custom_without_config
|
|
9
|
-
with_rails_env("foo") do
|
|
10
|
-
assert_equal Webpacker.env, "production"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def test_custom_with_config
|
|
15
|
-
with_rails_env("staging") do
|
|
16
|
-
assert_equal Webpacker.env, "staging"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_default
|
|
21
|
-
assert_equal Webpacker::DEFAULT_ENV, "production"
|
|
22
|
-
end
|
|
23
|
-
end
|
data/test/helper_test.rb
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
class HelperTest < ActionView::TestCase
|
|
4
|
-
tests Webpacker::Helper
|
|
5
|
-
|
|
6
|
-
attr_reader :request
|
|
7
|
-
|
|
8
|
-
def setup
|
|
9
|
-
@request = Class.new do
|
|
10
|
-
def send_early_hints(links) end
|
|
11
|
-
def base_url
|
|
12
|
-
"https://example.com"
|
|
13
|
-
end
|
|
14
|
-
end.new
|
|
15
|
-
|
|
16
|
-
@javascript_pack_tag_loaded = nil
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_asset_pack_path
|
|
20
|
-
assert_equal "/packs/bootstrap-300631c4f0e0f9c865bc.js", asset_pack_path("bootstrap.js")
|
|
21
|
-
assert_equal "/packs/bootstrap-c38deda30895059837cf.css", asset_pack_path("bootstrap.css")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def test_asset_pack_url
|
|
25
|
-
assert_equal "https://example.com/packs/bootstrap-300631c4f0e0f9c865bc.js", asset_pack_url("bootstrap.js")
|
|
26
|
-
assert_equal "https://example.com/packs/bootstrap-c38deda30895059837cf.css", asset_pack_url("bootstrap.css")
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def test_image_pack_path
|
|
30
|
-
assert_equal "/packs/application-k344a6d59eef8632c9d1.png", image_pack_path("application.png")
|
|
31
|
-
assert_equal "/packs/static/image-c38deda30895059837cf.jpg", image_pack_path("image.jpg")
|
|
32
|
-
assert_equal "/packs/static/image-c38deda30895059837cf.jpg", image_pack_path("static/image.jpg")
|
|
33
|
-
assert_equal "/packs/static/nested/image-c38deda30895059837cf.jpg", image_pack_path("nested/image.jpg")
|
|
34
|
-
assert_equal "/packs/static/nested/image-c38deda30895059837cf.jpg", image_pack_path("static/nested/image.jpg")
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def test_image_pack_url
|
|
38
|
-
assert_equal "https://example.com/packs/application-k344a6d59eef8632c9d1.png", image_pack_url("application.png")
|
|
39
|
-
assert_equal "https://example.com/packs/static/image-c38deda30895059837cf.jpg", image_pack_url("image.jpg")
|
|
40
|
-
assert_equal "https://example.com/packs/static/image-c38deda30895059837cf.jpg", image_pack_url("static/image.jpg")
|
|
41
|
-
assert_equal "https://example.com/packs/static/nested/image-c38deda30895059837cf.jpg", image_pack_url("nested/image.jpg")
|
|
42
|
-
assert_equal "https://example.com/packs/static/nested/image-c38deda30895059837cf.jpg", image_pack_url("static/nested/image.jpg")
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def test_image_pack_tag
|
|
46
|
-
assert_equal \
|
|
47
|
-
"<img alt=\"Edit Entry\" src=\"/packs/application-k344a6d59eef8632c9d1.png\" width=\"16\" height=\"10\" />",
|
|
48
|
-
image_pack_tag("application.png", size: "16x10", alt: "Edit Entry")
|
|
49
|
-
assert_equal \
|
|
50
|
-
"<img alt=\"Edit Entry\" src=\"/packs/static/image-c38deda30895059837cf.jpg\" width=\"16\" height=\"10\" />",
|
|
51
|
-
image_pack_tag("image.jpg", size: "16x10", alt: "Edit Entry")
|
|
52
|
-
assert_equal \
|
|
53
|
-
"<img alt=\"Edit Entry\" src=\"/packs/static/image-c38deda30895059837cf.jpg\" width=\"16\" height=\"10\" />",
|
|
54
|
-
image_pack_tag("static/image.jpg", size: "16x10", alt: "Edit Entry")
|
|
55
|
-
assert_equal \
|
|
56
|
-
"<img alt=\"Edit Entry\" src=\"/packs/static/nested/image-c38deda30895059837cf.jpg\" width=\"16\" height=\"10\" />",
|
|
57
|
-
image_pack_tag("nested/image.jpg", size: "16x10", alt: "Edit Entry")
|
|
58
|
-
assert_equal \
|
|
59
|
-
"<img alt=\"Edit Entry\" src=\"/packs/static/nested/image-c38deda30895059837cf.jpg\" width=\"16\" height=\"10\" />",
|
|
60
|
-
image_pack_tag("static/nested/image.jpg", size: "16x10", alt: "Edit Entry")
|
|
61
|
-
assert_equal \
|
|
62
|
-
"<img srcset=\"/packs/static/image-2x-7cca48e6cae66ec07b8e.jpg 2x\" src=\"/packs/static/image-c38deda30895059837cf.jpg\" />",
|
|
63
|
-
image_pack_tag("static/image.jpg", srcset: { "static/image-2x.jpg" => "2x" })
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def test_favicon_pack_tag
|
|
67
|
-
assert_equal \
|
|
68
|
-
"<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/application-k344a6d59eef8632c9d1.png\" />",
|
|
69
|
-
favicon_pack_tag("application.png", rel: "apple-touch-icon", type: "image/png")
|
|
70
|
-
assert_equal \
|
|
71
|
-
"<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/static/mb-icon-c38deda30895059837cf.png\" />",
|
|
72
|
-
favicon_pack_tag("mb-icon.png", rel: "apple-touch-icon", type: "image/png")
|
|
73
|
-
assert_equal \
|
|
74
|
-
"<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/static/mb-icon-c38deda30895059837cf.png\" />",
|
|
75
|
-
favicon_pack_tag("static/mb-icon.png", rel: "apple-touch-icon", type: "image/png")
|
|
76
|
-
assert_equal \
|
|
77
|
-
"<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/static/nested/mb-icon-c38deda30895059837cf.png\" />",
|
|
78
|
-
favicon_pack_tag("nested/mb-icon.png", rel: "apple-touch-icon", type: "image/png")
|
|
79
|
-
assert_equal \
|
|
80
|
-
"<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/static/nested/mb-icon-c38deda30895059837cf.png\" />",
|
|
81
|
-
favicon_pack_tag("static/nested/mb-icon.png", rel: "apple-touch-icon", type: "image/png")
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def test_preload_pack_asset
|
|
85
|
-
if self.class.method_defined?(:preload_link_tag)
|
|
86
|
-
assert_equal \
|
|
87
|
-
%(<link rel="preload" href="/packs/fonts/fa-regular-400-944fb546bd7018b07190a32244f67dc9.woff2" as="font" type="font/woff2" crossorigin="anonymous">),
|
|
88
|
-
preload_pack_asset("fonts/fa-regular-400.woff2")
|
|
89
|
-
else
|
|
90
|
-
error = assert_raises do
|
|
91
|
-
preload_pack_asset("fonts/fa-regular-400.woff2")
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
assert_equal \
|
|
95
|
-
"You need Rails >= 5.2 to use this tag.",
|
|
96
|
-
error.message
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def test_javascript_pack_tag
|
|
101
|
-
assert_equal \
|
|
102
|
-
%(<script src="/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js" defer="defer"></script>\n) +
|
|
103
|
-
%(<script src="/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js" defer="defer"></script>\n) +
|
|
104
|
-
%(<script src="/packs/application-k344a6d59eef8632c9d1.js" defer="defer"></script>\n) +
|
|
105
|
-
%(<script src="/packs/bootstrap-300631c4f0e0f9c865bc.js" defer="defer"></script>),
|
|
106
|
-
javascript_pack_tag("application", "bootstrap")
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def test_javascript_pack_with_no_defer_tag
|
|
110
|
-
assert_equal \
|
|
111
|
-
%(<script src="/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js"></script>\n) +
|
|
112
|
-
%(<script src="/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js"></script>\n) +
|
|
113
|
-
%(<script src="/packs/application-k344a6d59eef8632c9d1.js"></script>\n) +
|
|
114
|
-
%(<script src="/packs/bootstrap-300631c4f0e0f9c865bc.js"></script>),
|
|
115
|
-
javascript_pack_tag("application", "bootstrap", defer: false)
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def test_javascript_pack_with_append
|
|
119
|
-
append_javascript_pack_tag("bootstrap", defer: false)
|
|
120
|
-
assert_equal \
|
|
121
|
-
%(<script src="/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js" defer="defer"></script>\n) +
|
|
122
|
-
%(<script src="/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js" defer="defer"></script>\n) +
|
|
123
|
-
%(<script src="/packs/application-k344a6d59eef8632c9d1.js" defer="defer"></script>\n) +
|
|
124
|
-
%(<script src="/packs/bootstrap-300631c4f0e0f9c865bc.js"></script>),
|
|
125
|
-
javascript_pack_tag("application")
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def test_append_javascript_pack_tag_raises
|
|
129
|
-
error = assert_raises do
|
|
130
|
-
javascript_pack_tag("application")
|
|
131
|
-
append_javascript_pack_tag("bootstrap", defer: false)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
assert_equal \
|
|
135
|
-
"You can only call append_javascript_pack_tag before javascript_pack_tag helper. " +
|
|
136
|
-
"Please refer to https://github.com/shakacode/shakapacker/blob/master/README.md#view-helper-append_javascript_pack_tag-and-append_stylesheet_pack_tag for the usage guide",
|
|
137
|
-
error.message
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def test_javascript_pack_tag_splat
|
|
141
|
-
assert_equal \
|
|
142
|
-
%(<script src="/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js" defer="defer"></script>\n) +
|
|
143
|
-
%(<script src="/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js" defer="defer"></script>\n) +
|
|
144
|
-
%(<script src="/packs/application-k344a6d59eef8632c9d1.js" defer="defer"></script>),
|
|
145
|
-
javascript_pack_tag("application", defer: true)
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def test_javascript_pack_tag_symbol
|
|
149
|
-
assert_equal \
|
|
150
|
-
%(<script src="/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js" defer="defer"></script>\n) +
|
|
151
|
-
%(<script src="/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js" defer="defer"></script>\n) +
|
|
152
|
-
%(<script src="/packs/application-k344a6d59eef8632c9d1.js" defer="defer"></script>),
|
|
153
|
-
javascript_pack_tag(:application)
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def test_javascript_pack_tag_multiple_invocations
|
|
157
|
-
error = assert_raises do
|
|
158
|
-
javascript_pack_tag(:application)
|
|
159
|
-
javascript_pack_tag(:bootstrap)
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
assert_equal \
|
|
163
|
-
"To prevent duplicated chunks on the page, you should call javascript_pack_tag only once on the page. " +
|
|
164
|
-
"Please refer to https://github.com/shakacode/shakapacker/blob/master/README.md#view-helpers-javascript_pack_tag-and-stylesheet_pack_tag for the usage guide",
|
|
165
|
-
error.message
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
def application_stylesheet_chunks
|
|
169
|
-
%w[/packs/1-c20632e7baf2c81200d3.chunk.css /packs/application-k344a6d59eef8632c9d1.chunk.css]
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def hello_stimulus_stylesheet_chunks
|
|
173
|
-
%w[/packs/1-c20632e7baf2c81200d3.chunk.css /packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css]
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
def test_stylesheet_pack_tag
|
|
177
|
-
assert_equal \
|
|
178
|
-
(application_stylesheet_chunks + hello_stimulus_stylesheet_chunks).uniq
|
|
179
|
-
.map { |chunk| stylesheet_link_tag(chunk) }.join("\n"),
|
|
180
|
-
stylesheet_pack_tag("application", "hello_stimulus")
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
def test_stylesheet_pack_tag_symbol
|
|
184
|
-
assert_equal \
|
|
185
|
-
(application_stylesheet_chunks + hello_stimulus_stylesheet_chunks).uniq
|
|
186
|
-
.map { |chunk| stylesheet_link_tag(chunk) }.join("\n"),
|
|
187
|
-
stylesheet_pack_tag(:application, :hello_stimulus)
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
def test_stylesheet_pack_tag_splat
|
|
191
|
-
assert_equal \
|
|
192
|
-
(application_stylesheet_chunks).map { |chunk| stylesheet_link_tag(chunk, media: "all") }.join("\n"),
|
|
193
|
-
stylesheet_pack_tag("application", media: "all")
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def test_stylesheet_pack_tag_multiple_invocations_are_allowed
|
|
197
|
-
app_style = stylesheet_pack_tag(:application)
|
|
198
|
-
stimulus_style = stylesheet_pack_tag(:hello_stimulus)
|
|
199
|
-
|
|
200
|
-
assert_equal \
|
|
201
|
-
application_stylesheet_chunks.map { |chunk| stylesheet_link_tag(chunk) }.join("\n"),
|
|
202
|
-
app_style
|
|
203
|
-
|
|
204
|
-
assert_equal \
|
|
205
|
-
hello_stimulus_stylesheet_chunks.map { |chunk| stylesheet_link_tag(chunk) }.join("\n"),
|
|
206
|
-
stimulus_style
|
|
207
|
-
|
|
208
|
-
assert_nothing_raised do
|
|
209
|
-
stylesheet_pack_tag(:application)
|
|
210
|
-
stylesheet_pack_tag(:hello_stimulus)
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
def test_stylesheet_pack_with_append
|
|
215
|
-
append_stylesheet_pack_tag(:hello_stimulus)
|
|
216
|
-
|
|
217
|
-
assert_equal \
|
|
218
|
-
(application_stylesheet_chunks + hello_stimulus_stylesheet_chunks).uniq.map { |chunk| stylesheet_link_tag(chunk) }.join("\n"),
|
|
219
|
-
stylesheet_pack_tag(:application)
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
def test_stylesheet_pack_with_duplicate_append
|
|
223
|
-
append_stylesheet_pack_tag(:hello_stimulus)
|
|
224
|
-
append_stylesheet_pack_tag(:application)
|
|
225
|
-
|
|
226
|
-
assert_equal \
|
|
227
|
-
(application_stylesheet_chunks + hello_stimulus_stylesheet_chunks).uniq.map { |chunk| stylesheet_link_tag(chunk) }.join("\n"),
|
|
228
|
-
stylesheet_pack_tag(:application)
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
def test_multiple_stylesheet_pack_with_different_media_attr
|
|
232
|
-
app_style = stylesheet_pack_tag(:application)
|
|
233
|
-
app_style_with_media = stylesheet_pack_tag(:application, media: "print")
|
|
234
|
-
hello_stimulus_style_with_media = stylesheet_pack_tag(:hello_stimulus, media: "all")
|
|
235
|
-
|
|
236
|
-
assert_equal \
|
|
237
|
-
application_stylesheet_chunks.map { |chunk| stylesheet_link_tag(chunk) }.join("\n"),
|
|
238
|
-
app_style
|
|
239
|
-
|
|
240
|
-
assert_equal \
|
|
241
|
-
application_stylesheet_chunks.map { |chunk| stylesheet_link_tag(chunk, media: "print") }.join("\n"),
|
|
242
|
-
app_style_with_media
|
|
243
|
-
|
|
244
|
-
assert_equal \
|
|
245
|
-
hello_stimulus_stylesheet_chunks.map { |chunk| stylesheet_link_tag(chunk, media: "all") }.join("\n"),
|
|
246
|
-
hello_stimulus_style_with_media
|
|
247
|
-
end
|
|
248
|
-
end
|
data/test/manifest_test.rb
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
class ManifestTest < Minitest::Test
|
|
4
|
-
def test_lookup_exception!
|
|
5
|
-
asset_file = "calendar.js"
|
|
6
|
-
|
|
7
|
-
error = assert_raises_manifest_missing_entry_error do
|
|
8
|
-
Webpacker.manifest.lookup!(asset_file)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
assert_match "Shakapacker can't find #{asset_file} in #{manifest_path}", error.message
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def test_lookup_with_type_exception!
|
|
15
|
-
asset_file = "calendar"
|
|
16
|
-
|
|
17
|
-
error = assert_raises_manifest_missing_entry_error do
|
|
18
|
-
Webpacker.manifest.lookup!(asset_file, type: :javascript)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
assert_match "Shakapacker can't find #{asset_file}.js in #{manifest_path}", error.message
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def test_lookup_success!
|
|
25
|
-
assert_equal Webpacker.manifest.lookup!("bootstrap.js"), "/packs/bootstrap-300631c4f0e0f9c865bc.js"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def test_lookup_with_chunks_without_extension_success!
|
|
29
|
-
assert_equal ["/packs/bootstrap-300631c4f0e0f9c865bc.js"], Webpacker.manifest.lookup_pack_with_chunks!("bootstrap", type: :javascript)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_lookup_with_chunks_with_extension_success!
|
|
33
|
-
assert_equal ["/packs/bootstrap-300631c4f0e0f9c865bc.js"], Webpacker.manifest.lookup_pack_with_chunks!("bootstrap.js", type: :javascript)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def test_lookup_with_chunks_without_extension_subdir_success!
|
|
37
|
-
assert_equal ["/packs/print/application-983b6c164a47f7ed49cd.css"], Webpacker.manifest.lookup_pack_with_chunks!("print/application", type: :css)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def test_lookup_with_chunks_with_extension_subdir_success!
|
|
41
|
-
assert_equal ["/packs/print/application-983b6c164a47f7ed49cd.css"], Webpacker.manifest.lookup_pack_with_chunks!("print/application.css", type: :css)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def test_lookup_nil
|
|
45
|
-
assert_nil Webpacker.manifest.lookup("foo.js")
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def test_lookup_chunks_nil
|
|
49
|
-
assert_nil Webpacker.manifest.lookup_pack_with_chunks("foo.js")
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def test_lookup_success
|
|
53
|
-
assert_equal Webpacker.manifest.lookup("bootstrap.js"), "/packs/bootstrap-300631c4f0e0f9c865bc.js"
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def test_lookup_entrypoint_exception!
|
|
57
|
-
asset_file = "calendar"
|
|
58
|
-
|
|
59
|
-
error = assert_raises_manifest_missing_entry_error do
|
|
60
|
-
Webpacker.manifest.lookup_pack_with_chunks!(asset_file, type: :javascript)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
assert_match "Shakapacker can't find #{asset_file}.js in #{manifest_path}", error.message
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def test_lookup_entrypoint
|
|
67
|
-
application_entrypoints = [
|
|
68
|
-
"/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js",
|
|
69
|
-
"/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js",
|
|
70
|
-
"/packs/application-k344a6d59eef8632c9d1.js"
|
|
71
|
-
]
|
|
72
|
-
|
|
73
|
-
assert_equal Webpacker.manifest.lookup_pack_with_chunks!("application", type: :javascript), application_entrypoints
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
private
|
|
77
|
-
|
|
78
|
-
def assert_raises_manifest_missing_entry_error(&block)
|
|
79
|
-
error = nil
|
|
80
|
-
Webpacker.config.stub :compile?, false do
|
|
81
|
-
error = assert_raises Webpacker::Manifest::MissingEntryError, &block
|
|
82
|
-
end
|
|
83
|
-
error
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def manifest_path
|
|
87
|
-
File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s
|
|
88
|
-
end
|
|
89
|
-
end
|
data/test/mtime_strategy_test.rb
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
class MtimeStrategyTest < Minitest::Test
|
|
4
|
-
def setup
|
|
5
|
-
@mtime_strategy = Webpacker::MtimeStrategy.new
|
|
6
|
-
@manifest_timestamp = Time.parse("2021-01-01 12:34:56 UTC")
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def with_stubs(latest_timestamp:, manifest_exists: true)
|
|
10
|
-
@mtime_strategy.stub :latest_modified_timestamp, latest_timestamp do
|
|
11
|
-
FileTest.stub :exist?, manifest_exists do
|
|
12
|
-
File.stub :mtime, @manifest_timestamp do
|
|
13
|
-
yield
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_freshness_when_manifest_missing
|
|
20
|
-
latest_timestamp = @manifest_timestamp + 3600
|
|
21
|
-
|
|
22
|
-
with_stubs(latest_timestamp: latest_timestamp.to_i, manifest_exists: false) do
|
|
23
|
-
assert @mtime_strategy.stale?
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def test_freshness_when_manifest_older
|
|
28
|
-
latest_timestamp = @manifest_timestamp + 3600
|
|
29
|
-
|
|
30
|
-
with_stubs(latest_timestamp: latest_timestamp.to_i) do
|
|
31
|
-
assert @mtime_strategy.stale?
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def test_freshness_when_manifest_newer
|
|
36
|
-
latest_timestamp = @manifest_timestamp - 3600
|
|
37
|
-
|
|
38
|
-
with_stubs(latest_timestamp: latest_timestamp.to_i) do
|
|
39
|
-
assert @mtime_strategy.fresh?
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|