actionpack-page_caching 1.2.4 → 1.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 +4 -4
- data/.github/workflows/ci.yml +38 -31
- data/CHANGELOG.md +6 -0
- data/actionpack-page_caching.gemspec +1 -1
- data/gemfiles/Gemfile-7-0-stable +5 -0
- data/gemfiles/Gemfile-7-1-stable +5 -0
- data/gemfiles/Gemfile-7-2-stable +5 -0
- data/gemfiles/Gemfile-8-0-stable +5 -0
- data/gemfiles/Gemfile-8-1-stable +5 -0
- data/lib/action_controller/caching/pages.rb +3 -2
- data/test/caching_test.rb +23 -3
- data/test/instrumentation_test.rb +63 -0
- metadata +10 -13
- data/gemfiles/Gemfile-4-2-stable +0 -5
- data/gemfiles/Gemfile-5-0-stable +0 -5
- data/gemfiles/Gemfile-5-1-stable +0 -5
- data/gemfiles/Gemfile-5-2-stable +0 -5
- data/gemfiles/Gemfile-6-0-stable +0 -5
- data/test/log_subscriber_test.rb +0 -57
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ddc94d6e16fd7d3cb21aa0d63a1ade832a271077ea5d9b1e42e769490f05f102
|
|
4
|
+
data.tar.gz: 0bc6935d09e011c00c437ddb6ee5aee424ebde5452a801cb582be7f5c977f940
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4319580bee3b3fe4f9ced4d73c180d623e625b4ae885a4cc7b66d2fb2e831aba3bdd630d8a2a3298f38186fc40602b799ec342772540cfe96c1636ab536a9e7b
|
|
7
|
+
data.tar.gz: a81007b1ebd1b0c06b5b836b0951ecba336ef182375ad8705ef6a057193941545a09b0642cd6cc651325c9222402d7ef4da3085dac75015edfcd923af49db1bf
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -11,63 +11,71 @@ jobs:
|
|
|
11
11
|
strategy:
|
|
12
12
|
matrix:
|
|
13
13
|
gemfile:
|
|
14
|
-
- '4-2-stable'
|
|
15
|
-
- '5-0-stable'
|
|
16
|
-
- '5-1-stable'
|
|
17
|
-
- '5-2-stable'
|
|
18
|
-
- '6-0-stable'
|
|
19
14
|
- '6-1-stable'
|
|
15
|
+
- '7-0-stable'
|
|
16
|
+
- '7-1-stable'
|
|
17
|
+
- '7-2-stable'
|
|
18
|
+
- '8-0-stable'
|
|
19
|
+
- '8-1-stable'
|
|
20
20
|
- 'edge'
|
|
21
21
|
ruby:
|
|
22
|
-
- '2.4'
|
|
23
|
-
- '2.5'
|
|
24
|
-
- '2.6'
|
|
25
22
|
- '2.7'
|
|
26
23
|
- '3.0'
|
|
24
|
+
- '3.1'
|
|
25
|
+
- '3.2'
|
|
26
|
+
- '3.3'
|
|
27
|
+
- '3.4'
|
|
27
28
|
exclude:
|
|
28
|
-
- gemfile: '
|
|
29
|
-
ruby: '
|
|
30
|
-
- gemfile: '
|
|
31
|
-
ruby: '2
|
|
32
|
-
- gemfile: '
|
|
29
|
+
- gemfile: '6-1-stable'
|
|
30
|
+
ruby: '3.1'
|
|
31
|
+
- gemfile: '6-1-stable'
|
|
32
|
+
ruby: '3.2'
|
|
33
|
+
- gemfile: '6-1-stable'
|
|
34
|
+
ruby: '3.3'
|
|
35
|
+
- gemfile: '6-1-stable'
|
|
36
|
+
ruby: '3.4'
|
|
37
|
+
- gemfile: '7-0-stable'
|
|
38
|
+
ruby: '3.3'
|
|
39
|
+
- gemfile: '7-0-stable'
|
|
40
|
+
ruby: '3.4'
|
|
41
|
+
- gemfile: '7-1-stable'
|
|
42
|
+
ruby: '3.4'
|
|
43
|
+
- gemfile: '7-2-stable'
|
|
33
44
|
ruby: '2.7'
|
|
34
|
-
- gemfile: '
|
|
45
|
+
- gemfile: '7-2-stable'
|
|
35
46
|
ruby: '3.0'
|
|
36
|
-
- gemfile: '
|
|
47
|
+
- gemfile: '8-0-stable'
|
|
37
48
|
ruby: '2.7'
|
|
38
|
-
- gemfile: '
|
|
49
|
+
- gemfile: '8-0-stable'
|
|
39
50
|
ruby: '3.0'
|
|
40
|
-
- gemfile: '
|
|
51
|
+
- gemfile: '8-0-stable'
|
|
52
|
+
ruby: '3.1'
|
|
53
|
+
- gemfile: '8-1-stable'
|
|
41
54
|
ruby: '2.7'
|
|
42
|
-
- gemfile: '
|
|
55
|
+
- gemfile: '8-1-stable'
|
|
43
56
|
ruby: '3.0'
|
|
44
|
-
- gemfile: '
|
|
57
|
+
- gemfile: '8-1-stable'
|
|
58
|
+
ruby: '3.1'
|
|
59
|
+
- gemfile: 'edge'
|
|
45
60
|
ruby: '2.7'
|
|
46
|
-
- gemfile: '5-2-stable'
|
|
47
|
-
ruby: '3.0'
|
|
48
|
-
- gemfile: '6-0-stable'
|
|
49
|
-
ruby: '2.4'
|
|
50
|
-
- gemfile: '6-1-stable'
|
|
51
|
-
ruby: '2.4'
|
|
52
61
|
- gemfile: 'edge'
|
|
53
|
-
ruby: '
|
|
62
|
+
ruby: '3.0'
|
|
54
63
|
- gemfile: 'edge'
|
|
55
|
-
ruby: '
|
|
64
|
+
ruby: '3.1'
|
|
56
65
|
- gemfile: 'edge'
|
|
57
|
-
ruby: '2
|
|
66
|
+
ruby: '3.2'
|
|
58
67
|
fail-fast: false
|
|
59
68
|
|
|
60
69
|
runs-on: ubuntu-latest
|
|
61
70
|
name: ${{ matrix.ruby }} rails-${{ matrix.gemfile }}
|
|
62
71
|
|
|
63
72
|
steps:
|
|
64
|
-
- uses: actions/checkout@
|
|
73
|
+
- uses: actions/checkout@v4
|
|
65
74
|
|
|
66
75
|
- uses: ruby/setup-ruby@v1
|
|
67
76
|
with:
|
|
68
77
|
ruby-version: ${{ matrix.ruby }}
|
|
69
78
|
bundler-cache: true
|
|
70
|
-
bundler: ${{ fromJSON('["2", "1"]')[matrix.ruby == '2.4'] }}
|
|
71
79
|
|
|
72
80
|
- run: bundle exec rake test
|
|
73
81
|
|
|
@@ -75,4 +83,3 @@ jobs:
|
|
|
75
83
|
BUNDLE_GEMFILE: gemfiles/Gemfile-${{ matrix.gemfile }}
|
|
76
84
|
BUNDLE_JOBS: 4
|
|
77
85
|
BUNDLE_RETRY: 3
|
|
78
|
-
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |gem|
|
|
2
2
|
gem.name = "actionpack-page_caching"
|
|
3
|
-
gem.version = "1.2.
|
|
3
|
+
gem.version = "1.2.5"
|
|
4
4
|
gem.author = "David Heinemeier Hansson"
|
|
5
5
|
gem.email = "david@loudthinking.com"
|
|
6
6
|
gem.description = "Static page caching for Action Pack (removed from core in Rails 4.0)"
|
|
@@ -157,10 +157,11 @@ module ActionController
|
|
|
157
157
|
end
|
|
158
158
|
|
|
159
159
|
def cache_path(path, extension = nil)
|
|
160
|
-
|
|
160
|
+
cache_directory = normalized_cache_directory
|
|
161
|
+
unnormalized_path = File.join(cache_directory, cache_file(path, extension))
|
|
161
162
|
normalized_path = File.expand_path(unnormalized_path)
|
|
162
163
|
|
|
163
|
-
normalized_path if normalized_path.start_with?(
|
|
164
|
+
normalized_path if normalized_path.start_with?(File.join(cache_directory, ""))
|
|
164
165
|
end
|
|
165
166
|
|
|
166
167
|
def delete(path)
|
data/test/caching_test.rb
CHANGED
|
@@ -200,6 +200,23 @@ class PageCachingTest < ActionController::TestCase
|
|
|
200
200
|
assert_predicate Find.find(File.join(project_root, "test")).grep(/pwnd/), :empty?
|
|
201
201
|
end
|
|
202
202
|
|
|
203
|
+
def test_cache_does_not_escape_into_sibling_sharing_name_prefix
|
|
204
|
+
draw do
|
|
205
|
+
get "/page_caching_test/ok/:id", to: "page_caching_test#ok"
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Relative to the cache directory, "../../../" is the directory holding it.
|
|
209
|
+
["../../../#{CACHE_DIR}_sibling/page", "../../../#{CACHE_DIR}_sibling"].each do |id|
|
|
210
|
+
if Rails.version =~ /^4\./
|
|
211
|
+
get :ok, id: id
|
|
212
|
+
else
|
|
213
|
+
get :ok, params: { id: id }
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
assert_equal [CACHE_DIR], Dir.entries(TEST_TMP_DIR) - [".", ".."]
|
|
218
|
+
end
|
|
219
|
+
|
|
203
220
|
def test_page_caching_resources_saves_to_correct_path_with_extension_even_if_default_route
|
|
204
221
|
draw do
|
|
205
222
|
get "posts.:format", to: "posts#index", as: :formatted_posts
|
|
@@ -426,9 +443,10 @@ class ProcPageCachingTest < ActionController::TestCase
|
|
|
426
443
|
end
|
|
427
444
|
|
|
428
445
|
def test_class_level_cache_page_raise_error
|
|
429
|
-
assert_raises(RuntimeError
|
|
446
|
+
error = assert_raises(RuntimeError) do
|
|
430
447
|
@controller.class.cache_page "cached content", "/proc_page_caching_test/ok"
|
|
431
448
|
end
|
|
449
|
+
assert_match(/class-level cache_page method/, error.message)
|
|
432
450
|
end
|
|
433
451
|
end
|
|
434
452
|
|
|
@@ -482,9 +500,10 @@ class SymbolPageCachingTest < ActionController::TestCase
|
|
|
482
500
|
end
|
|
483
501
|
|
|
484
502
|
def test_class_level_cache_page_raise_error
|
|
485
|
-
assert_raises(RuntimeError
|
|
503
|
+
error = assert_raises(RuntimeError) do
|
|
486
504
|
@controller.class.cache_page "cached content", "/symbol_page_caching_test/ok"
|
|
487
505
|
end
|
|
506
|
+
assert_match(/class-level cache_page method/, error.message)
|
|
488
507
|
end
|
|
489
508
|
end
|
|
490
509
|
|
|
@@ -539,8 +558,9 @@ class CallablePageCachingTest < ActionController::TestCase
|
|
|
539
558
|
end
|
|
540
559
|
|
|
541
560
|
def test_class_level_cache_page_raise_error
|
|
542
|
-
assert_raises(RuntimeError
|
|
561
|
+
error = assert_raises(RuntimeError) do
|
|
543
562
|
@controller.class.cache_page "cached content", "/callable_page_caching_test/ok"
|
|
544
563
|
end
|
|
564
|
+
assert_match(/class-level cache_page method/, error.message)
|
|
545
565
|
end
|
|
546
566
|
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require "abstract_unit"
|
|
2
|
+
|
|
3
|
+
module Another
|
|
4
|
+
class InstrumentationController < ActionController::Base
|
|
5
|
+
self.perform_caching = true
|
|
6
|
+
|
|
7
|
+
def with_page_cache
|
|
8
|
+
cache_page("Super soaker", "/index.html")
|
|
9
|
+
head :ok
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class InstrumentationTest < ActionController::TestCase
|
|
15
|
+
tests Another::InstrumentationController
|
|
16
|
+
|
|
17
|
+
def setup
|
|
18
|
+
super
|
|
19
|
+
|
|
20
|
+
@routes = ActionDispatch::Routing::RouteSet.new
|
|
21
|
+
|
|
22
|
+
@cache_path = File.expand_path("../tmp/test_cache", __FILE__)
|
|
23
|
+
ActionController::Base.page_cache_directory = @cache_path
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def teardown
|
|
27
|
+
FileUtils.rm_rf(@cache_path)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_write_page_is_instrumented
|
|
31
|
+
events = []
|
|
32
|
+
subscriber = ActiveSupport::Notifications.subscribe("write_page.action_controller") do |*args|
|
|
33
|
+
events << ActiveSupport::Notifications::Event.new(*args)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
with_routing do |set|
|
|
37
|
+
set.draw do
|
|
38
|
+
get "/with_page_cache", to: "another/instrumentation#with_page_cache"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
get :with_page_cache
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
assert_equal 1, events.size
|
|
45
|
+
assert_equal "/index.html", events.first.payload[:path]
|
|
46
|
+
ensure
|
|
47
|
+
ActiveSupport::Notifications.unsubscribe(subscriber)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_expire_page_is_instrumented
|
|
51
|
+
events = []
|
|
52
|
+
subscriber = ActiveSupport::Notifications.subscribe("expire_page.action_controller") do |*args|
|
|
53
|
+
events << ActiveSupport::Notifications::Event.new(*args)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
@controller.class.expire_page("/index.html")
|
|
57
|
+
|
|
58
|
+
assert_equal 1, events.size
|
|
59
|
+
assert_equal "/index.html", events.first.payload[:path]
|
|
60
|
+
ensure
|
|
61
|
+
ActiveSupport::Notifications.unsubscribe(subscriber)
|
|
62
|
+
end
|
|
63
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: actionpack-page_caching
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: actionpack
|
|
@@ -54,12 +53,12 @@ files:
|
|
|
54
53
|
- README.md
|
|
55
54
|
- Rakefile
|
|
56
55
|
- actionpack-page_caching.gemspec
|
|
57
|
-
- gemfiles/Gemfile-4-2-stable
|
|
58
|
-
- gemfiles/Gemfile-5-0-stable
|
|
59
|
-
- gemfiles/Gemfile-5-1-stable
|
|
60
|
-
- gemfiles/Gemfile-5-2-stable
|
|
61
|
-
- gemfiles/Gemfile-6-0-stable
|
|
62
56
|
- gemfiles/Gemfile-6-1-stable
|
|
57
|
+
- gemfiles/Gemfile-7-0-stable
|
|
58
|
+
- gemfiles/Gemfile-7-1-stable
|
|
59
|
+
- gemfiles/Gemfile-7-2-stable
|
|
60
|
+
- gemfiles/Gemfile-8-0-stable
|
|
61
|
+
- gemfiles/Gemfile-8-1-stable
|
|
63
62
|
- gemfiles/Gemfile-edge
|
|
64
63
|
- lib/action_controller/caching/pages.rb
|
|
65
64
|
- lib/action_controller/page_caching.rb
|
|
@@ -67,12 +66,11 @@ files:
|
|
|
67
66
|
- lib/actionpack/page_caching/railtie.rb
|
|
68
67
|
- test/abstract_unit.rb
|
|
69
68
|
- test/caching_test.rb
|
|
70
|
-
- test/
|
|
69
|
+
- test/instrumentation_test.rb
|
|
71
70
|
homepage: https://github.com/rails/actionpack-page_caching
|
|
72
71
|
licenses:
|
|
73
72
|
- MIT
|
|
74
73
|
metadata: {}
|
|
75
|
-
post_install_message:
|
|
76
74
|
rdoc_options: []
|
|
77
75
|
require_paths:
|
|
78
76
|
- lib
|
|
@@ -87,11 +85,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
87
85
|
- !ruby/object:Gem::Version
|
|
88
86
|
version: '0'
|
|
89
87
|
requirements: []
|
|
90
|
-
rubygems_version:
|
|
91
|
-
signing_key:
|
|
88
|
+
rubygems_version: 4.0.16
|
|
92
89
|
specification_version: 4
|
|
93
90
|
summary: Static page caching for Action Pack (removed from core in Rails 4.0)
|
|
94
91
|
test_files:
|
|
95
92
|
- test/abstract_unit.rb
|
|
96
93
|
- test/caching_test.rb
|
|
97
|
-
- test/
|
|
94
|
+
- test/instrumentation_test.rb
|
data/gemfiles/Gemfile-4-2-stable
DELETED
data/gemfiles/Gemfile-5-0-stable
DELETED
data/gemfiles/Gemfile-5-1-stable
DELETED
data/gemfiles/Gemfile-5-2-stable
DELETED
data/gemfiles/Gemfile-6-0-stable
DELETED
data/test/log_subscriber_test.rb
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
require "abstract_unit"
|
|
2
|
-
require "active_support/log_subscriber/test_helper"
|
|
3
|
-
require "action_controller/log_subscriber"
|
|
4
|
-
|
|
5
|
-
module Another
|
|
6
|
-
class LogSubscribersController < ActionController::Base
|
|
7
|
-
abstract!
|
|
8
|
-
|
|
9
|
-
self.perform_caching = true
|
|
10
|
-
|
|
11
|
-
def with_page_cache
|
|
12
|
-
cache_page("Super soaker", "/index.html")
|
|
13
|
-
head :ok
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
class ACLogSubscriberTest < ActionController::TestCase
|
|
19
|
-
tests Another::LogSubscribersController
|
|
20
|
-
include ActiveSupport::LogSubscriber::TestHelper
|
|
21
|
-
|
|
22
|
-
def setup
|
|
23
|
-
super
|
|
24
|
-
|
|
25
|
-
@routes = ActionDispatch::Routing::RouteSet.new
|
|
26
|
-
|
|
27
|
-
@cache_path = File.expand_path("../tmp/test_cache", __FILE__)
|
|
28
|
-
ActionController::Base.page_cache_directory = @cache_path
|
|
29
|
-
@controller.cache_store = :file_store, @cache_path
|
|
30
|
-
ActionController::LogSubscriber.attach_to :action_controller
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def teardown
|
|
34
|
-
ActiveSupport::LogSubscriber.log_subscribers.clear
|
|
35
|
-
FileUtils.rm_rf(@cache_path)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def set_logger(logger)
|
|
39
|
-
ActionController::Base.logger = logger
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def test_with_page_cache
|
|
43
|
-
with_routing do |set|
|
|
44
|
-
set.draw do
|
|
45
|
-
get "/with_page_cache", to: "another/log_subscribers#with_page_cache"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
get :with_page_cache
|
|
49
|
-
wait
|
|
50
|
-
|
|
51
|
-
logs = @logger.logged(:info)
|
|
52
|
-
assert_equal 3, logs.size
|
|
53
|
-
assert_match(/Write page/, logs[1])
|
|
54
|
-
assert_match(/\/index\.html/, logs[1])
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|