make respond-with play nice with namespace
This commit is contained in:
parent
503250fd67
commit
31cdac9d0e
|
@ -66,6 +66,11 @@ module Sinatra
|
|||
[*codes].each { |c| errors[c] = block }
|
||||
end
|
||||
|
||||
def respond_to(*args)
|
||||
return @conditions[:provides] || base.respond_to if args.empty?
|
||||
@conditions[:provides] = args
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def app
|
||||
|
|
|
@ -108,7 +108,7 @@ module Sinatra
|
|||
result
|
||||
end
|
||||
|
||||
def respond_to(*formats, &block)
|
||||
def respond_to(*formats)
|
||||
if formats.any?
|
||||
@respond_to ||= []
|
||||
@respond_to.concat formats
|
||||
|
|
|
@ -262,5 +262,19 @@ describe Sinatra::RespondWith do
|
|||
req('/b', :html).should_not be_ok
|
||||
req('/b', :json).should be_ok
|
||||
end
|
||||
|
||||
it 'plays well with namespaces' do
|
||||
respond_app do
|
||||
register Sinatra::Namespace
|
||||
namespace '/a' do
|
||||
respond_to :json
|
||||
get { 'json' }
|
||||
end
|
||||
get('/b') { 'anything' }
|
||||
end
|
||||
|
||||
req('/a', :html).should_not be_ok
|
||||
req('/b', :html).should be_ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue