aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/request/session_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add #dig to ActionDispatch::Request::Sessionclaudiob2018-04-041-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary The `session` object is not a real Hash but responds to many methods of Hash such as `[]`, `[]`, `fetch`, `has_key?`. Since Ruby 2.3, Hash also supports a `dig` method. This commit adds a `dig` method to `ActionDispatch::Request::Session` with the same behavior as `Hash#dig`. This is useful if you store a hash in your session, such as: ```ruby session[:user] = { id: 1, avatar_url: "http://example.org/nyancat.jpg" } ``` Then you can shorten your code from `session[:user][:avatar_url]` to `session.dig :user, :avatar_url`. ### Other Information I cherry-picked a commit from https://github.com/rails/rails/pull/23864, and modify a bit. The changes are below: * Converts only the first key to a string adjust to the `fetch` method. * Fixes a test case because we cannot use the indifferent access since ee5b621e2f8fde380ea4bc75b0b9d6f98499f511.
* Consistent behavior for session and cookies with to_h and to_hash methodIgor Kasyanchuk2018-01-311-0/+1
|
* Use frozen string literal in actionpack/Kir Shatrov2017-07-291-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Add lazy loading to #keys and #values methods in Sessioncodeforkjeff2017-04-261-0/+18
| | | | | | | This fixes a bug where session.keys and session.values return an empty array unless one of the other methods that does lazy loading from the underlying store is called first. #keys and #values should also call #load_for_read!
* Add three new rubocop rulesRafael Mendonça França2016-08-161-2/+2
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-7/+7
|
* modernizes hash syntax in actionpackXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in actionpack/testXavier Noria2016-08-061-30/+30
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Ensure compatibility between ActionDispatch::Request::Session and RackJon Moss2016-05-041-0/+26
| | | | | | | | | | | | | | Adding the `each` method is required for ensuring compatibility between Rails, and other Rack frameworks (like Sinatra, etc.), that are mounted within Rails, and wish to use its session tooling. Prior to this, there was an inconsistency between ActionDispatch::Request::Session and Rack::Session::Cookie, due to the absence of the `each` method. This should hopefully fix that error. :) For a full integration test with Sinatra and a standalone Rack application, you can check out the gist for that here: https://gist.github.com/maclover7/08cd95b0bfe259465314311941326470. Solves #15843.
* Revert "Merge pull request #20851 from tomprats/indifferent-sessions"Matthew Draper2016-02-261-10/+0
| | | | | | | This reverts commit 22db455dbe9c26fe6d723cac0758705d9943ea4b, reversing changes made to 40be61dfda1e04c3f306022a40370862e3a2ce39. This finishes off what I meant to do in 6216a092ccfe6422f113db906a52fe8ffdafdbe6.
* Revert "Update Session to utilize indiffernt access"Matthew Draper2016-02-261-1/+1
| | | | | | | | | | | This reverts commit 45a75a3fcc96b22954caf69be2df4e302b134d7a. HWIAs are better than silently deeply-stringified hashes... but that's a reaction to a shortcoming of one particular session store: we should not break the basic behaviour of other, more featureful, session stores in the process. Fixes #23884
* Update Session to utilize indiffernt accessTom Prats2016-01-301-1/+1
|
* Update session to have indifferent accessTom Prats2016-01-291-0/+10
|
* Push `before_sending` to super classeileencodes2015-12-061-1/+1
| | | | | | | | | | | | We want to get rid of the `Live::Response` so we are consolidating methods from `Live::Response` and `Response` by merging them together. This adds an `#empty` method to the request so we don't need to hard-code the empty array each time we call an empty `ActionDispatch::Request`. The work here is a continuation on combining controller and integration test code bases into one.
* implement abstract store methodsAaron Patterson2015-09-041-1/+1
| | | | converts old ID methods to the new abstract store methods in Rack
* use a request object in the session middlewareAaron Patterson2015-08-221-19/+21
| | | | | This commit allows us to use one request object rather than allocating multiple request objects to deal with the session.
* point at rack masterAaron Patterson2015-08-201-1/+1
|
* Cleaning and adding tests for SessionAttila Domokos2014-03-191-7/+34
| | | Adding tests for Session `destroy`, `update` and `delete` methods. No changes for code under test.
* Make ActionDispatch::Request::Session#fetch behave like Hash#fetchTrent Ogren2013-12-111-3/+2
| | | | | | Session#fetch was mutating the session when given a default argument and/or a block. Since Session duck-types as a Hash, it should behave like one in these cases.
* session#fetch doesn't behave exactly like Hash#fetch.Damien Mathieu2013-10-301-1/+5
| | | | | | | | | Mention it in the changelog and add a test checking for regressions. Hash#fetch isn't adding the defaultly returned value. However, in the session, saving it is the behavior we should expect. See discussion in #12692
* add the fetch method to sessionsDamien Mathieu2013-10-291-0/+13
|
* Alias refute methods to assert_not and perfer assert_not on testsRafael Mendonça França2012-12-311-1/+1
|
* Add test for clear in ActionDispatch::Request::SessionAndreas Loupasakis2012-09-081-0/+9
|
* Added ActionDispatch::Request::Session#keys and ↵Philip Arndt2012-05-231-0/+16
| | | | ActionDispatch::Request::Session#values
* testing session store behaviorAaron Patterson2012-05-021-0/+48