Sweep flash when filter chain is halted. Closes #6175. [Caio Chassot <lists@v2studio.com>]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6670 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
67ca9224d7
commit
dac6aae7f8
@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Sweep flash when filter chain is halted. [Caio Chassot <lists@v2studio.com>]
|
||||
|
||||
* Fixed that content_tag with a block will just return the result instead of concate it if not used in a ERb view #7857, #7432 [michael.niessner]
|
||||
|
||||
* Replace the current block/continuation filter chain handling by an implementation based on a simple loop. #8226 [Stefan Kaes]
|
||||
|
@ -672,7 +672,6 @@ def self.included(base)
|
||||
base.class_eval do
|
||||
alias_method_chain :perform_action, :filters
|
||||
alias_method_chain :process, :filters
|
||||
alias_method_chain :process_cleanup, :filters
|
||||
end
|
||||
end
|
||||
|
||||
@ -748,13 +747,6 @@ def perform_action_with_filters
|
||||
call_filters(self.class.filter_chain, 0, 0)
|
||||
end
|
||||
|
||||
def process_cleanup_with_filters
|
||||
if @before_filter_chain_aborted
|
||||
close_session
|
||||
else
|
||||
process_cleanup_without_filters
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -63,7 +63,7 @@ def []=(k, v) #:nodoc:
|
||||
end
|
||||
|
||||
def update(h) #:nodoc:
|
||||
h.keys.each{ |k| discard(k) }
|
||||
h.keys.each { |k| keep(k) }
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -34,6 +34,12 @@ def use_flash_and_keep_it
|
||||
silence_warnings { keep_flash }
|
||||
render :inline => "hello"
|
||||
end
|
||||
|
||||
def use_flash_and_update_it
|
||||
flash.update("this" => "hello again")
|
||||
@flash_copy = {}.update flash
|
||||
render :inline => "hello"
|
||||
end
|
||||
|
||||
def use_flash_after_reset_session
|
||||
flash["that"] = "hello"
|
||||
@ -48,6 +54,24 @@ def use_flash_after_reset_session
|
||||
def rescue_action(e)
|
||||
raise unless ActionController::MissingTemplate === e
|
||||
end
|
||||
|
||||
# methods for test_sweep_after_halted_filter_chain
|
||||
before_filter :halt_and_redir, :only => "filter_halting_action"
|
||||
|
||||
def std_action
|
||||
@flash_copy = {}.update(flash)
|
||||
end
|
||||
|
||||
def filter_halting_action
|
||||
@flash_copy = {}.update(flash)
|
||||
end
|
||||
|
||||
def halt_and_redir
|
||||
flash["foo"] = "bar"
|
||||
redirect_to :action => "std_action"
|
||||
@flash_copy = {}.update(flash)
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def setup
|
||||
@ -93,10 +117,31 @@ def test_flash_now
|
||||
assert_nil @response.template.assigns["flashy"]
|
||||
end
|
||||
|
||||
def test_update_flash
|
||||
get :set_flash
|
||||
get :use_flash_and_update_it
|
||||
assert_equal "hello", @response.template.assigns["flash_copy"]["that"]
|
||||
assert_equal "hello again", @response.template.assigns["flash_copy"]["this"]
|
||||
get :use_flash
|
||||
assert_nil @response.template.assigns["flash_copy"]["that"], "On second flash"
|
||||
assert_equal "hello again", @response.template.assigns["flash_copy"]["this"], "On second flash"
|
||||
end
|
||||
|
||||
def test_flash_after_reset_session
|
||||
get :use_flash_after_reset_session
|
||||
assert_equal "hello", @response.template.assigns["flashy_that"]
|
||||
assert_equal "good-bye", @response.template.assigns["flashy_this"]
|
||||
assert_nil @response.template.assigns["flashy_that_reset"]
|
||||
end
|
||||
|
||||
def test_sweep_after_halted_filter_chain
|
||||
get :std_action
|
||||
assert_nil @response.template.assigns["flash_copy"]["foo"]
|
||||
get :filter_halting_action
|
||||
assert_equal "bar", @response.template.assigns["flash_copy"]["foo"]
|
||||
get :std_action # follow redirection
|
||||
assert_equal "bar", @response.template.assigns["flash_copy"]["foo"]
|
||||
get :std_action
|
||||
assert_nil @response.template.assigns["flash_copy"]["foo"]
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user