diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2013-06-28 12:57:13 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2013-06-28 12:57:13 -0700 |
commit | df7e1e25ded17423c635a8a1e2d53467f61ffe58 (patch) | |
tree | d3dd708eb302966beff65a852e2e99b5697c9456 | |
parent | b33032395de77ec15237c28d603a3962d5c481f2 (diff) | |
parent | cf13f31a74c46eb79032428d5efd176c4c35187c (diff) | |
download | rack-df7e1e25ded17423c635a8a1e2d53467f61ffe58.tar.gz |
Merge pull request #580 from sikachu/unauthorized_helper
Add Response#unauthorized? helper
-rw-r--r-- | lib/rack/response.rb | 1 | ||||
-rw-r--r-- | test/spec_response.rb | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/rack/response.rb b/lib/rack/response.rb index 2beba7a8..2076aff0 100644 --- a/lib/rack/response.rb +++ b/lib/rack/response.rb @@ -122,6 +122,7 @@ module Rack def ok?; status == 200; end def bad_request?; status == 400; end + def unauthorized?; status == 401; end def forbidden?; status == 403; end def not_found?; status == 404; end def method_not_allowed?; status == 405; end diff --git a/test/spec_response.rb b/test/spec_response.rb index 7ba1e0e1..0ba17b15 100644 --- a/test/spec_response.rb +++ b/test/spec_response.rb @@ -216,6 +216,11 @@ describe Rack::Response do res.should.be.client_error res.should.be.bad_request + res.status = 401 + res.should.not.be.successful + res.should.be.client_error + res.should.be.unauthorized + res.status = 404 res.should.not.be.successful res.should.be.client_error |