Skip to content

Commit 4df235f

Browse files
authored
Merge pull request rails#53626 from viralpraxis/add-actiondispatch-request-session-store-method-to-conform-rack-spec
Add `ActionDispatch::Request::Session#store` method to conform Rack spec
2 parents 2ca3cb0 + 226d7c6 commit 4df235f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

actionpack/lib/action_dispatch/request/session.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def []=(key, value)
155155
load_for_write!
156156
@delegate[key.to_s] = value
157157
end
158+
alias store []=
158159

159160
# Clears the session.
160161
def clear

actionpack/test/dispatch/request/session_test.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ def test_destroy
5050
assert_empty s
5151
end
5252

53+
def test_store
54+
s = Session.create(store, req, {})
55+
s.store("foo", "bar")
56+
assert_equal "bar", s["foo"]
57+
end
58+
5359
def test_keys
5460
s = Session.create(store, req, {})
5561
s["rails"] = "ftw"
@@ -205,7 +211,11 @@ def call(env)
205211
end
206212

207213
def app
208-
@app ||= RoutedRackApp.new(Router)
214+
@app ||= RoutedRackApp.new(Router) do |middleware|
215+
@cache = ActiveSupport::Cache::MemoryStore.new
216+
middleware.use ActionDispatch::Session::CacheStore, key: "_session_id", cache: @cache
217+
middleware.use Rack::Lint
218+
end
209219
end
210220

211221
def test_session_follows_rack_api_contract_1

0 commit comments

Comments
 (0)