aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | Merge pull request #23682 from ShikChen/fast_strxorSantiago Pastorino2016-02-211-1/+2
|\ \ \ \ | | | | | | | | | | Improve the performance of string xor operation
| * | | | Improve the performance of string xor operationshik2016-02-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use `each_byte` instead of `bytes` to speed up string xor operation and reduce object allocations. Inspired by commit 02c3867882d6d23b10df262a6db5f937ca69fb53. ``` ruby require 'benchmark/ips' require 'allocation_tracer' a = 32.times.map { rand(256) }.pack('C*') b = 32.times.map { rand(256) }.pack('C*') def xor_byte_strings1(s1, s2) s1.bytes.zip(s2.bytes).map { |(c1,c2)| c1 ^ c2 }.pack('c*') end def xor_byte_strings2(s1, s2) s2_bytes = s2.bytes s1.bytes.map.with_index { |c1, i| c1 ^ s2_bytes[i] }.pack('c*') end def xor_byte_strings3(s1, s2) s2_bytes = s2.bytes s1.each_byte.with_index { |c1, i| s2_bytes[i] ^= c1 } s2_bytes.pack('C*') end fail if xor_byte_strings1(a, b) != xor_byte_strings2(a, b) fail if xor_byte_strings1(a, b) != xor_byte_strings3(a, b) Benchmark.ips do |x| x.report('xor_byte_strings1') { xor_byte_strings1(a, b) } x.report('xor_byte_strings2') { xor_byte_strings2(a, b) } x.report('xor_byte_strings3') { xor_byte_strings3(a, b) } x.compare! end Tracer = ObjectSpace::AllocationTracer Tracer.setup(%i{type}) p xor_byte_strings1: Tracer.trace { xor_byte_strings1(a, b) } p xor_byte_strings2: Tracer.trace { xor_byte_strings2(a, b) } p xor_byte_strings3: Tracer.trace { xor_byte_strings3(a, b) } ``` ``` Warming up -------------------------------------- xor_byte_strings1 10.668k i/100ms xor_byte_strings2 11.814k i/100ms xor_byte_strings3 13.139k i/100ms Calculating ------------------------------------- xor_byte_strings1 116.667k (± 3.1%) i/s - 586.740k xor_byte_strings2 129.932k (± 4.3%) i/s - 649.770k xor_byte_strings3 142.506k (± 4.2%) i/s - 722.645k Comparison: xor_byte_strings3: 142506.3 i/s xor_byte_strings2: 129932.4 i/s - 1.10x slower xor_byte_strings1: 116666.8 i/s - 1.22x slower {:xor_byte_strings1=>{[:T_ARRAY]=>[38, 0, 0, 0, 0, 0], [:T_STRING]=>[2, 0, 0, 0, 0, 0]}} {:xor_byte_strings2=>{[:T_ARRAY]=>[3, 0, 0, 0, 0, 0], [:T_DATA]=>[1, 0, 0, 0, 0, 0], [:T_IMEMO]=>[2, 0, 0, 0, 0, 0], [:T_STRING]=>[2, 0, 0, 0, 0, 0]}} {:xor_byte_strings3=>{[:T_ARRAY]=>[1, 0, 0, 0, 0, 0], [:T_DATA]=>[1, 0, 0, 0, 0, 0], [:T_IMEMO]=>[2, 0, 0, 0, 0, 0], [:T_STRING]=>[2, 0, 0, 0, 0, 0]}} ```
* | | | | Merge pull request #23695 from kaspth/remove-automatic-collection-cachingKasper Timm Hansen2016-02-202-17/+6
|\ \ \ \ \ | |_|/ / / |/| | | | Make collection caching explicit.
| * | | | Make collection caching explicit.Kasper Timm Hansen2016-02-202-17/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having collection caching that wraps templates and automatically tries to infer if they are cachable proved to be too much of a hassle. We'd rather have it be something you explicitly turn on. This removes much of the code and docs to explain the previous automatic behavior. This change also removes scoped cache keys and passing cache_options.
* | | | | Deprecate AC::Parameters#== with a HashBenjamin Quorning2016-02-192-11/+18
| | | | |
* | | | | Fix AC::Parameters#== with other AC::ParametersBenjamin Quorning2016-02-192-3/+37
| | | | | | | | | | | | | | | | | | | | Creating a protected getter method for `@parameters`.
* | | | | Tests for AC::Parameters#==Benjamin Quorning2016-02-191-0/+6
| | | | |
* | | | | Fix master buildJon Moss2016-02-181-1/+1
|/ / / /
* | | | fields_for_style needs to test for AC::ParametersAaron Patterson2016-02-172-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While iterating an AC::Parameters object, the object will mutate itself and stick AC::Parameters objects where there used to be hashes: https://github.com/rails/rails/blob/f57092ad728fa1de06c4f5fd9d09dcc2c4738fd9/actionpack/lib/action_controller/metal/strong_parameters.rb#L632 If you use `permit` after this iteration, the `fields_for_style` method wouldn't return true because the child objects are now AC::Parameters objects rather than Hashes. fixes #23701
* | | | partially revert 69009f4473637a44ade26d954ef5ddea6ff903f2Aaron Patterson2016-02-171-4/+1
| | | | | | | | | | | | | | | | | | | | we need to continue setting the body on the request object because of Fiber based streaming templates. Fixes #23659
* | | | Implement ActionController::Parameters#inspectBenjamin Quorning2016-02-172-1/+14
| | | | | | | | | | | | | | | | Now that AC::Parameters is no longer a Hash, it shouldn't look like a hash.
* | | | Merge pull request #23729 from maclover7/rm-unused-journeyRafael França2016-02-172-8/+0
|\ \ \ \ | | | | | | | | | | Remove unused Journey code
| * | | | Remove unused Journey codeJon Moss2016-02-172-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - `VERSION` shouldn't be there anymore since Journey is technically part of Action Dispatch now (and thus Action Pack, and follows the normal Rails versioning scheme) - `backwards.rb` was only in the file tree because early in the history or Journey (back in 2011!), it was moved from under the Rack namespace, to its own namespace, Journey! This file is no longer required, and is assigning constants that are no longer needed.
* | | | | Fix typoRafael Mendonça França2016-02-171-1/+1
| | | | |
* | | | | Merge pull request #23712 from ↵Rafael França2016-02-172-10/+3
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | bf4/incorrect_to_accept_json_api_and_not_render_spec The JSON API media type should only work wih a JSON API handler
| * | | | | The JSON API media type should only work wih a JSON API handlerBenjamin Fleischer2016-02-162-10/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the media type 'application/vnd.api+json' is a spec, it is inappropriate to handle it with the JSON renderer. This PR removes support for a JSON API media type. I would recommend the media type be registered on its own as `jsonapi` when a jsonapi Renderer and deserializer (Http::Parameters::DEFAULT_PARSERS) are added. Is related to work in https://github.com/rails/rails/pull/21496
* | | | | | Fix code styleRafael Mendonça França2016-02-171-3/+4
| |/ / / / |/| | | | | | | | | | | | | | This change was added in #23203 and it was not conforming our code style.
* | | | | Merge pull request #23661 from meinac/add_gzip_mime_typeRichard Schneeman2016-02-163-1/+6
|\ \ \ \ \ | | | | | | | | | | | | application/gzip added as default mime type into mime type list
| * | | | | application/gzip added as default mime type into mime type listMehmet Emin İNAÇ2016-02-133-1/+6
| | | | | |
* | | | | | Merge pull request #23203 from vipulnsward/22979-show-tags-on-exceptionRichard Schneeman2016-02-161-7/+11
|\ \ \ \ \ \ | |_|/ / / / |/| | | | | WIP: Errors in logs should show log tags as well.
| * | | | | WIP: Errors in logs should show log tags as well.Vipul A M2016-02-121-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Changed formatted_code_for to return array of logs to be tagged for each line - Changed some render tests to match new behaviour of return Fixes #22979
* | | | | | Merge pull request #23692 from abhishekjain16/docsYves Senn2016-02-163-3/+3
|\ \ \ \ \ \ | | | | | | | | | | | | | | Use a URL instead of an URL everywhere
| * | | | | | Use a URL instead of an URL everywhereAbhishek Jain2016-02-153-3/+3
| | | | | | |
* | | | | | | Remove unused test controller actionAndrew White2016-02-161-5/+0
| | | | | | |
* | | | | | | Join values using '; ' as per RFC specAndrew White2016-02-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Multiple cookie values should be separated by '; ' according to RFC 6265, section 5.4.4[1]. [1]: https://tools.ietf.org/html/rfc6265#section-5.4
* | | | | | | Add require and move escape to private methodAndrew White2016-02-161-1/+6
| | | | | | |
* | | | | | | Move test for #22828 into it's own testAndrew White2016-02-161-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `cookies` hash isn't updated with the value generated by the output from `to_header` so it wasn't testing anything. Rendering the cookie value in the controller makes sure that the escaping is actually working.
* | | | | | | Merge branch 'should-escape-cookie' of https://github.com/ma2gedev/rails ↵Andrew White2016-02-162-1/+8
|\ \ \ \ \ \ \ | |_|_|_|_|_|/ |/| | | | | | | | | | | | | into ma2gedev-should-escape-cookie
| * | | | | | Escape cookie's key and value in ActionController::TestCaseTakayuki Matsubara2015-12-302-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Get an incorrect cookie value in controller action method if cookie value contains an escapable string.
* | | | | | | Corrected secret_key_basevs4vijay2016-02-151-1/+1
| |_|_|_|/ / |/| | | | |
* | | | | | Remove `const_missing` which fallback to deprecated `NEVER_UNPERMITTED_PARAMS`Ryuta Kamizono2016-02-152-16/+0
| |_|_|/ / |/| | | | | | | | | | | | | | `NEVER_UNPERMITTED_PARAMS` is deprecated in Rails 4.2. See #15933.
* | | | | Only write to collection cache if we have a callable cache key.Kasper Timm Hansen2016-02-121-15/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A callable cache key writes to the collection cache under a certain namespace. Which means if we don't have scoped cache key we can just rely on the `cache model_name do` in the templates to cache them. Less writes, more sharing. Add `assert_customer_cached` to better illustrate this in tests, and remove tests which then don't communicate as much.
* | | | | Check `partial_rendered_times` to clarify expectations.Kasper Timm Hansen2016-02-121-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | It was difficult to see when the partials were rendered, and how many times we expected it to be rendered before. Because we weren't explaining it.
* | | | | Test collection caching with callable cache key.Kasper Timm Hansen2016-02-121-0/+25
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | When people pass `cache: -> item { item.upcase }` they scope the collection cache keys so the individual partial cache isn't reused. Test that behavior.
* | | | Merge pull request #23611 from abhishekjain16/routes_optionsKasper Timm Hansen2016-02-121-2/+3
|\ \ \ \ | | | | | | | | | | Fix routes to match verb and URL path with -g option also.
| * | | | Fixes routes to match verbs and path with -g optionAbhishek Jain2016-02-111-2/+3
| | | | |
* | | | | Add fixes accidentally removed.Kasper Timm Hansen2016-02-123-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Yesterday, when improving how `parsed_body` extracted a parser I wrote 77bbf1e. Then I thought that was too many changes in one commit and broke it up locally... or so I thought. When pushed the extra commits removed the changes! Wups! In shame, lob those changes together here: * 3b94c38 which meant to fix the CHANGELOG syntax error. * 5007df5 which meant to mention `parsed_body` in the docs. * 036a7a0 which meant to memoize the `parsed_body`.
* | | | | Flesh out request encoding + response parsing changelog entry.Kasper Timm Hansen2016-02-121-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add more info about the APIs added and how they work. Use string keys when comparing the parsed response, like how JSON would be parsed.
* | | | | use rails instead of rakeGaurav Sharma2016-02-121-2/+2
| |_|/ / |/| | | | | | | since starting with Rails 5.x(beta) we prefer to use rails as the replacement of rake commands, may be change log will be the same
* | | | Merge pull request #23612 from vipulnsward/23561-fix-routes-argsKasper Timm Hansen2016-02-122-4/+2
|\ \ \ \ | | | | | | | | | | Fix argument passing to rake routes
| * | | | - Fixed and removed long arguments to rake routesVipul A M2016-02-122-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Fixed related documentation and usage all around Fixes #23561
* | | | | Memoize `parsed_body`.Kasper Timm Hansen2016-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's common to use several assertions on the parsed response. The response bodies aren't meant to be mutated. People should make new test requests instead. Thus, it should be safe to memoize the parsing.
* | | | | [ci skip] Mention `parsed_body` in docs.Kasper Timm Hansen2016-02-111-2/+1
| | | | | | | | | | | | | | | | | | | | Little easier to understand when you know the method that's used.
* | | | | [ci skip] Fix syntax error in CHANGELOG example.Kasper Timm Hansen2016-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | Can't code for shit.
* | | | | Make `parsed_body` extract parser from the content type.Kasper Timm Hansen2016-02-114-6/+20
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | We're not guaranteed to have a `RequestEncoder` to assign on `get` requests because we aren't extracting the parser from the response content type. Until now.
* | | | Add request encoding and response parsing to changelog.Kasper Timm Hansen2016-02-101-0/+38
| | | | | | | | | | | | | | | | | | | | Forgot to add this in the original pull request. No biggie, just show some examples.
* | | | Add `parsed_body` to spare writing out parsing routines.Kasper Timm Hansen2016-02-103-23/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When testing: ```ruby post articles_path, params: { article: { title: 'Ahoy!' } }, as: :json ``` It's common to want to make assertions on the response body. Perhaps the server responded with JSON, so you write `JSON.parse(response.body)`. But that gets tedious real quick. Instead add `parsed_body` which will automatically parse the reponse body as what the last request was encoded `as`.
* | | | Merge pull request #21671 from kaspth/integration-request-encoding-helpersDavid Heinemeier Hansson2016-02-102-4/+122
|\ \ \ \ | |/ / / |/| | | Add `as` to encode a request as a specific mime type.
| * | | Add `as` to encode a request as a specific mime type.Kasper Timm Hansen2016-01-042-4/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Turns ``` post articles_path(format: :json), params: { article: { name: 'Ahoy!' } }.to_json, headers: { 'Content-Type' => 'application/json' } ``` into ``` post articles_path, params: { article: { name: 'Ahoy!' } }, as: :json ```
* | | | `log_process_action` will return an array, so use `empty?`Aaron Patterson2016-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | We don't need to use active support in this case because we know the type that will be returned.