Class: ActionController::TestSession
- Inherits:
-
Rack::Session::Abstract::PersistedSecure::SecureSessionHash
- Object
- Rack::Session::Abstract::PersistedSecure::SecureSessionHash
- ActionController::TestSession
- Defined in:
- lib/action_controller/test_case.rb
Overview
Methods #destroy and #load! are overridden to avoid calling methods on the
Constant Summary collapse
- DEFAULT_OPTIONS =
:nodoc:
Rack::Session::Abstract::Persisted::DEFAULT_OPTIONS
Instance Method Summary collapse
- #destroy ⇒ Object
- #dig(*keys) ⇒ Object
- #enabled? ⇒ Boolean
- #exists? ⇒ Boolean
- #fetch(key, *args, &block) ⇒ Object
- #id_was ⇒ Object
-
#initialize(session = {}, id = Rack::Session::SessionId.new(SecureRandom.hex(16))) ⇒ TestSession
constructor
A new instance of TestSession.
- #keys ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(session = {}, id = Rack::Session::SessionId.new(SecureRandom.hex(16))) ⇒ TestSession
Returns a new instance of TestSession.
190 191 192 193 194 195 196 |
# File 'lib/action_controller/test_case.rb', line 190 def initialize(session = {}, id = Rack::Session::SessionId.new(SecureRandom.hex(16))) super(nil, nil) @id = id @data = stringify_keys(session) @loaded = true @initially_empty = @data.empty? end |
Instance Method Details
#destroy ⇒ Object
210 211 212 |
# File 'lib/action_controller/test_case.rb', line 210 def destroy clear end |
#dig(*keys) ⇒ Object
214 215 216 217 |
# File 'lib/action_controller/test_case.rb', line 214 def dig(*keys) keys = keys.map.with_index { |key, i| i.zero? ? key.to_s : key } @data.dig(*keys) end |
#enabled? ⇒ Boolean
223 224 225 |
# File 'lib/action_controller/test_case.rb', line 223 def enabled? true end |
#exists? ⇒ Boolean
198 199 200 |
# File 'lib/action_controller/test_case.rb', line 198 def exists? true end |
#fetch(key, *args, &block) ⇒ Object
219 220 221 |
# File 'lib/action_controller/test_case.rb', line 219 def fetch(key, *args, &block) @data.fetch(key.to_s, *args, &block) end |
#id_was ⇒ Object
227 228 229 |
# File 'lib/action_controller/test_case.rb', line 227 def id_was @id end |
#keys ⇒ Object
202 203 204 |
# File 'lib/action_controller/test_case.rb', line 202 def keys @data.keys end |
#values ⇒ Object
206 207 208 |
# File 'lib/action_controller/test_case.rb', line 206 def values @data.values end |