aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/middleware/cookies.rb7
-rw-r--r--actionpack/lib/action_dispatch/middleware/flash.rb12
-rw-r--r--actionpack/test/dispatch/cookies_test.rb6
3 files changed, 11 insertions, 14 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb
index 24ebb8fed7..3ed5f1055f 100644
--- a/actionpack/lib/action_dispatch/middleware/cookies.rb
+++ b/actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -115,13 +115,10 @@ module ActionDispatch
@delete_cookies = {}
@host = host
@secure = secure
- @closed = false
@cookies = {}
end
- attr_reader :closed
- alias :closed? :closed
- def close!; @closed = true end
+ alias :closed? :frozen?
# Returns the value of the cookie by +name+, or +nil+ if no such cookie exists.
def [](name)
@@ -330,7 +327,7 @@ module ActionDispatch
[status, headers, body]
ensure
cookie_jar = ActionDispatch::Request.new(env).cookie_jar unless cookie_jar
- cookie_jar.close!
+ cookie_jar.freeze
end
end
end
diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb
index 6eda1f31a7..e7090ecf1b 100644
--- a/actionpack/lib/action_dispatch/middleware/flash.rb
+++ b/actionpack/lib/action_dispatch/middleware/flash.rb
@@ -43,12 +43,9 @@ module ActionDispatch
class FlashNow #:nodoc:
def initialize(flash)
@flash = flash
- @closed = false
end
- attr_reader :closed
- alias :closed? :closed
- def close!; @closed = true end
+ alias :closed? :frozen?
def []=(k, v)
raise ClosedError, :flash if closed?
@@ -76,12 +73,9 @@ module ActionDispatch
def initialize #:nodoc:
super
@used = Set.new
- @closed = false
end
- attr_reader :closed
- alias :closed? :closed
- def close!; @closed = true end
+ alias :closed? :frozen?
def []=(k, v) #:nodoc:
raise ClosedError, :flash if closed?
@@ -200,7 +194,7 @@ module ActionDispatch
if !flash_hash.empty? || session.key?('flash')
session["flash"] = flash_hash
end
- flash_hash.close!
+ flash_hash.freeze
end
if session.key?('flash') && session['flash'].empty?
diff --git a/actionpack/test/dispatch/cookies_test.rb b/actionpack/test/dispatch/cookies_test.rb
index 1d06a755b8..cfa521b2d9 100644
--- a/actionpack/test/dispatch/cookies_test.rb
+++ b/actionpack/test/dispatch/cookies_test.rb
@@ -502,10 +502,16 @@ class CookiesIntegrationTest < ActionDispatch::IntegrationTest
class TestController < ActionController::Base
def dont_set_cookies
+ # initialize lazy loaded objects
+ cookies.permanent
+ cookies.signed
head :ok
end
def set_cookies
+ # initialize lazy loaded objects
+ cookies.permanent
+ cookies.signed
cookies["that"] = "hello"
head :ok
end