actionpack 5.2.0.beta2 → 5.2.0.rc1

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 (32) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +47 -4
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +3 -3
  5. data/lib/action_controller/metal.rb +8 -10
  6. data/lib/action_controller/metal/force_ssl.rb +2 -2
  7. data/lib/action_controller/metal/redirecting.rb +1 -1
  8. data/lib/action_controller/metal/request_forgery_protection.rb +11 -0
  9. data/lib/action_controller/metal/streaming.rb +1 -1
  10. data/lib/action_controller/metal/strong_parameters.rb +1 -1
  11. data/lib/action_controller/test_case.rb +1 -1
  12. data/lib/action_dispatch.rb +1 -1
  13. data/lib/action_dispatch/http/cache.rb +1 -1
  14. data/lib/action_dispatch/http/content_security_policy.rb +3 -5
  15. data/lib/action_dispatch/http/mime_types.rb +13 -0
  16. data/lib/action_dispatch/http/url.rb +1 -1
  17. data/lib/action_dispatch/journey/nfa/dot.rb +10 -10
  18. data/lib/action_dispatch/middleware/exception_wrapper.rb +1 -0
  19. data/lib/action_dispatch/middleware/request_id.rb +1 -1
  20. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +21 -0
  21. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +13 -0
  22. data/lib/action_dispatch/railtie.rb +4 -1
  23. data/lib/action_dispatch/routing/mapper.rb +3 -3
  24. data/lib/action_dispatch/routing/route_set.rb +10 -0
  25. data/lib/action_dispatch/system_test_case.rb +10 -2
  26. data/lib/action_dispatch/system_testing/browser.rb +49 -0
  27. data/lib/action_dispatch/system_testing/driver.rb +3 -15
  28. data/lib/action_dispatch/system_testing/server.rb +1 -1
  29. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +6 -10
  30. data/lib/action_pack.rb +1 -1
  31. data/lib/action_pack/gem_version.rb +1 -1
  32. metadata +14 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dc7cea7b72a28f8b23a591f15cff558cd172013b
4
- data.tar.gz: '08c06ad7911cf4fcf9e41dcd854f2f8c3dc9fc4e'
2
+ SHA256:
3
+ metadata.gz: 252948a97023ff044a61ba6b4eace0810b36e6ed5b01687cdc402af4125c79b6
4
+ data.tar.gz: 16b93ec8e09990a9db1d0073c2836a0766fe7457b7c3d8671988421860bc6704
5
5
  SHA512:
6
- metadata.gz: 14ccbecb7a91c51d938bbab6c83161f122245047ee7d0d4180a1ffebb83f81f5c91bf4dbd04c9874a7d7b66957d1f1540989cb2ad2169c08c56f6742bcec961f
7
- data.tar.gz: 38753f6fec63ec5b2f5ead65f1652172c7aae22a110ae017057ad5eee2327373d3f390a0d85017485065f842f9ff80e20b13242cbbacee4ff257ece39e12b9fb
6
+ metadata.gz: a148db40d3edfe126926e6866ce0167083f2adbaafb5d1144e32784cb51c80f344a5e28b957577cd0b51653505c6318620107047d02e77c5758f2869932a30b9
7
+ data.tar.gz: 1e26f9ccc1bc7e7e2f1cff24486c1f1a2c84971004023758a50cd3907ad1ab44ebf244ec48d4af9886b7f885c7792715736c601affed74d68a29c680463914b7
@@ -1,3 +1,46 @@
1
+ ## Rails 5.2.0.rc1 (January 30, 2018) ##
2
+
3
+ * Add `Referrer-Policy` header to default headers set.
4
+
5
+ *Guillermo Iguaran*
6
+
7
+ * Changed the system tests to set Puma as default server only when the
8
+ user haven't specified manually another server.
9
+
10
+ *Guillermo Iguaran*
11
+
12
+ * Add secure `X-Download-Options` and `X-Permitted-Cross-Domain-Policies` to
13
+ default headers set.
14
+
15
+ *Guillermo Iguaran*
16
+
17
+ * Add headless firefox support to System Tests.
18
+
19
+ *bogdanvlviv*
20
+
21
+ * Changed the default system test screenshot output from `inline` to `simple`.
22
+
23
+ `inline` works well for iTerm2 but not everyone uses iTerm2. Some terminals like
24
+ Terminal.app ignore the `inline` and output the path to the file since it can't
25
+ render the image. Other terminals, like those on Ubuntu, cannot handle the image
26
+ inline, but also don't handle it gracefully and instead of outputting the file
27
+ path, it dumps binary into the terminal.
28
+
29
+ Commit 9d6e28 fixes this by changing the default for screenshot to be `simple`.
30
+
31
+ *Eileen M. Uchitelle*
32
+
33
+ * Register most popular audio/video/font mime types supported by modern browsers.
34
+
35
+ *Guillermo Iguaran*
36
+
37
+ * Fix optimized url helpers when using relative url root
38
+
39
+ Fixes #31220.
40
+
41
+ *Andrew White*
42
+
43
+
1
44
  ## Rails 5.2.0.beta2 (November 28, 2017) ##
2
45
 
3
46
  * No changes.
@@ -74,9 +117,9 @@
74
117
  *Rafael Mendonça França*
75
118
 
76
119
  * Add `:allow_other_host` option to `redirect_back` method.
77
- When `allow_other_host` is set to `false`, the `redirect_back`
78
- will not allow a redirecting from a different host.
79
- `allow_other_host` is `true` by default.
120
+
121
+ When `allow_other_host` is set to `false`, the `redirect_back` will not allow redirecting from a
122
+ different host. `allow_other_host` is `true` by default.
80
123
 
81
124
  *Tim Masliuchenko*
82
125
 
@@ -135,7 +178,7 @@
135
178
 
136
179
  *Yuji Yaginuma*
137
180
 
138
- * Deprecate `ActionDispatch::TestResponse` response aliases
181
+ * Deprecate `ActionDispatch::TestResponse` response aliases.
139
182
 
140
183
  `#success?`, `#missing?` & `#error?` are not supported by the actual
141
184
  `ActionDispatch::Response` object and can produce false-positives. Instead,
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2017 David Heinemeier Hansson
1
+ Copyright (c) 2004-2018 David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -30,7 +30,7 @@ The latest version of Action Pack can be installed with RubyGems:
30
30
 
31
31
  $ gem install actionpack
32
32
 
33
- Source code can be downloaded as part of the Rails project on GitHub
33
+ Source code can be downloaded as part of the Rails project on GitHub:
34
34
 
35
35
  * https://github.com/rails/rails/tree/master/actionpack
36
36
 
@@ -44,11 +44,11 @@ Action Pack is released under the MIT license:
44
44
 
45
45
  == Support
46
46
 
47
- API documentation is at
47
+ API documentation is at:
48
48
 
49
49
  * http://api.rubyonrails.org
50
50
 
51
- Bug reports can be filed for the Ruby on Rails project here:
51
+ Bug reports for the Ruby on Rails project can be filed here:
52
52
 
53
53
  * https://github.com/rails/rails/issues
54
54
 
@@ -230,18 +230,16 @@ module ActionController
230
230
 
231
231
  # Returns a Rack endpoint for the given action name.
232
232
  def self.action(name)
233
+ app = lambda { |env|
234
+ req = ActionDispatch::Request.new(env)
235
+ res = make_response! req
236
+ new.dispatch(name, req, res)
237
+ }
238
+
233
239
  if middleware_stack.any?
234
- middleware_stack.build(name) do |env|
235
- req = ActionDispatch::Request.new(env)
236
- res = make_response! req
237
- new.dispatch(name, req, res)
238
- end
240
+ middleware_stack.build(name, app)
239
241
  else
240
- lambda { |env|
241
- req = ActionDispatch::Request.new(env)
242
- res = make_response! req
243
- new.dispatch(name, req, res)
244
- }
242
+ app
245
243
  end
246
244
  end
247
245
 
@@ -39,7 +39,7 @@ module ActionController
39
39
  # end
40
40
  #
41
41
  # ==== URL Options
42
- # You can pass any of the following options to affect the redirect url
42
+ # You can pass any of the following options to affect the redirect URL
43
43
  # * <tt>host</tt> - Redirect to a different host name
44
44
  # * <tt>subdomain</tt> - Redirect to a different subdomain
45
45
  # * <tt>domain</tt> - Redirect to a different domain
@@ -73,7 +73,7 @@ module ActionController
73
73
  # Redirect the existing request to use the HTTPS protocol.
74
74
  #
75
75
  # ==== Parameters
76
- # * <tt>host_or_options</tt> - Either a host name or any of the url and
76
+ # * <tt>host_or_options</tt> - Either a host name or any of the URL and
77
77
  # redirect options available to the <tt>force_ssl</tt> method.
78
78
  def force_ssl_redirect(host_or_options = nil)
79
79
  unless request.ssl?
@@ -83,7 +83,7 @@ module ActionController
83
83
  #
84
84
  # ==== Options
85
85
  # * <tt>:fallback_location</tt> - The default fallback location that will be used on missing +Referer+ header.
86
- # * <tt>:allow_other_host</tt> - Allows or disallow redirection to the host that is different to the current host
86
+ # * <tt>:allow_other_host</tt> - Allow or disallow redirection to the host that is different to the current host, defaults to true.
87
87
  #
88
88
  # All other options that can be passed to <tt>redirect_to</tt> are accepted as
89
89
  # options and the behavior is identical.
@@ -3,6 +3,7 @@
3
3
  require "rack/session/abstract/id"
4
4
  require "action_controller/metal/exceptions"
5
5
  require "active_support/security_utils"
6
+ require "active_support/core_ext/string/strip"
6
7
 
7
8
  module ActionController #:nodoc:
8
9
  class InvalidAuthenticityToken < ActionControllerError #:nodoc:
@@ -415,11 +416,21 @@ module ActionController #:nodoc:
415
416
  allow_forgery_protection
416
417
  end
417
418
 
419
+ NULL_ORIGIN_MESSAGE = <<-MSG.strip_heredoc
420
+ The browser returned a 'null' origin for a request with origin-based forgery protection turned on. This usually
421
+ means you have the 'no-referrer' Referrer-Policy header enabled, or that you the request came from a site that
422
+ refused to give its origin. This makes it impossible for Rails to verify the source of the requests. Likely the
423
+ best solution is to change your referrer policy to something less strict like same-origin or strict-same-origin.
424
+ If you cannot change the referrer policy, you can disable origin checking with the
425
+ Rails.application.config.action_controller.forgery_protection_origin_check setting.
426
+ MSG
427
+
418
428
  # Checks if the request originated from the same origin by looking at the
419
429
  # Origin header.
420
430
  def valid_request_origin? # :doc:
421
431
  if forgery_protection_origin_check
422
432
  # We accept blank origin headers because some user agents don't send it.
433
+ raise InvalidAuthenticityToken, NULL_ORIGIN_MESSAGE if request.origin == "null"
423
434
  request.origin.nil? || request.origin == request.base_url
424
435
  else
425
436
  true
@@ -183,7 +183,7 @@ module ActionController #:nodoc:
183
183
  # unicorn_rails --config-file unicorn.config.rb
184
184
  #
185
185
  # You may also want to configure other parameters like <tt>:tcp_nodelay</tt>.
186
- # Please check its documentation for more information: http://unicorn.bogomips.org/Unicorn/Configurator.html#method-i-listen
186
+ # Please check its documentation for more information: https://bogomips.org/unicorn/Unicorn/Configurator.html#method-i-listen
187
187
  #
188
188
  # If you are using Unicorn with NGINX, you may need to tweak NGINX.
189
189
  # Streaming should work out of the box on Rainbows.
@@ -335,7 +335,7 @@ module ActionController
335
335
  # the same way as <tt>Hash#each_pair</tt>.
336
336
  def each_pair(&block)
337
337
  @parameters.each_pair do |key, value|
338
- yield key, convert_hashes_to_parameters(key, value)
338
+ yield [key, convert_hashes_to_parameters(key, value)]
339
339
  end
340
340
  end
341
341
  alias_method :each, :each_pair
@@ -256,7 +256,7 @@ module ActionController
256
256
  #
257
257
  # def test_create
258
258
  # json = {book: { title: "Love Hina" }}.to_json
259
- # post :create, json
259
+ # post :create, body: json
260
260
  # end
261
261
  #
262
262
  # == Special instance variables
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # Copyright (c) 2004-2017 David Heinemeier Hansson
4
+ # Copyright (c) 2004-2018 David Heinemeier Hansson
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
7
7
  # a copy of this software and associated documentation files (the
@@ -133,7 +133,7 @@ module ActionDispatch
133
133
  end
134
134
 
135
135
  def generate_strong_etag(validators)
136
- %("#{Digest::MD5.hexdigest(ActiveSupport::Cache.expand_cache_key(validators))}")
136
+ %("#{ActiveSupport::Digest.hexdigest(ActiveSupport::Cache.expand_cache_key(validators))}")
137
137
  end
138
138
 
139
139
  def cache_control_segments
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support/core_ext/object/deep_dup"
4
+
3
5
  module ActionDispatch #:nodoc:
4
6
  class ContentSecurityPolicy
5
7
  class Middleware
@@ -110,7 +112,7 @@ module ActionDispatch #:nodoc:
110
112
  end
111
113
 
112
114
  def initialize_copy(other)
113
- @directives = copy_directives(other.directives)
115
+ @directives = other.directives.deep_dup
114
116
  end
115
117
 
116
118
  DIRECTIVES.each do |name, directive|
@@ -174,10 +176,6 @@ module ActionDispatch #:nodoc:
174
176
  end
175
177
 
176
178
  private
177
- def copy_directives(directives)
178
- directives.transform_values { |sources| sources.map(&:dup) }
179
- end
180
-
181
179
  def apply_mappings(sources)
182
180
  sources.map do |source|
183
181
  case source
@@ -10,6 +10,7 @@ Mime::Type.register "text/css", :css
10
10
  Mime::Type.register "text/calendar", :ics
11
11
  Mime::Type.register "text/csv", :csv
12
12
  Mime::Type.register "text/vcard", :vcf
13
+ Mime::Type.register "text/vtt", :vtt, %w(vtt)
13
14
 
14
15
  Mime::Type.register "image/png", :png, [], %w(png)
15
16
  Mime::Type.register "image/jpeg", :jpeg, [], %w(jpg jpeg jpe pjpeg)
@@ -20,6 +21,18 @@ Mime::Type.register "image/svg+xml", :svg
20
21
 
21
22
  Mime::Type.register "video/mpeg", :mpeg, [], %w(mpg mpeg mpe)
22
23
 
24
+ Mime::Type.register "audio/mpeg", :mp3, [], %w(mp1 mp2 mp3)
25
+ Mime::Type.register "audio/ogg", :ogg, [], %w(oga ogg spx opus)
26
+ Mime::Type.register "audio/aac", :m4a, %w( audio/mp4 ), %w(m4a mpg4 aac)
27
+
28
+ Mime::Type.register "video/webm", :webm, [], %w(webm)
29
+ Mime::Type.register "video/mp4", :mp4, [], %w(mp4 m4v)
30
+
31
+ Mime::Type.register "font/otf", :otf, [], %w(otf)
32
+ Mime::Type.register "font/ttf", :ttf, [], %w(ttf)
33
+ Mime::Type.register "font/woff", :woff, [], %w(woff)
34
+ Mime::Type.register "font/woff2", :woff2, [], %w(woff2)
35
+
23
36
  Mime::Type.register "application/xml", :xml, %w( text/xml application/x-xml )
24
37
  Mime::Type.register "application/rss+xml", :rss
25
38
  Mime::Type.register "application/atom+xml", :atom
@@ -274,7 +274,7 @@ module ActionDispatch
274
274
  def standard_port
275
275
  case protocol
276
276
  when "https://" then 443
277
- else 80
277
+ else 80
278
278
  end
279
279
  end
280
280
 
@@ -9,16 +9,16 @@ module ActionDispatch
9
9
  " #{from} -> #{to} [label=\"#{sym || 'ε'}\"];"
10
10
  }
11
11
 
12
- #memo_nodes = memos.values.flatten.map { |n|
13
- # label = n
14
- # if Journey::Route === n
15
- # label = "#{n.verb.source} #{n.path.spec}"
16
- # end
17
- # " #{n.object_id} [label=\"#{label}\", shape=box];"
18
- #}
19
- #memo_edges = memos.flat_map { |k, memos|
20
- # (memos || []).map { |v| " #{k} -> #{v.object_id};" }
21
- #}.uniq
12
+ # memo_nodes = memos.values.flatten.map { |n|
13
+ # label = n
14
+ # if Journey::Route === n
15
+ # label = "#{n.verb.source} #{n.path.spec}"
16
+ # end
17
+ # " #{n.object_id} [label=\"#{label}\", shape=box];"
18
+ # }
19
+ # memo_edges = memos.flat_map { |k, memos|
20
+ # (memos || []).map { |v| " #{k} -> #{v.object_id};" }
21
+ # }.uniq
22
22
 
23
23
  <<-eodot
24
24
  digraph nfa {
@@ -25,6 +25,7 @@ module ActionDispatch
25
25
  "ActionView::MissingTemplate" => "missing_template",
26
26
  "ActionController::RoutingError" => "routing_error",
27
27
  "AbstractController::ActionNotFound" => "unknown_action",
28
+ "ActiveRecord::StatementInvalid" => "invalid_statement",
28
29
  "ActionView::Template::Error" => "template_error"
29
30
  )
30
31
 
@@ -30,7 +30,7 @@ module ActionDispatch
30
30
  private
31
31
  def make_request_id(request_id)
32
32
  if request_id.presence
33
- request_id.gsub(/[^\w\-]/, "".freeze).first(255)
33
+ request_id.gsub(/[^\w\-@]/, "".freeze).first(255)
34
34
  else
35
35
  internal_request_id
36
36
  end
@@ -0,0 +1,21 @@
1
+ <header>
2
+ <h1>
3
+ <%= @exception.class.to_s %>
4
+ <% if @request.parameters['controller'] %>
5
+ in <%= @request.parameters['controller'].camelize %>Controller<% if @request.parameters['action'] %>#<%= @request.parameters['action'] %><% end %>
6
+ <% end %>
7
+ </h1>
8
+ </header>
9
+
10
+ <div id="container">
11
+ <h2>
12
+ <%= h @exception.message %>
13
+ <% if @exception.message.match? %r{#{ActiveStorage::Blob.table_name}|#{ActiveStorage::Attachment.table_name}} %>
14
+ <br />To resolve this issue run: bin/rails active_storage:install
15
+ <% end %>
16
+ </h2>
17
+
18
+ <%= render template: "rescues/_source" %>
19
+ <%= render template: "rescues/_trace" %>
20
+ <%= render template: "rescues/_request_and_response" %>
21
+ </div>
@@ -0,0 +1,13 @@
1
+ <%= @exception.class.to_s %><%
2
+ if @request.parameters['controller']
3
+ %> in <%= @request.parameters['controller'].camelize %>Controller<% if @request.parameters['action'] %>#<%= @request.parameters['action'] %><% end %>
4
+ <% end %>
5
+
6
+ <%= @exception.message %>
7
+ <% if @exception.message.match? %r{#{ActiveStorage::Blob.table_name}|#{ActiveStorage::Attachment.table_name}} %>
8
+ To resolve this issue run: bin/rails active_storage:install
9
+ <% end %>
10
+
11
+ <%= render template: "rescues/_source" %>
12
+ <%= render template: "rescues/_trace" %>
13
+ <%= render template: "rescues/_request_and_response" %>
@@ -26,7 +26,10 @@ module ActionDispatch
26
26
  config.action_dispatch.default_headers = {
27
27
  "X-Frame-Options" => "SAMEORIGIN",
28
28
  "X-XSS-Protection" => "1; mode=block",
29
- "X-Content-Type-Options" => "nosniff"
29
+ "X-Content-Type-Options" => "nosniff",
30
+ "X-Download-Options" => "noopen",
31
+ "X-Permitted-Cross-Domain-Policies" => "none",
32
+ "Referrer-Policy" => "strict-origin-when-cross-origin"
30
33
  }
31
34
 
32
35
  config.action_dispatch.cookies_rotations = ActiveSupport::Messages::RotationConfiguration.new
@@ -1573,7 +1573,7 @@ module ActionDispatch
1573
1573
  # Matches a URL pattern to one or more routes.
1574
1574
  # For more information, see match[rdoc-ref:Base#match].
1575
1575
  #
1576
- # match 'path' => 'controller#action', via: patch
1576
+ # match 'path' => 'controller#action', via: :patch
1577
1577
  # match 'path', to: 'controller#action', via: :post
1578
1578
  # match 'path', 'otherpath', on: :member, via: :get
1579
1579
  def match(path, *rest, &block)
@@ -2082,9 +2082,9 @@ module ActionDispatch
2082
2082
  # [ :products, options.merge(params.permit(:page, :size).to_h.symbolize_keys) ]
2083
2083
  # end
2084
2084
  #
2085
- # In this instance the +params+ object comes from the context in which the the
2085
+ # In this instance the +params+ object comes from the context in which the
2086
2086
  # block is executed, e.g. generating a URL inside a controller action or a view.
2087
- # If the block is executed where there isn't a params object such as this:
2087
+ # If the block is executed where there isn't a +params+ object such as this:
2088
2088
  #
2089
2089
  # Rails.application.routes.url_helpers.browse_path
2090
2090
  #
@@ -199,6 +199,16 @@ module ActionDispatch
199
199
  if args.size == arg_size && !inner_options && optimize_routes_generation?(t)
200
200
  options = t.url_options.merge @options
201
201
  options[:path] = optimized_helper(args)
202
+
203
+ original_script_name = options.delete(:original_script_name)
204
+ script_name = t._routes.find_script_name(options)
205
+
206
+ if original_script_name
207
+ script_name = original_script_name + script_name
208
+ end
209
+
210
+ options[:script_name] = script_name
211
+
202
212
  url_strategy.call options
203
213
  else
204
214
  super
@@ -6,6 +6,7 @@ require "capybara/dsl"
6
6
  require "capybara/minitest"
7
7
  require "action_controller"
8
8
  require "action_dispatch/system_testing/driver"
9
+ require "action_dispatch/system_testing/browser"
9
10
  require "action_dispatch/system_testing/server"
10
11
  require "action_dispatch/system_testing/test_helpers/screenshot_helper"
11
12
  require "action_dispatch/system_testing/test_helpers/setup_and_teardown"
@@ -69,6 +70,9 @@ module ActionDispatch
69
70
  # size of the browser screen. These two options are not applicable for
70
71
  # headless drivers and will be silently ignored if passed.
71
72
  #
73
+ # Headless browsers such as headless Chrome and headless Firefox are also supported.
74
+ # You can use these browsers by setting the +:using+ argument to +:headless_chrome+ or +:headless_firefox+.
75
+ #
72
76
  # To use a headless driver, like Poltergeist, update your Gemfile to use
73
77
  # Poltergeist instead of Selenium and then declare the driver name in the
74
78
  # +application_system_test_case.rb+ file. In this case, you would leave out
@@ -121,11 +125,15 @@ module ActionDispatch
121
125
  #
122
126
  # driven_by :poltergeist
123
127
  #
124
- # driven_by :selenium, using: :firefox
128
+ # driven_by :selenium, screen_size: [800, 800]
129
+ #
130
+ # driven_by :selenium, using: :chrome
125
131
  #
126
132
  # driven_by :selenium, using: :headless_chrome
127
133
  #
128
- # driven_by :selenium, screen_size: [800, 800]
134
+ # driven_by :selenium, using: :firefox
135
+ #
136
+ # driven_by :selenium, using: :headless_firefox
129
137
  def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400], options: {})
130
138
  self.driver = SystemTesting::Driver.new(driver, using: using, screen_size: screen_size, options: options)
131
139
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionDispatch
4
+ module SystemTesting
5
+ class Browser # :nodoc:
6
+ attr_reader :name
7
+
8
+ def initialize(name)
9
+ @name = name
10
+ end
11
+
12
+ def type
13
+ case name
14
+ when :headless_chrome
15
+ :chrome
16
+ when :headless_firefox
17
+ :firefox
18
+ else
19
+ name
20
+ end
21
+ end
22
+
23
+ def options
24
+ case name
25
+ when :headless_chrome
26
+ headless_chrome_browser_options
27
+ when :headless_firefox
28
+ headless_firefox_browser_options
29
+ end
30
+ end
31
+
32
+ private
33
+ def headless_chrome_browser_options
34
+ options = Selenium::WebDriver::Chrome::Options.new
35
+ options.args << "--headless"
36
+ options.args << "--disable-gpu"
37
+
38
+ options
39
+ end
40
+
41
+ def headless_firefox_browser_options
42
+ options = Selenium::WebDriver::Firefox::Options.new
43
+ options.args << "-headless"
44
+
45
+ options
46
+ end
47
+ end
48
+ end
49
+ end
@@ -5,7 +5,7 @@ module ActionDispatch
5
5
  class Driver # :nodoc:
6
6
  def initialize(name, **options)
7
7
  @name = name
8
- @browser = options[:using]
8
+ @browser = Browser.new(options[:using])
9
9
  @screen_size = options[:screen_size]
10
10
  @options = options[:options]
11
11
  end
@@ -32,23 +32,11 @@ module ActionDispatch
32
32
  end
33
33
 
34
34
  def browser_options
35
- if @browser == :headless_chrome
36
- browser_options = Selenium::WebDriver::Chrome::Options.new
37
- browser_options.args << "--headless"
38
- browser_options.args << "--disable-gpu"
39
-
40
- @options.merge(options: browser_options)
41
- else
42
- @options
43
- end
44
- end
45
-
46
- def browser
47
- @browser == :headless_chrome ? :chrome : @browser
35
+ @options.merge(options: @browser.options).compact
48
36
  end
49
37
 
50
38
  def register_selenium(app)
51
- Capybara::Selenium::Driver.new(app, { browser: browser }.merge(browser_options)).tap do |driver|
39
+ Capybara::Selenium::Driver.new(app, { browser: @browser.type }.merge(browser_options)).tap do |driver|
52
40
  driver.browser.manage.window.size = Selenium::WebDriver::Dimension.new(*@screen_size)
53
41
  end
54
42
  end
@@ -20,7 +20,7 @@ module ActionDispatch
20
20
  end
21
21
 
22
22
  def set_server
23
- Capybara.server = :puma, { Silent: self.class.silence_puma }
23
+ Capybara.server = :puma, { Silent: self.class.silence_puma } if Capybara.server == Capybara.servers[:default]
24
24
  end
25
25
 
26
26
  def set_port
@@ -15,12 +15,11 @@ module ActionDispatch
15
15
  #
16
16
  # You can set the +RAILS_SYSTEM_TESTING_SCREENSHOT+ environment variable to
17
17
  # control the output. Possible values are:
18
- # * [+inline+ (default)] display the screenshot in the terminal using the
18
+ # * [+simple+ (default)] Only displays the screenshot path.
19
+ # This is the default value.
20
+ # * [+inline+] Display the screenshot in the terminal using the
19
21
  # iTerm image protocol (https://iterm2.com/documentation-images.html).
20
- # * [+simple+] only display the screenshot path.
21
- # This is the default value if the +CI+ environment variables
22
- # is defined.
23
- # * [+artifact+] display the screenshot in the terminal, using the terminal
22
+ # * [+artifact+] Display the screenshot in the terminal, using the terminal
24
23
  # artifact format (https://buildkite.github.io/terminal/inline-images/).
25
24
  def take_screenshot
26
25
  save_image
@@ -59,11 +58,8 @@ module ActionDispatch
59
58
  # Environment variables have priority
60
59
  output_type = ENV["RAILS_SYSTEM_TESTING_SCREENSHOT"] || ENV["CAPYBARA_INLINE_SCREENSHOT"]
61
60
 
62
- # If running in a CI environment, default to simple
63
- output_type ||= "simple" if ENV["CI"]
64
-
65
- # Default
66
- output_type ||= "inline"
61
+ # Default to outputting a path to the screenshot
62
+ output_type ||= "simple"
67
63
 
68
64
  output_type
69
65
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # Copyright (c) 2004-2017 David Heinemeier Hansson
4
+ # Copyright (c) 2004-2018 David Heinemeier Hansson
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
7
7
  # a copy of this software and associated documentation files (the
@@ -10,7 +10,7 @@ module ActionPack
10
10
  MAJOR = 5
11
11
  MINOR = 2
12
12
  TINY = 0
13
- PRE = "beta2"
13
+ PRE = "rc1"
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: 5.2.0.beta2
4
+ version: 5.2.0.rc1
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: 2017-11-28 00:00:00.000000000 Z
11
+ date: 2018-01-30 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: 5.2.0.beta2
19
+ version: 5.2.0.rc1
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: 5.2.0.beta2
26
+ version: 5.2.0.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 5.2.0.beta2
95
+ version: 5.2.0.rc1
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 5.2.0.beta2
102
+ version: 5.2.0.rc1
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: activemodel
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 5.2.0.beta2
109
+ version: 5.2.0.rc1
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 5.2.0.beta2
116
+ version: 5.2.0.rc1
117
117
  description: Web apps on Rails. Simple, battle-tested conventions for building and
118
118
  testing MVC web applications. Works with any Rack-compatible server.
119
119
  email: david@loudthinking.com
@@ -245,6 +245,8 @@ files:
245
245
  - lib/action_dispatch/middleware/templates/rescues/_trace.text.erb
246
246
  - lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb
247
247
  - lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb
248
+ - lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb
249
+ - lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb
248
250
  - lib/action_dispatch/middleware/templates/rescues/layout.erb
249
251
  - lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb
250
252
  - lib/action_dispatch/middleware/templates/rescues/missing_template.text.erb
@@ -269,6 +271,7 @@ files:
269
271
  - lib/action_dispatch/routing/routes_proxy.rb
270
272
  - lib/action_dispatch/routing/url_for.rb
271
273
  - lib/action_dispatch/system_test_case.rb
274
+ - lib/action_dispatch/system_testing/browser.rb
272
275
  - lib/action_dispatch/system_testing/driver.rb
273
276
  - lib/action_dispatch/system_testing/server.rb
274
277
  - lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
@@ -290,8 +293,8 @@ homepage: http://rubyonrails.org
290
293
  licenses:
291
294
  - MIT
292
295
  metadata:
293
- source_code_uri: https://github.com/rails/rails/tree/v5.2.0.beta2/actionpack
294
- changelog_uri: https://github.com/rails/rails/blob/v5.2.0.beta2/actionpack/CHANGELOG.md
296
+ source_code_uri: https://github.com/rails/rails/tree/v5.2.0.rc1/actionpack
297
+ changelog_uri: https://github.com/rails/rails/blob/v5.2.0.rc1/actionpack/CHANGELOG.md
295
298
  post_install_message:
296
299
  rdoc_options: []
297
300
  require_paths:
@@ -309,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
309
312
  requirements:
310
313
  - none
311
314
  rubyforge_project:
312
- rubygems_version: 2.6.12
315
+ rubygems_version: 2.7.3
313
316
  signing_key:
314
317
  specification_version: 4
315
318
  summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).