Commit Graph

14125 Commits

Author SHA1 Message Date
bogdanvlviv
ceadda2e94
Fix rubocop violations
https://codeclimate.com/github/rails/rails/issues

`bundle exec rubocop -a`

Related to e4e1b62007fe40c4277ebc30067837a91bf25967
2018-06-15 11:21:33 +03:00
Justin Searls
0eff45db7d
Remove reference to session_store.rb initializer
Rails no longer generates this file, but Google is still packed with results 
suggesting it should exist, so that the doc still pointed me to it threw me 
off (had I deleted it or something?). Probably be better to be vague and
prompt the user to stick it in a config file they own.

#33124
2018-06-12 06:36:52 -04:00
Dan Jensen
7dbc6d6979 Fix bug with eager_load in development environment
Modifies the routes simulator to allow for empty RouteSets, which are
created when secondary Engines are loaded.
2018-06-11 15:54:25 -04:00
Aaron Patterson
e4e1b62007
Use Rack to generate query information under test
`to_query` sorts parameters before encoding them.  This causes a round
tripping issue as noted here:

  https://github.com/rails/rails/issues/23997#issuecomment-328297933
  https://github.com/rails/rails/issues/10529#issuecomment-328298109
  https://github.com/rails/rails/pull/30558

Unfortunately, that method is being used to generate cache keys, so its
results need to be stable:

  10dec0e65e

However, the test harness is only using `to_query` to encode parameters
before sending them to the controller so the "cache key" usecase doesn't
apply here.

This commit adds a test that demonstrates the round trip problems and
changes the serialization strategy to use Rack for encoding the
parameters rather than `to_query`.
2018-06-08 17:08:16 +09:00
Ryuta Kamizono
e2e053608e Avoid unused capture in non_xhr_javascript_response? 2018-05-31 09:00:14 +09:00
Gabriel Jaldon
d3a2c53955 Include application/javascript when checking content_type 2018-05-27 16:17:53 +02:00
utilum
0428ed8067 Remove 7 years old note-to-self by tenderlove
Introduced in rails/journey@a806beb

[ci skip]
2018-05-22 21:55:41 +02:00
Jeremy Evans
8b10a9414d Speed up xor_byte_strings by 70%
Benchmark:

```ruby
require 'benchmark'
require 'benchmark/ips'
require 'securerandom'

def xor_byte_strings(s1, s2) # :doc:
  s2_bytes = s2.bytes
  s1.each_byte.with_index { |c1, i| s2_bytes[i] ^= c1 }
  s2_bytes.pack("C*")
end

def xor_byte_strings_new(s1, s2) # :doc:
  s2 = s2.dup
  size = s1.bytesize
  i = 0
  while i < size
    s2.setbyte(i, s1.getbyte(i) ^ s2.getbyte(i))
    i += 1
  end
  s2
end

s1 = SecureRandom.random_bytes(32)
s2 = SecureRandom.random_bytes(32)

Benchmark.ips do |x|
  x.report("current"){xor_byte_strings(s1, s2)}
  x.report("new"){xor_byte_strings_new(s1, s2)}
  x.compare!
end

100000.times do |i|
  s3 = SecureRandom.random_bytes(32)
  s4 = SecureRandom.random_bytes(32)
  raise unless xor_byte_strings(s3, s4) == xor_byte_strings_new(s3, s4)
end
```

Results on ruby 2.5.1:

```
Warming up --------------------------------------
             current     6.519k i/100ms
                 new    10.508k i/100ms
Calculating -------------------------------------
             current     84.723k (_ 0.4%) i/s -    423.735k in   5.001456s
                 new    145.871k (_ 0.3%) i/s -    735.560k in   5.042606s

Comparison:
                 new:   145870.6 i/s
             current:    84723.4 i/s - 1.72x  slower
```
2018-05-18 15:08:38 -07:00
Linus Marton
8d5e0d3f5b
Fix documentation for ActionController::Params#fetch
Make it clear that the return value is converted to an
instance of ActionController::Parameters if possible
2018-05-18 10:03:42 +02:00
Ryuta Kamizono
1dc17e7b2e Fix CustomCops/AssertNot to allow it to have failure message
Follow up of #32605.
2018-05-13 11:32:47 +09:00
Ryuta Kamizono
f4bb51789a
Merge pull request #29955 from padi/update_actiondispatch_integration_docs
Updates documentation on ActionDispatch::Integration::Session#process

[ci skip]
2018-05-04 17:35:55 +09:00
yuuji.yaginuma
1007191f31 Add support for prefetch-src directive
Specification: https://w3c.github.io/webappsec-csp/#directive-prefetch-src

This directive can already be used as an experimental feature in Chrome.
Ref: https://bugs.chromium.org/p/chromium/issues/detail?id=801561
2018-05-03 15:46:03 +09:00
George Claghorn
a42fb70a15
Merge pull request #32773 from eugeneius/content_length_multiple_requests
Reset CONTENT_LENGTH between test requests
2018-04-30 22:48:10 -04:00
Eddie Lebow
95e9a28cdc Add quotes to code in rdoc comment in ActionController [ci skip]
The example code is meant to be a string.
2018-04-30 21:35:51 -04:00
Eugene Kenny
f9e14b02c4 Reset CONTENT_LENGTH between test requests
If a POST request is followed by a GET request in a controller test, the
`rack.input` and `RAW_POST_DATA` headers from the first request will be
reset but the `CONTENT_LENGTH` header will leak, leading the request
object in the second request to incorrectly believe it has a body.
2018-05-01 01:24:32 +01:00
vaidehijoshi
91f9d255b8 Break up Journey's scanner test
This breaks up the one megatest for Journey's scanner into multiple test
cases, which also provides better output when there is a failure in the
scanner.

Before:

```
./bin/test test/journey/route/definition/scanner_test.rb
Run options: --seed 778

F

Failure:
ActionDispatch::Journey::Definition::TestScanner#test_tokens [/Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:57]:
--- expected
+++ actual
@@ -1 +1 @@
-[[:SLASH, "/"], [:LITERAL, "page!!"]]
+[[:SLASH, "/"], [:LITERAL, "page!"]]

bin/test Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:14

Finished in 0.090899s, 11.0012 runs/s, 44.0049 assertions/s.
1 runs, 4 assertions, 1 failures, 0 errors, 0 skips
```

After:

```
./bin/test test/journey/route/definition/scanner_test.rb
Run options: --seed 2230

....................F

Failure:
ActionDispatch::Journey::Definition::TestScanner#test_scanning_/page$ [/Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:58]:
Wrong tokens for `/page$`.
--- expected
+++ actual
@@ -1 +1 @@
-[[:SLASH, "/"], [:LITERAL, "page$$"]]
+[[:SLASH, "/"], [:LITERAL, "page$"]]

bin/test Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:56

F

Failure:
ActionDispatch::Journey::Definition::TestScanner#test_scanning_/page! [/Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:58]:
Wrong tokens for `/page!`.
--- expected
+++ actual
@@ -1 +1 @@
-[[:SLASH, "/"], [:LITERAL, "page!!"]]
+[[:SLASH, "/"], [:LITERAL, "page!"]]

bin/test Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:56

F

Failure:
ActionDispatch::Journey::Definition::TestScanner#test_scanning_/page& [/Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:58]:
Wrong tokens for `/page&`.
--- expected
+++ actual
@@ -1 +1 @@
-[[:SLASH, "/"], [:LITERAL, "page&&"]]
+[[:SLASH, "/"], [:LITERAL, "page&"]]

bin/test Users/vaidehijoshi/Code/tilde/rails/actionpack/test/journey/route/definition/scanner_test.rb:56

Finished in 0.126447s, 181.8944 runs/s, 181.8944 assertions/s.
23 runs, 23 assertions, 3 failures, 0 errors, 0 skips
```
2018-04-24 15:39:01 -07:00
Andrew White
a3ecf4ff1d
Merge pull request #32708 from bdewater/base64-screenshot
Use strict_encode64 instead of gsub newline for ScreenshotHelper
2018-04-24 05:09:29 +01:00
Bart de Water
7a5886b2b8 Use strict_encode64 instead of gsub newline for ScreenshotHelper 2018-04-23 22:45:14 -04:00
yuuji.yaginuma
c991ebbc91 Use the same tag as other views to display the error message
Since other views use the `h2` tag, should also use `h2` on
`missing_exact_template.html.erb`.

76acaf6eb9/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb (L5)
76acaf6eb9/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb (L11)
76acaf6eb9/actionpack/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb (L5)
2018-04-23 07:32:53 +09:00
Ryuta Kamizono
222f20eb19
Merge pull request #32681 from bdewater/rubocop-0-54
Rubocop 0.54
2018-04-22 13:27:36 +09:00
Bart de Water
999e7ec505 Fix Style/RedundantReturn offenses 2018-04-21 13:23:42 -04:00
Eugene Kenny
7a8d9649cd Reset RAW_POST_DATA between test requests
`RAW_POST_DATA` is derived from the `rack.input` header, which changes
with each test request. It needs to be cleared in `scrub_env!`, or all
requests within the same test will see the value from the first request.
2018-04-20 19:56:28 -04:00
Rafael Mendonça França
5033e2c082
Merge pull request #29286 from vinistock/create_missing_exact_template_exception
Create MissingExactTemplate exception with separate template
2018-04-20 16:39:02 -04:00
Rafael França
248197370c
Merge pull request #32665 from albertoalmagro/fix-typos-filter-parameters
Fix typos related to ActionDispatch::Http::FilterParameters
2018-04-20 11:44:10 -04:00
Rafael França
357559feea
Merge pull request #23868 from gsamokovarov/debug-exceptions-interceptors
Introduce ActionDispatch::DebugExceptions interceptors
2018-04-20 11:31:38 -04:00
Vinicius Stock
297a579de4 Create MissingExactTemplate exception with separate template 2018-04-20 11:01:05 -03:00
Genadi Samokovarov
d25fba89d4 Introduce ActionDispatch::DebugExceptions interceptors
Plugins interacting with the exceptions caught and displayed by
ActionDispatch::DebugExceptions currently have to monkey patch it to get
the much needed exception for their calculation.

With DebugExceptions.register_interceptor, plugin authors can hook into
DebugExceptions and process the exception, before being rendered. They
can store it into the request and process it on the way back of the
middleware chain execution or act on it straight in the interceptor.

The interceptors can be play blocks, procs, lambdas or any object that
responds to `#call`.
2018-04-20 14:55:37 +03:00
Alberto Almagro
78d00b079e [ci skip] Fix doc typos ActionDispatch::Http::FilterParameters
Fixes two documentation typos found at ActionDispatch::Http::FilterParameters
2018-04-20 13:22:48 +02:00
utilum
951383bd9a warning: ambiguous first argument; put parentheses or a space even after `/' operator 2018-04-20 12:57:17 +02:00
Rafael Mendonça França
7a9098fa15
Revert "Merge pull request #32652 from bogdanvlviv/add-missing-changelog-for-32593"
This reverts commit 78ff47f3e77925f72d98579da6feb68f36052ad8, reversing
changes made to daffe03308bffc43ea343a886aab33082d83bb9c.

That changelog entry should only be on 5-2-stable
2018-04-19 23:07:53 -04:00
bogdanvlviv
888dda875b
Add missing changelog entry
https://github.com/rails/rails/pull/32593 was backported to
`5-2-stable` but since 5.2.0 is released the changelog entry should
be in Rails 6.0.0 too.

[ci skip]
2018-04-20 01:50:30 +03:00
Rafael França
fca08b8167
Merge pull request #32636 from yhirano55/improve_line_tasks
Improve redundancy in line tasks
2018-04-19 15:36:23 -04:00
Rafael Mendonça França
0bf3e769e7
Merge pull request #32593 from sdhull/fix-strong-params-permit-bang
Fixes StrongParameters `permit!` to work with nested arrays
2018-04-19 15:05:27 -04:00
Rafael França
6fec9c27e5
Merge pull request #32605 from composerinteralia/assert-not
Add RuboCop for `assert_not` over `assert !`
2018-04-19 15:03:28 -04:00
Yoshiyuki Hirano
6aaeb8ef10 Improve redundancy in line tasks
* Remove needless concat from actionpack/Rakefile
* Remove neesless File.join from actionview/Rakefile
2018-04-19 23:45:28 +09:00
Daniel Colson
a1ac18671a Replace assert ! with assert_not
This autocorrects the violations after adding a custom cop in
3305c78dcd.
2018-04-19 08:11:33 -04:00
bogdanvlviv
698332cf85
Fix reference to fixed issue in actionpack/CHANGELOG.md
Pull Request #32602 fixes Issue #32597.

[ci skip]
2018-04-19 11:50:09 +03:00
Andrew White
0ac549a49a
Remove unused literal introduced in #32602 2018-04-18 07:19:44 -04:00
Andrew White
0d70e3900d
Don't link issue number in CHANGELOG [ci skip] 2018-04-18 07:18:00 -04:00
Andrew White
35970cbf3f
Pass nonce to CSP policy from outside 2018-04-18 10:51:02 +03:00
Andrey Novikov
b9b660728f
Output only one nonce in CSP header per request 2018-04-17 12:56:26 +03:00
Steve Hull
e539f2d585 Fixes StrongParameters permit! to work with nested arrays
`permit!` is intended to mark all instances of `ActionController::Parameters` as permitted, however nested arrays of params were not being marked permitted because the method did shallow iteration.
This fixes that by flattening the array before calling `permit!` on all each item.
2018-04-16 14:38:20 -07:00
Chris Arcand
72486005dd
Fix broken nodocs
This commit fixes all references in the codebase missing a trailing :,
which causes the nodoc not to actually work :) [skip ci]
2018-04-13 14:55:59 -05:00
George Claghorn
4f99a21864
Fix rendering a differently-formatted partial after caching 2018-04-13 14:43:12 -04:00
Stephen Solis
01d857b09a Add WebSocket URI support to CSP DSL mappings 2018-04-12 12:44:11 -04:00
Rafael França
6e4e692ee0
Merge pull request #32484 from kddeisz/default-headers
Include default headers by default in API mode
2018-04-10 19:10:52 -04:00
eileencodes
72f17d59e4 Remove upper bound on Capybara
There's no reason to block future versions of Capybara since we don't
_know_ they are going to break. How will we know if we have a
conservative option set? This change prevents us from blocking users who
want to upgrade in the future.
2018-04-10 16:40:14 -04:00
bogdanvlviv
125b71db22
Add TestCaseTest#test_request_format_kwarg_doesnt_mutate_params to master
Initially, the test was added to 5-0-stable in #32492
and a bit modified in #32506. This test ensures that request(in tests)
doesn't mutate params. It was fixed since v5.1.0.beta1 by
98b8309569a326910a723f521911e54994b112fb and then on 5-0-stable by #32492.
This commit adds this test to master branch in order to prevent any
regressions.
2018-04-10 05:17:47 +03:00
Rafael Mendonça França
601e31b362
Merge pull request #32488 from swrobel/patch-4
Only disable headless chrome gpu on Windows
2018-04-09 15:46:37 -04:00
Patrik Bóna
34ab9982dc Improve the null origin error message 2018-04-09 12:26:24 +02:00