提交 74eed629 编写于 作者: A Andreas Neuhaus 提交者: Michael Koziarski

Fixed flash.now not being accessible in tests. Flash sweeping is now done...

Fixed flash.now not being accessible in tests. Flash sweeping is now done before action processing instead after
Signed-off-by: NMichael Koziarski <michael@koziarski.com>

[#10 state:resolved]
上级 a7ea06b4
...@@ -28,7 +28,6 @@ def self.included(base) ...@@ -28,7 +28,6 @@ def self.included(base)
base.class_eval do base.class_eval do
include InstanceMethods include InstanceMethods
alias_method_chain :assign_shortcuts, :flash alias_method_chain :assign_shortcuts, :flash
alias_method_chain :process_cleanup, :flash
alias_method_chain :reset_session, :flash alias_method_chain :reset_session, :flash
end end
end end
...@@ -166,11 +165,7 @@ def flash(refresh = false) #:doc: ...@@ -166,11 +165,7 @@ def flash(refresh = false) #:doc:
def assign_shortcuts_with_flash(request, response) #:nodoc: def assign_shortcuts_with_flash(request, response) #:nodoc:
assign_shortcuts_without_flash(request, response) assign_shortcuts_without_flash(request, response)
flash(:refresh) flash(:refresh)
end flash.sweep if @_session && !component_request?
def process_cleanup_with_flash
flash.sweep if @_session
process_cleanup_without_flash
end end
end end
end end
......
...@@ -12,6 +12,11 @@ def set_flash ...@@ -12,6 +12,11 @@ def set_flash
render :text => 'ignore me' render :text => 'ignore me'
end end
def set_flash_now
flash.now["test_now"] = ">#{flash["test_now"]}<"
render :text => 'ignore me'
end
def set_session def set_session
session['string'] = 'A wonder' session['string'] = 'A wonder'
session[:symbol] = 'it works' session[:symbol] = 'it works'
...@@ -145,6 +150,11 @@ def test_process_with_flash ...@@ -145,6 +150,11 @@ def test_process_with_flash
assert_equal '>value<', flash['test'] assert_equal '>value<', flash['test']
end end
def test_process_with_flash_now
process :set_flash_now, nil, nil, { "test_now" => "value_now" }
assert_equal '>value_now<', flash['test_now']
end
def test_process_with_session def test_process_with_session
process :set_session process :set_session
assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key" assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册