Skip to content

Commit

Permalink
Merge pull request #97 from betesh/master
Browse files Browse the repository at this point in the history
A FailureApp should know its failure message
  • Loading branch information
Daniel Neighman committed Aug 15, 2014
2 parents e43d3ed + 3fcab49 commit 74162f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/warden/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def process_unauthenticated(env, options={})
when :custom
proxy.custom_response
else
options[:message] ||= proxy.message
call_failure_app(env, options)
end
end
Expand Down
10 changes: 10 additions & 0 deletions spec/warden/manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
result.last.should eq(["You Fail!"])
end

it "should set the message from the winning strategy in warden.options hash" do
env = env_with_params("/", {})
app = lambda do |_env|
_env['warden'].authenticate(:failz)
throw(:warden)
end
setup_rack(app, :failure_app => @fail_app).call(env) # TODO: What is @fail_app?
env["warden.options"][:message].should eq("The Fails Strategy Has Failed You")
end

it "should render the failure app when there's a failure" do
app = lambda do |e|
throw(:warden, :action => :unauthenticated) unless e['warden'].authenticated?(:failz)
Expand Down

0 comments on commit 74162f2

Please sign in to comment.