Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

do not set flash.now with redirect action

closes #61
  • Loading branch information...
commit fc7a49b3fe09df686cdf60d95cf240ede54c0d6e 1 parent d2639f8
@nashby nashby authored
View
4 lib/responders/flash_responder.rb
@@ -135,7 +135,9 @@ def set_flash(key, value)
end
def set_flash_now?
- (@flash_now == true) || (has_errors? ? @flash_now == :on_failure : @flash_now == :on_success) || (format == :js)
+ return true if @flash_now == true || format == :js
+
+ default_action && (has_errors? ? @flash_now == :on_failure : @flash_now == :on_success)
end
def set_flash_message? #:nodoc:
View
6 test/flash_responder_test.rb
@@ -174,6 +174,12 @@ def test_sets_flash_now_on_failure_by_default
assert_flash_now :failure
end
+ def test_does_not_set_flash_message_to_now_with_errors_and_redirect
+ delete :with_html, :fail => true
+ assert_not_flash_now :failure
+ assert_equal "<strong>OH NOES!</strong> You did it wrong!", flash[:failure]
+ end
+
def test_never_set_flash_now
post :flexible, :fail => true, :responder_options => { :flash_now => false, :alert => "Warning" }
assert_not_flash_now :failure
Please sign in to comment.
Something went wrong with that request. Please try again.