Skip to content

Commit

Permalink
Fixed deny_access matcher on Rails 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jferris committed Jan 11, 2012
1 parent 160366e commit 23df300
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions lib/clearance/testing/deny_access_matcher.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/denies_controller_spec.rb
Expand Up @@ -15,7 +15,7 @@ def show
protected

def authorize
deny_access(:flash => "Access denied.")
deny_access("Access denied.")
end
end

Expand Down

0 comments on commit 23df300

Please sign in to comment.