1. 11 10月, 2016 1 次提交
    • P
      ActionController::Parameters#deep_dup (#26567) · f80ddf30
      Pavel Evstigneev 提交于
      * ActionController::Parameters#deep_dup
      
      * Tests for ActionController::Parameters#deep_dup
      
      * Fix test for ActionController::Parameters#deep_dup
      
      * More tests for ActionController::Parameters#deep_dup
      
      [Rafael Mendonça França + Pavel Evstigneev]
      f80ddf30
  2. 10 10月, 2016 2 次提交
  3. 07 9月, 2016 1 次提交
    • Y
      call `.to_h` to avoid using deprecated method · 700c5583
      yuuji.yaginuma 提交于
      `ActionController::Parameters#merge` call `HashWithIndifferentAccess#merge`.
      In addition, it calls `HashWithIndifferentAccess#update` from
      `HashWithIndifferentAccess#merge`,  where it is called the `#to_hash` of argument.
      But `ActionController::Parameters#to_hash` is deprecated, warning message is
      displayed.
      To avoid this, modify to convert object to `Hash`.
      
      Fixes #26415
      700c5583
  4. 01 9月, 2016 1 次提交
  5. 31 8月, 2016 1 次提交
  6. 16 8月, 2016 1 次提交
  7. 10 8月, 2016 1 次提交
  8. 08 8月, 2016 1 次提交
    • X
      code gardening: removes redundant selfs · a9dc4545
      Xavier Noria 提交于
      A few have been left for aesthetic reasons, but have made a pass
      and removed most of them.
      
      Note that if the method `foo` returns an array, `foo << 1`
      is a regular push, nothing to do with assignments, so
      no self required.
      a9dc4545
  9. 07 8月, 2016 1 次提交
  10. 02 8月, 2016 4 次提交
    • K
      Move the YAML hook closer to `init_with`. · b71732c8
      Kasper Timm Hansen 提交于
      Looked odd, so completely detached from the other necessary part of
      the implementation.
      b71732c8
    • K
      Replace implicit formats with a case statement. · 0e0cff0f
      Kasper Timm Hansen 提交于
      The coder that Psych passes in has a `tag` method we can use to detect
      which serialization format we're reviving for. Use it and make it clearer
      alongside the `load_tags` fiddling.
      0e0cff0f
    • K
      Let Psych 2.0.9+ deserialize 2.0.8 serialized parameters. · 6eb97823
      Kasper Timm Hansen 提交于
      If we were to serialize an `ActionController::Parameters` on Psych 2.0.8, we'd get:
      
      ```yaml
      --- !ruby/hash:ActionController::Parameters
      key: :value
      ```
      
      Because 2.0.8 didn't store instance variables, while 2.0.9 did:
      https://github.com/tenderlove/psych/commit/8f84ad0fc711a82a1040def861cb121e8985fd4c
      
      That, coupled with 2.0.8 calling `new` instead of `allocate` meant parameters was
      deserialized just fine:
      https://github.com/tenderlove/psych/commit/af308f8307899cb9e1c0fffea4bce3110a1c3926
      
      However, if users have 2.0.8 serialized parameters, then upgrade to Psych 2.0.9+ and
      Rails 5, it would start to blow up because `initialize` will never be called, and thus
      `@parameters` will never be assigned. Hello, `NoMethodErrors` on `NilClass`! :)
      
      To fix this we register another variant of the previous serialization format and take
      it into account in `init_with`.
      
      I've tested this in our app and previously raising code now deserializes like a champ.
      I'm unsure how to test this in our suite because we use Psych 2.0.8 and don't know how
      to make us use 2.0.9+ for just one test.
      6eb97823
    • K
      Make Parameters support legacy YAML encodings. · 31448f2b
      Kasper Timm Hansen 提交于
      By changing ActionController::Parameter's superclass, Rails 5 also changed
      the YAML serialization format.
      
      Since YAML doesn't know how to handle parameters it would fallback to its
      routine for the superclass, which in Rails 4.2 was Hash while just Object
      in Rails 5. As evident in the tags YAML would spit out:
      
      4.2: !ruby/hash-with-ivars:ActionController::Parameters
      5.0: !ruby/object:ActionController::Parameters
      
      Thus when loading parameters YAML from 4.2 in Rails 5, it would parse a
      hash dump as it would an Object class.
      
      To fix this we have to provide our own `init_with` to be aware of the past
      format as well as the new one. Then we add a `load_tags` mapping, such that
      when the YAML parser sees `!ruby/hash-with-ivars:ActionController::Parameters`,
      it knows to call our `init_with` function and not try to instantiate it as
      a normal hash subclass.
      31448f2b
  11. 09 7月, 2016 1 次提交
    • T
      Trust `Object#dup` in `ActionController::Parameters`, using `#initialize_copy`... · 96070595
      Tim Rogers 提交于
      Trust `Object#dup` in `ActionController::Parameters`, using `#initialize_copy` to manually duplicate the underlying parameters hash
      
      It looks like `ActionController::Parameters#dup` is leftover from when the class inherited from `Hash`. We can just trust `#dup`, which already copies the `@permitted` instance variable (confirmed by tests). We still define a `#initialize_copy` to make `@parameters` a copy that can be mutated without affecting the original instance.
      96070595
  12. 07 7月, 2016 1 次提交
    • T
      Changes to a dupped `ActionController::Parameters` mutate the original · ba3dd5ca
      Tim Rogers 提交于
      When `ActionController::Parameters` is duplicated with `#dup`, it doesn't create a duplicate of the instance variables (e.g. `@parameters`) but rather maintains the reference (see <http://ruby-doc.org/core-2.3.1/Object.html>). Given that the parameters object is often manipulated as if it were a hash (e.g. with `#delete` and similar methods), this leads to unexpected behaviour, like the following:
      
      ```
      params = ActionController::Parameters.new(foo: "bar")
      duplicated_params = params.dup
      duplicated_params.delete(:foo)
      
      params == duplicated_params
      ```
      
      This fixes the bug by defining a private `#initialize_copy` method, used internally by `#dup`, which makes a copy of `@parameters`.
      ba3dd5ca
  13. 23 6月, 2016 2 次提交
  14. 29 5月, 2016 1 次提交
  15. 28 5月, 2016 1 次提交
  16. 01 5月, 2016 1 次提交
  17. 15 4月, 2016 1 次提交
  18. 24 3月, 2016 1 次提交
  19. 13 3月, 2016 1 次提交
  20. 12 3月, 2016 1 次提交
  21. 10 3月, 2016 2 次提交
  22. 24 2月, 2016 1 次提交
  23. 19 2月, 2016 2 次提交
  24. 18 2月, 2016 1 次提交
  25. 17 2月, 2016 1 次提交
  26. 15 2月, 2016 1 次提交
  27. 28 1月, 2016 1 次提交
  28. 22 1月, 2016 1 次提交
  29. 20 1月, 2016 3 次提交
  30. 13 1月, 2016 1 次提交
  31. 12 1月, 2016 1 次提交