Permalink
Browse files

Fixed deny_access matcher on Rails 3.1

  • Loading branch information...
1 parent f236a2f commit f796c45618e12520ad463308384c3b70d6fd9f99 @jferris jferris committed with Chad Pytel Jan 11, 2012
Showing with 15 additions and 3 deletions.
  1. +14 −2 lib/clearance/testing/deny_access_matcher.rb
  2. +1 −1 spec/controllers/denies_controller_spec.rb
@@ -38,16 +38,28 @@ def sets_the_flash?
if @flash.blank?
true
else
- if @controller.flash[:notice].try(:values).try(:first) == @flash
+ if flash_notice_value == @flash
@negative_failure_message << "Didn't expect to set the flash to #{@flash}"
true
else
- @failure_message << "Expected the flash to be set to #{@flash} but was #{@controller.flash[:notice].try(:values).try(:first)}"
+ @failure_message << "Expected the flash to be set to #{@flash} but was #{flash_notice_value}"
false
end
end
end
+ def flash_notice_value
+ if flash_notice.respond_to?(:values)
+ flash_notice.values.first
+ else
+ flash_notice
+ end
+ end
+
+ def flash_notice
+ @controller.flash[:notice]
+ end
+
def redirects_to_url?
@url ||= denied_access_url
begin
@@ -15,7 +15,7 @@ def show
protected
def authorize
- deny_access(:flash => "Access denied.")
+ deny_access("Access denied.")
end
end

0 comments on commit f796c45

Please sign in to comment.