rails-rfc6570 3.3.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +3 -1
  4. data/lib/rails/rfc6570/version.rb +1 -1
  5. data/lib/rails/rfc6570.rb +10 -29
  6. data/spec/dummy/config/application.rb +5 -1
  7. data/spec/dummy/config/environments/test.rb +1 -1
  8. data/spec/rails/rfc6570/extensions/route_set_spec.rb +29 -0
  9. data/spec/rails/rfc6570/helper_spec.rb +44 -0
  10. data/spec/rails/rfc6570/visitor_spec.rb +12 -0
  11. data/spec/spec_helper.rb +6 -0
  12. data/vendor/bundle/ruby/3.4.0/bundler/gems/rubocop-config-67802c9d1826/LICENSE +21 -0
  13. data/vendor/bundle/ruby/3.4.0/bundler/gems/rubocop-config-67802c9d1826/README.md +23 -0
  14. data/vendor/bundle/ruby/3.4.0/bundler/gems/rubocop-config-67802c9d1826/rubocop-config.gemspec +31 -0
  15. data/vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.1/CHANGELOG.md +205 -0
  16. data/vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.1/MIT-LICENSE +21 -0
  17. data/vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.1/README.rdoc +57 -0
  18. data/vendor/bundle/ruby/3.4.0/gems/actionview-8.0.1/CHANGELOG.md +67 -0
  19. data/vendor/bundle/ruby/3.4.0/gems/actionview-8.0.1/MIT-LICENSE +21 -0
  20. data/vendor/bundle/ruby/3.4.0/gems/actionview-8.0.1/README.rdoc +40 -0
  21. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.1/CHANGELOG.md +157 -0
  22. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.1/MIT-LICENSE +20 -0
  23. data/vendor/bundle/ruby/3.4.0/gems/activesupport-8.0.1/README.rdoc +40 -0
  24. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/CHANGELOG.md +301 -0
  25. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/LICENSE.txt +202 -0
  26. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/README.md +121 -0
  27. data/vendor/bundle/ruby/3.4.0/gems/addressable-2.8.7/addressable.gemspec +28 -0
  28. data/vendor/bundle/ruby/3.4.0/gems/base64-0.2.0/LICENSE.txt +22 -0
  29. data/vendor/bundle/ruby/3.4.0/gems/base64-0.2.0/README.md +48 -0
  30. data/vendor/bundle/ruby/3.4.0/gems/benchmark-0.4.0/README.md +138 -0
  31. data/vendor/bundle/ruby/3.4.0/gems/benchmark-0.4.0/benchmark.gemspec +32 -0
  32. data/vendor/bundle/ruby/3.4.0/gems/bigdecimal-3.1.9/LICENSE +56 -0
  33. data/vendor/bundle/ruby/3.4.0/gems/bigdecimal-3.1.9/bigdecimal.gemspec +57 -0
  34. data/vendor/bundle/ruby/3.4.0/gems/builder-3.3.0/MIT-LICENSE +20 -0
  35. data/vendor/bundle/ruby/3.4.0/gems/builder-3.3.0/README.md +258 -0
  36. data/vendor/bundle/ruby/3.4.0/gems/builder-3.3.0/builder.gemspec +49 -0
  37. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/CHANGELOG.md +603 -0
  38. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/LICENSE.txt +21 -0
  39. data/vendor/bundle/ruby/3.4.0/gems/concurrent-ruby-1.3.5/README.md +407 -0
  40. data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.0/LICENSE +20 -0
  41. data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.0/README.md +167 -0
  42. data/vendor/bundle/ruby/3.4.0/gems/connection_pool-2.5.0/connection_pool.gemspec +24 -0
  43. data/vendor/bundle/ruby/3.4.0/gems/crass-1.0.6/LICENSE +18 -0
  44. data/vendor/bundle/ruby/3.4.0/gems/crass-1.0.6/README.md +192 -0
  45. data/vendor/bundle/ruby/3.4.0/gems/crass-1.0.6/crass.gemspec +31 -0
  46. data/vendor/bundle/ruby/3.4.0/gems/diff-lcs-1.5.1/README.rdoc +84 -0
  47. data/vendor/bundle/ruby/3.4.0/gems/drb-2.2.1/LICENSE.txt +22 -0
  48. data/vendor/bundle/ruby/3.4.0/gems/drb-2.2.1/drb.gemspec +41 -0
  49. data/vendor/bundle/ruby/3.4.0/gems/erubi-1.13.1/CHANGELOG +111 -0
  50. data/vendor/bundle/ruby/3.4.0/gems/erubi-1.13.1/MIT-LICENSE +21 -0
  51. data/vendor/bundle/ruby/3.4.0/gems/erubi-1.13.1/README.rdoc +151 -0
  52. data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.7/MIT-LICENSE +20 -0
  53. data/vendor/bundle/ruby/3.4.0/gems/i18n-1.14.7/README.md +127 -0
  54. data/vendor/bundle/ruby/3.4.0/gems/logger-1.6.5/README.md +104 -0
  55. data/vendor/bundle/ruby/3.4.0/gems/logger-1.6.5/logger.gemspec +28 -0
  56. data/vendor/bundle/ruby/3.4.0/gems/loofah-2.24.0/CHANGELOG.md +591 -0
  57. data/vendor/bundle/ruby/3.4.0/gems/loofah-2.24.0/MIT-LICENSE.txt +23 -0
  58. data/vendor/bundle/ruby/3.4.0/gems/loofah-2.24.0/README.md +410 -0
  59. data/vendor/bundle/ruby/3.4.0/gems/minitest-5.25.4/README.rdoc +835 -0
  60. data/vendor/bundle/ruby/3.4.0/gems/nokogiri-1.18.2-x86_64-linux-gnu/LICENSE-DEPENDENCIES.md +2224 -0
  61. data/vendor/bundle/ruby/3.4.0/gems/nokogiri-1.18.2-x86_64-linux-gnu/LICENSE.md +9 -0
  62. data/vendor/bundle/ruby/3.4.0/gems/nokogiri-1.18.2-x86_64-linux-gnu/README.md +293 -0
  63. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.1/CHANGELOG.md +491 -0
  64. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.1/LICENSE.txt +22 -0
  65. data/vendor/bundle/ruby/3.4.0/gems/public_suffix-6.0.1/README.md +222 -0
  66. data/vendor/bundle/ruby/3.4.0/gems/racc-1.8.1/README.ja.rdoc +58 -0
  67. data/vendor/bundle/ruby/3.4.0/gems/racc-1.8.1/README.rdoc +60 -0
  68. data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.9/CHANGELOG.md +1006 -0
  69. data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.9/MIT-LICENSE +20 -0
  70. data/vendor/bundle/ruby/3.4.0/gems/rack-3.1.9/README.md +328 -0
  71. data/vendor/bundle/ruby/3.4.0/gems/rack-test-2.2.0/MIT-LICENSE.txt +20 -0
  72. data/vendor/bundle/ruby/3.4.0/gems/rack-test-2.2.0/README.md +139 -0
  73. data/vendor/bundle/ruby/3.4.0/gems/rails-dom-testing-2.2.0/MIT-LICENSE +23 -0
  74. data/vendor/bundle/ruby/3.4.0/gems/rails-dom-testing-2.2.0/README.md +91 -0
  75. data/vendor/bundle/ruby/3.4.0/gems/rails-html-sanitizer-1.6.2/CHANGELOG.md +255 -0
  76. data/vendor/bundle/ruby/3.4.0/gems/rails-html-sanitizer-1.6.2/MIT-LICENSE +23 -0
  77. data/vendor/bundle/ruby/3.4.0/gems/rails-html-sanitizer-1.6.2/README.md +267 -0
  78. data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/MIT-LICENSE +21 -0
  79. data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/README.rdoc +155 -0
  80. data/vendor/bundle/ruby/3.4.0/gems/rake-13.2.1/rake.gemspec +101 -0
  81. data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/LICENSE +21 -0
  82. data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/README.md +107 -0
  83. data/vendor/bundle/ruby/3.4.0/gems/rake-release-1.3.0/rake-release.gemspec +23 -0
  84. data/vendor/bundle/ruby/3.4.0/gems/rspec-3.13.0/LICENSE.md +27 -0
  85. data/vendor/bundle/ruby/3.4.0/gems/rspec-3.13.0/README.md +47 -0
  86. data/vendor/bundle/ruby/3.4.0/gems/rspec-core-3.13.2/LICENSE.md +26 -0
  87. data/vendor/bundle/ruby/3.4.0/gems/rspec-core-3.13.2/README.md +389 -0
  88. data/vendor/bundle/ruby/3.4.0/gems/rspec-expectations-3.13.3/LICENSE.md +25 -0
  89. data/vendor/bundle/ruby/3.4.0/gems/rspec-expectations-3.13.3/README.md +326 -0
  90. data/vendor/bundle/ruby/3.4.0/gems/rspec-mocks-3.13.2/LICENSE.md +25 -0
  91. data/vendor/bundle/ruby/3.4.0/gems/rspec-mocks-3.13.2/README.md +465 -0
  92. data/vendor/bundle/ruby/3.4.0/gems/rspec-support-3.13.2/LICENSE.md +23 -0
  93. data/vendor/bundle/ruby/3.4.0/gems/rspec-support-3.13.2/README.md +40 -0
  94. data/vendor/bundle/ruby/3.4.0/gems/securerandom-0.4.1/README.md +72 -0
  95. data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/LICENSE +19 -0
  96. data/vendor/bundle/ruby/3.4.0/gems/tzinfo-2.0.6/README.md +406 -0
  97. data/vendor/bundle/ruby/3.4.0/gems/uri-1.0.2/README.md +55 -0
  98. data/vendor/bundle/ruby/3.4.0/gems/useragent-0.16.11/LICENSE +20 -0
  99. data/vendor/bundle/ruby/3.4.0/gems/useragent-0.16.11/README.md +42 -0
  100. data/vendor/bundle/ruby/3.4.0/specifications/actionpack-8.0.1.gemspec +36 -0
  101. data/vendor/bundle/ruby/3.4.0/specifications/actionview-8.0.1.gemspec +33 -0
  102. data/vendor/bundle/ruby/3.4.0/specifications/activesupport-8.0.1.gemspec +38 -0
  103. data/vendor/bundle/ruby/3.4.0/specifications/addressable-2.8.7.gemspec +30 -0
  104. data/vendor/bundle/ruby/3.4.0/specifications/base64-0.2.0.gemspec +23 -0
  105. data/vendor/bundle/ruby/3.4.0/specifications/benchmark-0.4.0.gemspec +23 -0
  106. data/vendor/bundle/ruby/3.4.0/specifications/bigdecimal-3.1.9.gemspec +25 -0
  107. data/vendor/bundle/ruby/3.4.0/specifications/builder-3.3.0.gemspec +22 -0
  108. data/vendor/bundle/ruby/3.4.0/specifications/concurrent-ruby-1.3.5.gemspec +24 -0
  109. data/vendor/bundle/ruby/3.4.0/specifications/connection_pool-2.5.0.gemspec +28 -0
  110. data/vendor/bundle/ruby/3.4.0/specifications/crass-1.0.6.gemspec +27 -0
  111. data/vendor/bundle/ruby/3.4.0/specifications/diff-lcs-1.5.1.gemspec +37 -0
  112. data/vendor/bundle/ruby/3.4.0/specifications/drb-2.2.1.gemspec +22 -0
  113. data/vendor/bundle/ruby/3.4.0/specifications/erubi-1.13.1.gemspec +29 -0
  114. data/vendor/bundle/ruby/3.4.0/specifications/i18n-1.14.7.gemspec +26 -0
  115. data/vendor/bundle/ruby/3.4.0/specifications/logger-1.6.5.gemspec +22 -0
  116. data/vendor/bundle/ruby/3.4.0/specifications/loofah-2.24.0.gemspec +27 -0
  117. data/vendor/bundle/ruby/3.4.0/specifications/minitest-5.25.4.gemspec +31 -0
  118. data/vendor/bundle/ruby/3.4.0/specifications/nokogiri-1.18.2-x86_64-linux-gnu.gemspec +31 -0
  119. data/vendor/bundle/ruby/3.4.0/specifications/public_suffix-6.0.1.gemspec +24 -0
  120. data/vendor/bundle/ruby/3.4.0/specifications/racc-1.8.1.gemspec +28 -0
  121. data/vendor/bundle/ruby/3.4.0/specifications/rack-3.1.9.gemspec +31 -0
  122. data/vendor/bundle/ruby/3.4.0/specifications/rack-session-2.1.0.gemspec +30 -0
  123. data/vendor/bundle/ruby/3.4.0/specifications/rack-test-2.2.0.gemspec +29 -0
  124. data/vendor/bundle/ruby/3.4.0/specifications/rails-dom-testing-2.2.0.gemspec +28 -0
  125. data/vendor/bundle/ruby/3.4.0/specifications/rails-html-sanitizer-1.6.2.gemspec +27 -0
  126. data/vendor/bundle/ruby/3.4.0/specifications/rake-13.2.1.gemspec +26 -0
  127. data/vendor/bundle/ruby/3.4.0/specifications/rake-release-1.3.0.gemspec +26 -0
  128. data/vendor/bundle/ruby/3.4.0/specifications/rspec-3.13.0.gemspec +31 -0
  129. data/vendor/bundle/ruby/3.4.0/specifications/rspec-core-3.13.2.gemspec +39 -0
  130. data/vendor/bundle/ruby/3.4.0/specifications/rspec-expectations-3.13.3.gemspec +33 -0
  131. data/vendor/bundle/ruby/3.4.0/specifications/rspec-mocks-3.13.2.gemspec +33 -0
  132. data/vendor/bundle/ruby/3.4.0/specifications/rspec-support-3.13.2.gemspec +29 -0
  133. data/vendor/bundle/ruby/3.4.0/specifications/securerandom-0.4.1.gemspec +23 -0
  134. data/vendor/bundle/ruby/3.4.0/specifications/tzinfo-2.0.6.gemspec +30 -0
  135. data/vendor/bundle/ruby/3.4.0/specifications/uri-1.0.2.gemspec +23 -0
  136. data/vendor/bundle/ruby/3.4.0/specifications/useragent-0.16.11.gemspec +25 -0
  137. metadata +130 -8
  138. data/spec/dummy/log/test.log +0 -432
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1024d8d48a4b71d05fef63d55be57a7615070e7e337f55ab46b4e5f7f2bebe3
4
- data.tar.gz: 5af240717ecd2ce3231c51f9162bb938b0880228728103d6f3cbf2f180dad475
3
+ metadata.gz: 9da33d88750739a23961a9f48f5b26c2bb5e979a38a73f7646407ce41437a599
4
+ data.tar.gz: f8083a5cbcda1e9fe0b8bea8417161a9ae9940d784098f1507e7cbcf52a73f32
5
5
  SHA512:
6
- metadata.gz: d5585791e180636510de263564a9f1104fb888b4455efaed5351d848288eabecb45a4e58df6ff4354e7a4fce28203d154ec8bb129bfcbb8f8ebb1aae3bbc0770
7
- data.tar.gz: 5518b0541f5c7331202383b5fd9686e358ddf7fc66820b8c2932e0f6b7fbc45470d3fe9eff1d38b63f06ba3626362c63dbeae1af84baf415f7b0be8a7aa16da9
6
+ metadata.gz: 4342753841b8c3e94054412f1a275fc67be3ac6d2cde95fe16731e5d920a4e7b5e833c6dd4cb3a9b54f3f33be1ffda3a17a7f4be21e91fac8c5f3e192093da71
7
+ data.tar.gz: 5891d48dd9cbb1fe6a7b9a98b0cee339794d5f1da49cd7fa2e14e4314b22ed9729d1b8e3bd6c50fdfa136a777f8c3f21e3f484391b40d046cbba0059b2dad699
data/CHANGELOG.md CHANGED
@@ -11,10 +11,32 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch
11
11
 
12
12
  ### Changes
13
13
 
14
+ - Optimize named `*_rfc6570` helpers by removing unnecessary indirection
15
+ - Optimize `#rfc6570_routes` and `#rfc6570_route` helpers
16
+
14
17
  ### Fixes
15
18
 
19
+ - Fix up `RouteSet#to_rfc6570` and `NamedRouteCollection#to_rfc6570`
20
+
16
21
  ### Breaks
17
22
 
23
+ ## 3.4.0 - (2025-01-31)
24
+
25
+ ---
26
+
27
+ ### New
28
+
29
+ - Support for Ruby 3.4
30
+
31
+ ### Changes
32
+
33
+ - Optimize named `*_rfc6570` helpers by removing unnecessary indirection
34
+ - Optimize `#rfc6570_routes` and `#rfc6570_route` helpers
35
+
36
+ ### Fixes
37
+
38
+ - Fix up `RouteSet#to_rfc6570` and `NamedRouteCollection#to_rfc6570`
39
+
18
40
  ## 3.3.0 - (2024-11-25)
19
41
 
20
42
  ---
data/README.md CHANGED
@@ -3,7 +3,9 @@
3
3
  [![Gem Version](https://img.shields.io/gem/v/rails-rfc6570?logo=ruby)](https://rubygems.org/gems/rails-rfc6570)
4
4
  [![Build Status](https://img.shields.io/github/actions/workflow/status/jgraichen/rails-rfc6570/test.yml?logo=github)](https://github.com/jgraichen/rails-rfc6570/actions/workflows/test.yml)
5
5
 
6
- Pragmatic access to your Rails routes as RFC6570 URI templates. Tested with Rails 6.1, 7.0, 7.1, 7.2 and Ruby 2.7, 3.0, 3.1, 3.2, 3.3.
6
+ Pragmatic access to your Rails routes as RFC6570 URI templates.
7
+
8
+ Tested with Rails 6.1, 7.0, 7.1, 7.2 and Ruby 2.7, 3.0, 3.1, 3.2, 3.3, and 3.4.
7
9
 
8
10
  ## Installation
9
11
 
@@ -4,7 +4,7 @@ module Rails
4
4
  module RFC6570
5
5
  module VERSION
6
6
  MAJOR = 3
7
- MINOR = 3
7
+ MINOR = 4
8
8
  PATCH = 0
9
9
  STAGE = nil
10
10
 
data/lib/rails/rfc6570.rb CHANGED
@@ -32,14 +32,14 @@ module Rails
32
32
 
33
33
  module Extensions
34
34
  module RouteSet
35
- def to_rfc6570(opts = {})
36
- routes.map {|r| r.to_rfc6570(opts) }
35
+ def to_rfc6570(**opts)
36
+ named_routes.to_rfc6570(**opts)
37
37
  end
38
38
  end
39
39
 
40
40
  module NamedRouteCollection
41
- def to_rfc6570(opts = {})
42
- routes.to_h {|n, r| [n, r.to_rfc6570(opts)] }
41
+ def to_rfc6570(**opts)
42
+ routes.to_h {|name, route| [name, route.to_rfc6570(**opts)] }
43
43
  end
44
44
 
45
45
  def define_rfc6570_helpers(name, route, mod, set)
@@ -53,25 +53,15 @@ module Rails
53
53
 
54
54
  mod.module_eval do
55
55
  define_method(rfc6570_name) do |**opts|
56
- ::Rails::RFC6570.build_url_template(self, route, **opts)
56
+ route.to_rfc6570(**opts, ctx: self)
57
57
  end
58
58
 
59
59
  define_method(rfc6570_url_name) do |**opts|
60
- ::Rails::RFC6570.build_url_template(
61
- self,
62
- route,
63
- **opts,
64
- path_only: false,
65
- )
60
+ route.to_rfc6570(**opts, ctx: self, path_only: false)
66
61
  end
67
62
 
68
63
  define_method(rfc6570_path_name) do |**opts|
69
- ::Rails::RFC6570.build_url_template(
70
- self,
71
- route,
72
- **opts,
73
- path_only: true,
74
- )
64
+ route.to_rfc6570(**opts, ctx: self, path_only: true)
75
65
  end
76
66
  end
77
67
 
@@ -98,16 +88,11 @@ module Rails
98
88
 
99
89
  module Helper
100
90
  def rfc6570_routes(**opts)
101
- routes = {}
102
- Rails.application.routes.named_routes.names.each do |key|
103
- routes[key] = rfc6570_route(key, **opts)
104
- end
105
-
106
- routes
91
+ _routes.named_routes.to_rfc6570(**opts, ctx: self)
107
92
  end
108
93
 
109
94
  def rfc6570_route(name, **opts)
110
- route = Rails.application.routes.named_routes[name]
95
+ route = _routes.named_routes[name]
111
96
  raise KeyError.new "No named routed for `#{name}'." unless route
112
97
 
113
98
  route.to_rfc6570(**opts, ctx: self)
@@ -130,15 +115,11 @@ module Rails
130
115
 
131
116
  def params_for(controller, action)
132
117
  ctr = "#{controller.camelize}Controller".constantize
133
- ctr.rfc6570_defs[action.to_sym] if ctr.respond_to?(:rfc6570_defs)
118
+ ctr.rfc6570_params_for(action.to_sym) if ctr.respond_to?(:rfc6570_params_for)
134
119
  rescue NameError
135
120
  nil
136
121
  end
137
122
 
138
- def build_url_template(ctx, route, **kwargs)
139
- route.to_rfc6570(ctx: ctx, **kwargs)
140
- end
141
-
142
123
  extend self # rubocop:disable Style/ModuleFunction
143
124
  end
144
125
  end
@@ -1,5 +1,10 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
+ # Workaround for missing require "logger" in some Rails versions.
4
+ #
5
+ # See https://github.com/rails/rails/pull/54264.
6
+ require 'logger'
7
+
3
8
  require 'rails/all'
4
9
 
5
10
  Bundler.require(*Rails.groups)
@@ -19,4 +24,3 @@ module Dummy
19
24
  # config.i18n.default_locale = :de
20
25
  end
21
26
  end
22
-
@@ -21,7 +21,7 @@ Dummy::Application.configure do
21
21
  config.action_controller.perform_caching = false
22
22
 
23
23
  # Raise exceptions instead of rendering exception templates.
24
- config.action_dispatch.show_exceptions = false
24
+ config.action_dispatch.show_exceptions = :none
25
25
 
26
26
  # Disable request forgery protection in test environment.
27
27
  config.action_controller.allow_forgery_protection = false
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Rails::RFC6570::Extensions::RouteSet do
6
+ subject(:route_set) do
7
+ ActionDispatch::Routing::RouteSet.new.tap do |routes|
8
+ routes.draw do
9
+ get '/path/:id', to: 'controller#action', as: :test1
10
+ end
11
+ end
12
+ end
13
+
14
+ let(:ctx) do
15
+ Class.new do
16
+ def url_options
17
+ {host: 'www.example.org'}
18
+ end
19
+ end.new
20
+ end
21
+
22
+ describe '#to_rfc6570' do
23
+ it 'returns dictionary of all named routes' do
24
+ expect(route_set.to_rfc6570(ctx: ctx)).to eq({
25
+ test1: Addressable::Template.new('http://www.example.org/path/{id}'),
26
+ })
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Rails::RFC6570::Helper do
6
+ subject(:helper) do
7
+ routes = self.routes
8
+
9
+ Class.new do
10
+ def url_options
11
+ {host: 'www.example.org'}
12
+ end
13
+
14
+ include routes.url_helpers
15
+ include Rails::RFC6570::Helper
16
+ end.new
17
+ end
18
+
19
+ let(:routes) do
20
+ ActionDispatch::Routing::RouteSet.new.tap do |routes|
21
+ routes.draw do
22
+ get '/path/:id', to: 'controller#action', as: :test1
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '#rfc6570_routes' do
28
+ it 'returns dictionary of all named routes' do
29
+ expect(helper.rfc6570_routes).to eq({
30
+ test1: Addressable::Template.new('http://www.example.org/path/{id}'),
31
+ })
32
+ end
33
+ end
34
+
35
+ describe '#rfc6570_route' do
36
+ it 'returns template for named route' do
37
+ expect(helper.rfc6570_route(:test1)).to eq Addressable::Template.new('http://www.example.org/path/{id}')
38
+ end
39
+
40
+ it 'raise KeyError with unknown named route' do
41
+ expect { helper.rfc6570_route(:not_found) }.to raise_error KeyError
42
+ end
43
+ end
44
+ end
@@ -20,12 +20,24 @@ RSpec.describe Rails::RFC6570::Visitor do
20
20
  it { is_expected.to eq %w[/ path / path] }
21
21
  end
22
22
 
23
+ describe '/path.:format' do
24
+ let(:path) { '/path.:format' }
25
+
26
+ it { is_expected.to eq %w[/ path . {format}] }
27
+ end
28
+
23
29
  describe '/:title' do
24
30
  let(:path) { '/:title' }
25
31
 
26
32
  it { is_expected.to eq %w[/ {title}] }
27
33
  end
28
34
 
35
+ describe '/:title.html' do
36
+ let(:path) { '/:title.html' }
37
+
38
+ it { is_expected.to eq %w[/ {title} . html] }
39
+ end
40
+
29
41
  describe '/:title(.:format)' do
30
42
  let(:path) { '/:title(.:format)' }
31
43
 
data/spec/spec_helper.rb CHANGED
@@ -30,4 +30,10 @@ end
30
30
 
31
31
  RSpec.configure do |config|
32
32
  config.order = 'random'
33
+
34
+ # Use the GitHub Annotations formatter for CI
35
+ if ENV['GITHUB_ACTIONS'] == 'true'
36
+ require 'rspec/github'
37
+ config.add_formatter RSpec::Github::Formatter
38
+ end
33
39
  end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Jan Graichen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ # Shared Rubocop Configuration
2
+
3
+ Shared rubocop configuration and defaults for my libraries and projects.
4
+
5
+ ## Usage
6
+
7
+ ```ruby
8
+ # Gemfile
9
+
10
+ gem 'rubocop-config', github: 'jgraichen/rubocop-config', ref: 'v11', require: false
11
+ ```
12
+
13
+ ```yaml
14
+ # .rubocop.yml
15
+
16
+ inherit_gem:
17
+ rubocop-config: default.yml
18
+
19
+ AllCops:
20
+ TargetRubyVersion: 2.7
21
+ SuggestExtensions: False
22
+ NewCops: enable
23
+ ```
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # stub: rubocop-config 13.0.0 ruby lib
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "rubocop-config".freeze
6
+ s.version = "13.0.0".freeze
7
+
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
+ s.metadata = { "allowed_push_host" => ".", "rubygems_mfa_required" => "true" } if s.respond_to? :metadata=
10
+ s.require_paths = ["lib".freeze]
11
+ s.authors = ["Jan Graichen".freeze]
12
+ s.date = "2025-01-31"
13
+ s.email = ["jgraichen@altimos.de".freeze]
14
+ s.files = ["LICENSE".freeze, "README.md".freeze, "default.yml".freeze]
15
+ s.homepage = "https://github.com/jgraichen/rubocop-config".freeze
16
+ s.licenses = ["MIT".freeze]
17
+ s.required_ruby_version = Gem::Requirement.new(">= 2.7.0".freeze)
18
+ s.rubygems_version = "3.6.2".freeze
19
+ s.summary = "Shared rubocop config".freeze
20
+
21
+ s.installed_by_version = "3.6.2".freeze
22
+
23
+ s.specification_version = 4
24
+
25
+ s.add_runtime_dependency(%q<rubocop>.freeze, ["~> 1.70.0".freeze])
26
+ s.add_runtime_dependency(%q<rubocop-capybara>.freeze, ["~> 2.21.0".freeze])
27
+ s.add_runtime_dependency(%q<rubocop-factory_bot>.freeze, ["~> 2.26.1".freeze])
28
+ s.add_runtime_dependency(%q<rubocop-performance>.freeze, ["~> 1.23.0".freeze])
29
+ s.add_runtime_dependency(%q<rubocop-rspec>.freeze, ["~> 3.3.0".freeze])
30
+ s.add_runtime_dependency(%q<rubocop-rspec_rails>.freeze, ["~> 2.30.0".freeze])
31
+ end
@@ -0,0 +1,205 @@
1
+ ## Rails 8.0.1 (December 13, 2024) ##
2
+
3
+ * Add `ActionDispatch::Request::Session#store` method to conform Rack spec.
4
+
5
+ *Yaroslav*
6
+
7
+
8
+ ## Rails 8.0.0.1 (December 10, 2024) ##
9
+
10
+ * Add validation to content security policies to disallow spaces and semicolons.
11
+ Developers should use multiple arguments, and different directive methods instead.
12
+
13
+ [CVE-2024-54133]
14
+
15
+ *Gannon McGibbon*
16
+
17
+
18
+ ## Rails 8.0.0 (November 07, 2024) ##
19
+
20
+ * No changes.
21
+
22
+
23
+ ## Rails 8.0.0.rc2 (October 30, 2024) ##
24
+
25
+ * Fix routes with `::` in the path.
26
+
27
+ *Rafael Mendonça França*
28
+
29
+ * Maintain Rack 2 parameter parsing behaviour.
30
+
31
+ *Matthew Draper*
32
+
33
+
34
+ ## Rails 8.0.0.rc1 (October 19, 2024) ##
35
+
36
+ * Remove `Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality`.
37
+
38
+ *Rafael Mendonça França*
39
+
40
+ * Improve `ActionController::TestCase` to expose a binary encoded `request.body`.
41
+
42
+ The rack spec clearly states:
43
+
44
+ > The input stream is an IO-like object which contains the raw HTTP POST data.
45
+ > When applicable, its external encoding must be “ASCII-8BIT” and it must be opened in binary mode.
46
+
47
+ Until now its encoding was generally UTF-8, which doesn't accurately reflect production
48
+ behavior.
49
+
50
+ *Jean Boussier*
51
+
52
+ * Update `ActionController::AllowBrowser` to support passing method names to `:block`
53
+
54
+ ```ruby
55
+ class ApplicationController < ActionController::Base
56
+ allow_browser versions: :modern, block: :handle_outdated_browser
57
+
58
+ private
59
+ def handle_outdated_browser
60
+ render file: Rails.root.join("public/custom-error.html"), status: :not_acceptable
61
+ end
62
+ end
63
+ ```
64
+
65
+ *Sean Doyle*
66
+
67
+ * Raise an `ArgumentError` when invalid `:only` or `:except` options are passed into `#resource` and `#resources`.
68
+
69
+ *Joshua Young*
70
+
71
+ ## Rails 8.0.0.beta1 (September 26, 2024) ##
72
+
73
+ * Fix non-GET requests not updating cookies in `ActionController::TestCase`.
74
+
75
+ *Jon Moss*, *Hartley McGuire*
76
+
77
+ * Update `ActionController::Live` to use a thread-pool to reuse threads across requests.
78
+
79
+ *Adam Renberg Tamm*
80
+
81
+ * Introduce safer, more explicit params handling method with `params#expect` such that
82
+ `params.expect(table: [ :attr ])` replaces `params.require(:table).permit(:attr)`
83
+
84
+ Ensures params are filtered with consideration for the expected
85
+ types of values, improving handling of params and avoiding ignorable
86
+ errors caused by params tampering.
87
+
88
+ ```ruby
89
+ # If the url is altered to ?person=hacked
90
+ # Before
91
+ params.require(:person).permit(:name, :age, pets: [:name])
92
+ # raises NoMethodError, causing a 500 and potential error reporting
93
+
94
+ # After
95
+ params.expect(person: [ :name, :age, pets: [[:name]] ])
96
+ # raises ActionController::ParameterMissing, correctly returning a 400 error
97
+ ```
98
+
99
+ You may also notice the new double array `[[:name]]`. In order to
100
+ declare when a param is expected to be an array of parameter hashes,
101
+ this new double array syntax is used to explicitly declare an array.
102
+ `expect` requires you to declare expected arrays in this way, and will
103
+ ignore arrays that are passed when, for example, `pet: [:name]` is used.
104
+
105
+ In order to preserve compatibility, `permit` does not adopt the new
106
+ double array syntax and is therefore more permissive about unexpected
107
+ types. Using `expect` everywhere is recommended.
108
+
109
+ We suggest replacing `params.require(:person).permit(:name, :age)`
110
+ with the direct replacement `params.expect(person: [:name, :age])`
111
+ to prevent external users from manipulating params to trigger 500
112
+ errors. A 400 error will be returned instead, using public/400.html
113
+
114
+ Usage of `params.require(:id)` should likewise be replaced with
115
+ `params.expect(:id)` which is designed to ensure that `params[:id]`
116
+ is a scalar and not an array or hash, also requiring the param.
117
+
118
+ ```ruby
119
+ # Before
120
+ User.find(params.require(:id)) # allows an array, altering behavior
121
+
122
+ # After
123
+ User.find(params.expect(:id)) # expect only returns non-blank permitted scalars (excludes Hash, Array, nil, "", etc)
124
+ ```
125
+
126
+ *Martin Emde*
127
+
128
+ * System Testing: Disable Chrome's search engine choice by default in system tests.
129
+
130
+ *glaszig*
131
+
132
+ * Fix `Request#raw_post` raising `NoMethodError` when `rack.input` is `nil`.
133
+
134
+ *Hartley McGuire*
135
+
136
+ * Remove `racc` dependency by manually writing `ActionDispatch::Journey::Scanner`.
137
+
138
+ *Gannon McGibbon*
139
+
140
+ * Speed up `ActionDispatch::Routing::Mapper::Scope#[]` by merging frame hashes.
141
+
142
+ *Gannon McGibbon*
143
+
144
+ * Allow bots to ignore `allow_browser`.
145
+
146
+ *Matthew Nguyen*
147
+
148
+ * Deprecate drawing routes with multiple paths to make routing faster.
149
+ You may use `with_options` or a loop to make drawing multiple paths easier.
150
+
151
+ ```ruby
152
+ # Before
153
+ get "/users", "/other_path", to: "users#index"
154
+
155
+ # After
156
+ get "/users", to: "users#index"
157
+ get "/other_path", to: "users#index"
158
+ ```
159
+
160
+ *Gannon McGibbon*
161
+
162
+ * Make `http_cache_forever` use `immutable: true`
163
+
164
+ *Nate Matykiewicz*
165
+
166
+ * Add `config.action_dispatch.strict_freshness`.
167
+
168
+ When set to `true`, the `ETag` header takes precedence over the `Last-Modified` header when both are present,
169
+ as specified by RFC 7232, Section 6.
170
+
171
+ Defaults to `false` to maintain compatibility with previous versions of Rails, but is enabled as part of
172
+ Rails 8.0 defaults.
173
+
174
+ *heka1024*
175
+
176
+ * Support `immutable` directive in Cache-Control
177
+
178
+ ```ruby
179
+ expires_in 1.minute, public: true, immutable: true
180
+ # Cache-Control: public, max-age=60, immutable
181
+ ```
182
+
183
+ *heka1024*
184
+
185
+ * Add `:wasm_unsafe_eval` mapping for `content_security_policy`
186
+
187
+ ```ruby
188
+ # Before
189
+ policy.script_src "'wasm-unsafe-eval'"
190
+
191
+ # After
192
+ policy.script_src :wasm_unsafe_eval
193
+ ```
194
+
195
+ *Joe Haig*
196
+
197
+ * Add `display_capture` and `keyboard_map` in `permissions_policy`
198
+
199
+ *Cyril Blaecke*
200
+
201
+ * Add `connect` route helper.
202
+
203
+ *Samuel Williams*
204
+
205
+ Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/actionpack/CHANGELOG.md) for previous changes.
@@ -0,0 +1,21 @@
1
+ Copyright (c) David Heinemeier Hansson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
@@ -0,0 +1,57 @@
1
+ = Action Pack -- From request to response
2
+
3
+ Action Pack is a framework for handling and responding to web requests. It
4
+ provides mechanisms for *routing* (mapping request URLs to actions), defining
5
+ *controllers* that implement actions, and generating responses. In short, Action Pack
6
+ provides the controller layer in the MVC paradigm.
7
+
8
+ It consists of several modules:
9
+
10
+ * Action Dispatch, which parses information about the web request, handles
11
+ routing as defined by the user, and does advanced processing related to HTTP
12
+ such as MIME-type negotiation, decoding parameters in POST, PATCH, or PUT bodies,
13
+ handling HTTP caching logic, cookies and sessions.
14
+
15
+ * Action Controller, which provides a base controller class that can be
16
+ subclassed to implement filters and actions to handle requests. The result
17
+ of an action is typically content generated from views.
18
+
19
+ With the Ruby on \Rails framework, users only directly interface with the
20
+ Action Controller module. Necessary Action Dispatch functionality is activated
21
+ by default and Action View rendering is implicitly triggered by Action
22
+ Controller. However, these modules are designed to function on their own and
23
+ can be used outside of \Rails.
24
+
25
+ You can read more about Action Pack in the {Action Controller Overview}[https://guides.rubyonrails.org/action_controller_overview.html] guide.
26
+
27
+ == Download and installation
28
+
29
+ The latest version of Action Pack can be installed with RubyGems:
30
+
31
+ $ gem install actionpack
32
+
33
+ Source code can be downloaded as part of the \Rails project on GitHub:
34
+
35
+ * https://github.com/rails/rails/tree/main/actionpack
36
+
37
+
38
+ == License
39
+
40
+ Action Pack is released under the MIT license:
41
+
42
+ * https://opensource.org/licenses/MIT
43
+
44
+
45
+ == Support
46
+
47
+ API documentation is at:
48
+
49
+ * https://api.rubyonrails.org
50
+
51
+ Bug reports for the Ruby on \Rails project can be filed here:
52
+
53
+ * https://github.com/rails/rails/issues
54
+
55
+ Feature requests should be discussed on the rails-core mailing list here:
56
+
57
+ * https://discuss.rubyonrails.org/c/rubyonrails-core