0
@@ -13,7 +13,7 @@ describe Merb::Controller, " responds" do
0
dispatch_to(Merb::Test::Fixtures::Controllers::HtmlDefault, :index).body.should == "HTML: Default"
0
- it "should use other mime-types if they are provided on the c
lass level" do
0
+ it "should use other mime-types if they are provided on the c
ontroller-level" do
0
controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassProvides, :index, {}, :http_accept => "application/xml")
0
controller.body.should == "<XML:Class provides='true' />"
0
@@ -23,10 +23,24 @@ describe Merb::Controller, " responds" do
0
should raise_error(Merb::ControllerExceptions::NotAcceptable)
0
- it "should use mime-types that are provided at the
local level" do
0
+ it "should use mime-types that are provided at the
action-level" do
0
controller = dispatch_to(Merb::Test::Fixtures::Controllers::LocalProvides, :index, {}, :http_accept => "application/xml")
0
controller.body.should == "<XML:Local provides='true' />"
0
+ it "should use mime-types that are provided at the controller-level as well as the action-level (controller)" do
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassAndLocalProvides, :index, {}, :http_accept => "text/html")
0
+ controller.class_provided_formats.should == [:html]
0
+ controller._provided_formats.should == [:html, :xml]
0
+ controller.body.should == "HTML: Class and Local"
0
+ it "should use mime-types that are provided at the controller-level as well as the action-level (action)" do
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassAndLocalProvides, :index, {}, :http_accept => "application/xml")
0
+ controller.class_provided_formats.should == [:html]
0
+ controller._provided_formats.should == [:html, :xml]
0
+ controller.body.should == "<XML:ClassAndLocalProvides provides='true' />"
0
it "should use the first mime-type when accepting anything */*" do
0
controller = dispatch_to(Merb::Test::Fixtures::Controllers::MultiProvides, :index, {}, :http_accept => "*/*")
0
@@ -53,43 +67,57 @@ describe Merb::Controller, " responds" do
0
controller.body.should == "HTML: Multi"
0
- it "should select the format based on params supplied to it with c
lass provides" do
0
+ it "should select the format based on params supplied to it with c
ontroller-level provides" do
0
controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassProvides, :index, :format => "xml")
0
controller.content_type.should == :xml
0
- it "should select the format based on params supplied to it with
instance provides" do
0
+ it "should select the format based on params supplied to it with
action-level provides" do
0
controller = dispatch_to(Merb::Test::Fixtures::Controllers::LocalProvides, :index, :format => "xml")
0
controller.content_type.should == :xml
0
+ it "should select the format based on params supplied to it with controller and action provides (controller)" do
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassAndLocalProvides, :index, :format => "html")
0
+ controller.content_type.should == :html
0
+ it "should select the format based on params supplied to it with controller and action provides (action)" do
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassAndLocalProvides, :index, :format => "xml")
0
+ controller.content_type.should == :xml
0
it "should properly add formats when only_provides is called in action" do
0
controller = dispatch_to(Merb::Test::Fixtures::Controllers::OnlyProvides, :index, {}, :http_accept => "application/xml")
0
+ controller._provided_formats.should == [:text, :xml]
0
controller.content_type.should == :xml
0
it "should properly remove formats when only_provides is called in action" do
0
- controller = dispatch_to(Merb::Test::Fixtures::Controllers::OnlyProvides, :index, {}, :http_accept => "
application/html")
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::OnlyProvides, :index, {}, :http_accept => "
text/html")
0
lambda { controller.content_type }.should raise_error(Merb::ControllerExceptions::NotAcceptable)
0
it "should properly add formats when only_provides is called in controller" do
0
controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassOnlyProvides, :index, {}, :http_accept => "application/xml")
0
+ controller._provided_formats.should == [:text, :xml]
0
controller.content_type.should == :xml
0
it "should properly remove formats when only_provides is called in controller" do
0
- controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassOnlyProvides, :index, {}, :http_accept => "
application/html")
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassOnlyProvides, :index, {}, :http_accept => "
text/html")
0
lambda { controller.content_type }.should raise_error(Merb::ControllerExceptions::NotAcceptable)
0
- it "should properly remove formats when does_not_provide is called in action" do
0
- controller = dispatch_to(Merb::Test::Fixtures::Controllers::OnlyProvides, :index, {}, :http_accept => "application/html")
0
+ it "should properly remove formats when does_not_provide is called in controller" do
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassDoesntProvides, :index, {}, :http_accept => "text/html")
0
+ controller._provided_formats.should == [:xml]
0
lambda { controller.content_type }.should raise_error(Merb::ControllerExceptions::NotAcceptable)
0
- it "should properly remove formats when does_not_provide is called in controller" do
0
- controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassOnlyProvides, :index, {}, :http_accept => "application/html")
0
+ it "should properly remove formats when does_not_provide is called in action" do
0
+ controller = dispatch_to(Merb::Test::Fixtures::Controllers::DoesntProvide, :index, {}, :http_accept => "text/html")
0
+ controller._provided_formats.should == [:xml]
0
lambda { controller.content_type }.should raise_error(Merb::ControllerExceptions::NotAcceptable)
Comments
No one has commented yet.