Skip to content

Commit

Permalink
Merge pull request rails#53626 from viralpraxis/add-actiondispatch-re…
Browse files Browse the repository at this point in the history
…quest-session-store-method-to-conform-rack-spec

Add `ActionDispatch::Request::Session#store` method to conform Rack spec
  • Loading branch information
kamipo authored Nov 18, 2024
2 parents 2ca3cb0 + 226d7c6 commit 4df235f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions actionpack/lib/action_dispatch/request/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def []=(key, value)
load_for_write!
@delegate[key.to_s] = value
end
alias store []=

# Clears the session.
def clear
Expand Down
12 changes: 11 additions & 1 deletion actionpack/test/dispatch/request/session_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def test_destroy
assert_empty s
end

def test_store
s = Session.create(store, req, {})
s.store("foo", "bar")
assert_equal "bar", s["foo"]
end

def test_keys
s = Session.create(store, req, {})
s["rails"] = "ftw"
Expand Down Expand Up @@ -205,7 +211,11 @@ def call(env)
end

def app
@app ||= RoutedRackApp.new(Router)
@app ||= RoutedRackApp.new(Router) do |middleware|
@cache = ActiveSupport::Cache::MemoryStore.new
middleware.use ActionDispatch::Session::CacheStore, key: "_session_id", cache: @cache
middleware.use Rack::Lint
end
end

def test_session_follows_rack_api_contract_1
Expand Down

0 comments on commit 4df235f

Please sign in to comment.