actionpack 7.0.0.alpha2 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +163 -0
  3. data/lib/abstract_controller/callbacks.rb +15 -2
  4. data/lib/abstract_controller/translation.rb +4 -1
  5. data/lib/action_controller/log_subscriber.rb +1 -2
  6. data/lib/action_controller/metal/helpers.rb +1 -1
  7. data/lib/action_controller/metal/http_authentication.rb +2 -1
  8. data/lib/action_controller/metal/instrumentation.rb +2 -0
  9. data/lib/action_controller/metal/params_wrapper.rb +13 -4
  10. data/lib/action_controller/metal/redirecting.rb +58 -22
  11. data/lib/action_controller/metal/request_forgery_protection.rb +40 -35
  12. data/lib/action_controller/metal/strong_parameters.rb +61 -20
  13. data/lib/action_controller/metal/testing.rb +9 -0
  14. data/lib/action_controller/railtie.rb +16 -10
  15. data/lib/action_controller/test_case.rb +19 -2
  16. data/lib/action_controller.rb +0 -1
  17. data/lib/action_dispatch/http/response.rb +0 -12
  18. data/lib/action_dispatch/http/url.rb +2 -9
  19. data/lib/action_dispatch/journey/nodes/node.rb +2 -2
  20. data/lib/action_dispatch/journey/route.rb +1 -1
  21. data/lib/action_dispatch/middleware/cookies.rb +1 -1
  22. data/lib/action_dispatch/middleware/executor.rb +3 -0
  23. data/lib/action_dispatch/middleware/host_authorization.rb +72 -35
  24. data/lib/action_dispatch/middleware/server_timing.rb +33 -0
  25. data/lib/action_dispatch/middleware/show_exceptions.rb +10 -0
  26. data/lib/action_dispatch/middleware/static.rb +0 -1
  27. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +1 -0
  28. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb +2 -0
  29. data/lib/action_dispatch/routing/inspector.rb +1 -1
  30. data/lib/action_dispatch/routing/mapper.rb +10 -6
  31. data/lib/action_dispatch/routing/route_set.rb +5 -0
  32. data/lib/action_dispatch/system_test_case.rb +7 -1
  33. data/lib/action_dispatch/system_testing/browser.rb +2 -12
  34. data/lib/action_dispatch/system_testing/driver.rb +13 -9
  35. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +1 -1
  36. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +0 -8
  37. data/lib/action_dispatch/testing/test_process.rb +1 -27
  38. data/lib/action_dispatch.rb +1 -0
  39. data/lib/action_pack/gem_version.rb +1 -1
  40. metadata +16 -15
  41. data/lib/action_controller/metal/query_tags.rb +0 -16
@@ -146,7 +146,7 @@ module ActionDispatch
146
146
  end
147
147
 
148
148
  requirements, conditions = split_constraints ast.path_params, constraints
149
- verify_regexp_requirements requirements.map(&:last).grep(Regexp)
149
+ verify_regexp_requirements requirements, ast.wildcard_options
150
150
 
151
151
  formats = normalize_format(formatted)
152
152
 
@@ -246,14 +246,18 @@ module ActionDispatch
246
246
  end
247
247
  end
248
248
 
249
- def verify_regexp_requirements(requirements)
250
- requirements.each do |requirement|
251
- if ANCHOR_CHARACTERS_REGEX.match?(requirement.source)
249
+ def verify_regexp_requirements(requirements, wildcard_options)
250
+ requirements.each do |requirement, regex|
251
+ next unless regex.is_a? Regexp
252
+
253
+ if ANCHOR_CHARACTERS_REGEX.match?(regex.source)
252
254
  raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}"
253
255
  end
254
256
 
255
- if requirement.multiline?
256
- raise ArgumentError, "Regexp multiline option is not allowed in routing requirements: #{requirement.inspect}"
257
+ if regex.multiline?
258
+ next if wildcard_options.key?(requirement)
259
+
260
+ raise ArgumentError, "Regexp multiline option is not allowed in routing requirements: #{regex.inspect}"
257
261
  end
258
262
  end
259
263
  end
@@ -820,6 +820,11 @@ module ActionDispatch
820
820
 
821
821
  route_with_params = generate(route_name, path_options, recall)
822
822
  path = route_with_params.path(method_name)
823
+
824
+ if options[:trailing_slash] && !options[:format] && !path.end_with?("/")
825
+ path += "/"
826
+ end
827
+
823
828
  params = route_with_params.params
824
829
 
825
830
  if options.key? :params
@@ -115,6 +115,8 @@ module ActionDispatch
115
115
  include SystemTesting::TestHelpers::SetupAndTeardown
116
116
  include SystemTesting::TestHelpers::ScreenshotHelper
117
117
 
118
+ DEFAULT_HOST = "http://127.0.0.1"
119
+
118
120
  def initialize(*) # :nodoc:
119
121
  super
120
122
  self.class.driven_by(:selenium) unless self.class.driver?
@@ -166,7 +168,11 @@ module ActionDispatch
166
168
  include ActionDispatch.test_app.routes.mounted_helpers
167
169
 
168
170
  def url_options
169
- default_url_options.reverse_merge(host: Capybara.app_host || Capybara.current_session.server_url)
171
+ default_url_options.reverse_merge(host: app_host)
172
+ end
173
+
174
+ def app_host
175
+ Capybara.app_host || Capybara.current_session.server_url || DEFAULT_HOST
170
176
  end
171
177
  end.new
172
178
  end
@@ -33,19 +33,9 @@ module ActionDispatch
33
33
  def preload
34
34
  case type
35
35
  when :chrome
36
- if ::Selenium::WebDriver::Service.respond_to? :driver_path=
37
- ::Selenium::WebDriver::Chrome::Service.driver_path&.call
38
- else
39
- # Selenium <= v3.141.0
40
- ::Selenium::WebDriver::Chrome.driver_path
41
- end
36
+ ::Selenium::WebDriver::Chrome::Service.driver_path&.call
42
37
  when :firefox
43
- if ::Selenium::WebDriver::Service.respond_to? :driver_path=
44
- ::Selenium::WebDriver::Firefox::Service.driver_path&.call
45
- else
46
- # Selenium <= v3.141.0
47
- ::Selenium::WebDriver::Firefox.driver_path
48
- end
38
+ ::Selenium::WebDriver::Firefox::Service.driver_path&.call
49
39
  end
50
40
  end
51
41
 
@@ -3,13 +3,16 @@
3
3
  module ActionDispatch
4
4
  module SystemTesting
5
5
  class Driver # :nodoc:
6
- def initialize(name, **options, &capabilities)
7
- @name = name
6
+ attr_reader :name
7
+
8
+ def initialize(driver_type, **options, &capabilities)
9
+ @driver_type = driver_type
8
10
  @screen_size = options[:screen_size]
9
11
  @options = options[:options] || {}
12
+ @name = @options.delete(:name) || driver_type
10
13
  @capabilities = capabilities
11
14
 
12
- if [:poltergeist, :webkit].include?(name)
15
+ if [:poltergeist, :webkit].include?(driver_type)
13
16
  ActiveSupport::Deprecation.warn <<~MSG.squish
14
17
  Poltergeist and capybara-webkit are not maintained already.
15
18
  Driver registration of :poltergeist or :webkit is deprecated and will be removed in Rails 7.1.
@@ -17,7 +20,8 @@ module ActionDispatch
17
20
  MSG
18
21
  end
19
22
 
20
- if name == :selenium
23
+ if driver_type == :selenium
24
+ gem "selenium-webdriver", ">= 4.0.0"
21
25
  require "selenium/webdriver"
22
26
  @browser = Browser.new(options[:using])
23
27
  @browser.preload
@@ -34,14 +38,14 @@ module ActionDispatch
34
38
 
35
39
  private
36
40
  def registerable?
37
- [:selenium, :poltergeist, :webkit, :cuprite, :rack_test].include?(@name)
41
+ [:selenium, :poltergeist, :webkit, :cuprite, :rack_test].include?(@driver_type)
38
42
  end
39
43
 
40
44
  def register
41
45
  @browser&.configure(&@capabilities)
42
46
 
43
- Capybara.register_driver @name do |app|
44
- case @name
47
+ Capybara.register_driver name do |app|
48
+ case @driver_type
45
49
  when :selenium then register_selenium(app)
46
50
  when :poltergeist then register_poltergeist(app)
47
51
  when :webkit then register_webkit(app)
@@ -52,7 +56,7 @@ module ActionDispatch
52
56
  end
53
57
 
54
58
  def browser_options
55
- @options.merge(options: @browser.options).compact
59
+ @options.merge(capabilities: @browser.options).compact
56
60
  end
57
61
 
58
62
  def register_selenium(app)
@@ -80,7 +84,7 @@ module ActionDispatch
80
84
  end
81
85
 
82
86
  def setup
83
- Capybara.current_driver = @name
87
+ Capybara.current_driver = name
84
88
  end
85
89
  end
86
90
  end
@@ -42,7 +42,7 @@ module ActionDispatch
42
42
  #
43
43
  # +take_failed_screenshot+ is called during system test teardown.
44
44
  def take_failed_screenshot
45
- take_screenshot if failed? && supports_screenshot?
45
+ take_screenshot if failed? && supports_screenshot? && Capybara::Session.instance_created?
46
46
  end
47
47
 
48
48
  private
@@ -4,14 +4,6 @@ module ActionDispatch
4
4
  module SystemTesting
5
5
  module TestHelpers
6
6
  module SetupAndTeardown # :nodoc:
7
- def host!(host)
8
- ActiveSupport::Deprecation.warn \
9
- "ActionDispatch::SystemTestCase#host! is deprecated with no replacement. " \
10
- "Set Capybara.app_host directly or rely on Capybara's default host."
11
-
12
- Capybara.app_host = host
13
- end
14
-
15
7
  def before_teardown
16
8
  take_failed_screenshot
17
9
  ensure
@@ -17,33 +17,7 @@ module ActionDispatch
17
17
  #
18
18
  # post :change_avatar, params: { avatar: fixture_file_upload('david.png', 'image/png', :binary) }
19
19
  def fixture_file_upload(path, mime_type = nil, binary = false)
20
- if self.class.respond_to?(:fixture_path) && self.class.fixture_path &&
21
- !File.exist?(path)
22
- original_path = path
23
- path = Pathname.new(self.class.fixture_path).join(path)
24
-
25
- if !self.class.file_fixture_path
26
- ActiveSupport::Deprecation.warn(<<~EOM)
27
- Passing a path to `fixture_file_upload` relative to `fixture_path` is deprecated.
28
- In Rails 7.0, the path needs to be relative to `file_fixture_path` which you
29
- haven't set yet. Set `file_fixture_path` to discard this warning.
30
- EOM
31
- elsif path.exist?
32
- non_deprecated_path = Pathname(File.absolute_path(path)).relative_path_from(Pathname(File.absolute_path(self.class.file_fixture_path)))
33
-
34
- if Pathname(original_path) != non_deprecated_path
35
- ActiveSupport::Deprecation.warn(<<~EOM)
36
- Passing a path to `fixture_file_upload` relative to `fixture_path` is deprecated.
37
- In Rails 7.0, the path needs to be relative to `file_fixture_path`.
38
-
39
- Please modify the call from
40
- `fixture_file_upload("#{original_path}")` to `fixture_file_upload("#{non_deprecated_path}")`.
41
- EOM
42
- end
43
- else
44
- path = file_fixture(original_path)
45
- end
46
- elsif self.class.file_fixture_path && !File.exist?(path)
20
+ if self.class.file_fixture_path && !File.exist?(path)
47
21
  path = file_fixture(path)
48
22
  end
49
23
 
@@ -67,6 +67,7 @@ module ActionDispatch
67
67
  autoload :PublicExceptions
68
68
  autoload :Reloader
69
69
  autoload :RemoteIp
70
+ autoload :ServerTiming
70
71
  autoload :ShowExceptions
71
72
  autoload :SSL
72
73
  autoload :Static
@@ -10,7 +10,7 @@ module ActionPack
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
12
  TINY = 0
13
- PRE = "alpha2"
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0.alpha2
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-15 00:00:00.000000000 Z
11
+ date: 2021-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 7.0.0.alpha2
19
+ version: 7.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 7.0.0.alpha2
26
+ version: 7.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -98,28 +98,28 @@ dependencies:
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 7.0.0.alpha2
101
+ version: 7.0.0
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - '='
107
107
  - !ruby/object:Gem::Version
108
- version: 7.0.0.alpha2
108
+ version: 7.0.0
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: activemodel
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - '='
114
114
  - !ruby/object:Gem::Version
115
- version: 7.0.0.alpha2
115
+ version: 7.0.0
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - '='
121
121
  - !ruby/object:Gem::Version
122
- version: 7.0.0.alpha2
122
+ version: 7.0.0
123
123
  description: Web apps on Rails. Simple, battle-tested conventions for building and
124
124
  testing MVC web applications. Works with any Rack-compatible server.
125
125
  email: david@loudthinking.com
@@ -173,7 +173,6 @@ files:
173
173
  - lib/action_controller/metal/parameter_encoding.rb
174
174
  - lib/action_controller/metal/params_wrapper.rb
175
175
  - lib/action_controller/metal/permissions_policy.rb
176
- - lib/action_controller/metal/query_tags.rb
177
176
  - lib/action_controller/metal/redirecting.rb
178
177
  - lib/action_controller/metal/renderers.rb
179
178
  - lib/action_controller/metal/rendering.rb
@@ -239,6 +238,7 @@ files:
239
238
  - lib/action_dispatch/middleware/reloader.rb
240
239
  - lib/action_dispatch/middleware/remote_ip.rb
241
240
  - lib/action_dispatch/middleware/request_id.rb
241
+ - lib/action_dispatch/middleware/server_timing.rb
242
242
  - lib/action_dispatch/middleware/session/abstract_store.rb
243
243
  - lib/action_dispatch/middleware/session/cache_store.rb
244
244
  - lib/action_dispatch/middleware/session/cookie_store.rb
@@ -310,10 +310,11 @@ licenses:
310
310
  - MIT
311
311
  metadata:
312
312
  bug_tracker_uri: https://github.com/rails/rails/issues
313
- changelog_uri: https://github.com/rails/rails/blob/v7.0.0.alpha2/actionpack/CHANGELOG.md
314
- documentation_uri: https://api.rubyonrails.org/v7.0.0.alpha2/
313
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.0/actionpack/CHANGELOG.md
314
+ documentation_uri: https://api.rubyonrails.org/v7.0.0/
315
315
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
316
- source_code_uri: https://github.com/rails/rails/tree/v7.0.0.alpha2/actionpack
316
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.0/actionpack
317
+ rubygems_mfa_required: 'true'
317
318
  post_install_message:
318
319
  rdoc_options: []
319
320
  require_paths:
@@ -325,12 +326,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
325
326
  version: 2.7.0
326
327
  required_rubygems_version: !ruby/object:Gem::Requirement
327
328
  requirements:
328
- - - ">"
329
+ - - ">="
329
330
  - !ruby/object:Gem::Version
330
- version: 1.3.1
331
+ version: '0'
331
332
  requirements:
332
333
  - none
333
- rubygems_version: 3.1.6
334
+ rubygems_version: 3.2.32
334
335
  signing_key:
335
336
  specification_version: 4
336
337
  summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActionController
4
- module QueryTags # :nodoc:
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- around_action :expose_controller_to_query_logs
9
- end
10
-
11
- private
12
- def expose_controller_to_query_logs(&block)
13
- ActiveRecord::QueryLogs.set_context(controller: self, &block)
14
- end
15
- end
16
- end