<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -195,27 +195,6 @@ module Merb
       @_provided_formats ||= class_provided_formats.dup
     end
     
-    # Sets the provided formats for this action.  Usually, you would use a
-    # combination of provides, only_provides and does_not_provide to manage
-    # this, but you can set it directly.
-    # 
-    # ==== Parameters
-    # *formats&lt;Symbol&gt;:: A list of formats to be passed to provides.
-    #
-    # ==== Raises
-    # Merb::ResponderMixin::ContentTypeAlreadySet::
-    #   Content negotiation already occured, and the content_type is set.
-    #
-    # ==== Returns
-    # Array[Symbol]:: List of formats passed in.
-    def _set_provided_formats(*formats)
-      if @_content_type
-        raise ContentTypeAlreadySet, &quot;Cannot modify provided_formats because content_type has already been set&quot;
-      end
-      provides(*formats)
-    end
-    alias :_provided_formats= :_set_provided_formats   
-    
     # Adds formats to the list of provided formats for this particular request.
     # Usually used to add formats to a single action. See also the
     # controller-level provides that affects all actions in a controller.
@@ -237,8 +216,7 @@ module Merb
       if @_content_type
         raise ContentTypeAlreadySet, &quot;Cannot modify provided_formats because content_type has already been set&quot;
       end
-      @_provided_formats ||= [] 
-      @_provided_formats |= formats
+      @_provided_formats = self._provided_formats | formats # merges with class_provided_formats if not already
     end
 
     # Sets list of provided formats for this particular request. Usually used
@@ -255,7 +233,8 @@ module Merb
     #---
     # @public
     def only_provides(*formats)
-      _set_provided_formats(*formats)
+      @_provided_formats = []
+      provides(*formats)
     end
     
     # Removes formats from the list of provided formats for this particular 
@@ -273,8 +252,7 @@ module Merb
     #---
     # @public
     def does_not_provide(*formats)
-      formats.flatten!
-      self._provided_formats -= formats
+      @_provided_formats -= formats.flatten
     end
     
     # Do the content negotiation:</diff>
      <filename>lib/merb-core/controller/mixins/responder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,6 +34,13 @@ module Merb::Test::Fixtures::Controllers
     end
   end
 
+  class ClassAndLocalProvides &lt; Responder
+    provides :html    
+    def index
+      provides :xml
+      render
+    end
+  end
 
   class ClassOnlyProvides &lt; Responder
     only_provides :text, :xml</diff>
      <filename>spec/public/controller/controllers/responder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,7 +13,7 @@ describe Merb::Controller, &quot; responds&quot; do
     dispatch_to(Merb::Test::Fixtures::Controllers::HtmlDefault, :index).body.should == &quot;HTML: Default&quot;
   end
 
-  it &quot;should use other mime-types if they are provided on the class level&quot; do
+  it &quot;should use other mime-types if they are provided on the controller-level&quot; do
     controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassProvides, :index, {}, :http_accept =&gt; &quot;application/xml&quot;)
     controller.body.should == &quot;&lt;XML:Class provides='true' /&gt;&quot;
   end
@@ -23,10 +23,24 @@ describe Merb::Controller, &quot; responds&quot; do
       should raise_error(Merb::ControllerExceptions::NotAcceptable)
   end
 
-  it &quot;should use mime-types that are provided at the local level&quot; do
+  it &quot;should use mime-types that are provided at the action-level&quot; do
     controller = dispatch_to(Merb::Test::Fixtures::Controllers::LocalProvides, :index, {}, :http_accept =&gt; &quot;application/xml&quot;)
     controller.body.should == &quot;&lt;XML:Local provides='true' /&gt;&quot;
   end
+  
+  it &quot;should use mime-types that are provided at the controller-level as well as the action-level (controller)&quot; do
+    controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassAndLocalProvides, :index, {}, :http_accept =&gt; &quot;text/html&quot;)
+    controller.class_provided_formats.should == [:html]
+    controller._provided_formats.should == [:html, :xml]
+    controller.body.should == &quot;HTML: Class and Local&quot;
+  end  
+  
+  it &quot;should use mime-types that are provided at the controller-level as well as the action-level (action)&quot; do  
+    controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassAndLocalProvides, :index, {}, :http_accept =&gt; &quot;application/xml&quot;)
+    controller.class_provided_formats.should == [:html]
+    controller._provided_formats.should == [:html, :xml]
+    controller.body.should == &quot;&lt;XML:ClassAndLocalProvides provides='true' /&gt;&quot;
+  end
 
   it &quot;should use the first mime-type when accepting anything */*&quot; do
     controller = dispatch_to(Merb::Test::Fixtures::Controllers::MultiProvides, :index, {}, :http_accept =&gt; &quot;*/*&quot;)
@@ -53,43 +67,57 @@ describe Merb::Controller, &quot; responds&quot; do
     controller.body.should == &quot;HTML: Multi&quot;
   end
   
-  it &quot;should select the format based on params supplied to it with class provides&quot; do
+  it &quot;should select the format based on params supplied to it with controller-level provides&quot; do
     controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassProvides, :index, :format =&gt; &quot;xml&quot;)
     controller.content_type.should == :xml    
   end
   
-  it &quot;should select the format based on params supplied to it with instance provides&quot; do
+  it &quot;should select the format based on params supplied to it with action-level provides&quot; do
     controller = dispatch_to(Merb::Test::Fixtures::Controllers::LocalProvides, :index, :format =&gt; &quot;xml&quot;)
     controller.content_type.should == :xml    
   end
   
+  it &quot;should select the format based on params supplied to it with controller and action provides (controller)&quot; do
+    controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassAndLocalProvides, :index, :format =&gt; &quot;html&quot;)
+    controller.content_type.should == :html
+  end
+  
+  it &quot;should select the format based on params supplied to it with controller and action provides (action)&quot; do
+    controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassAndLocalProvides, :index, :format =&gt; &quot;xml&quot;)
+    controller.content_type.should == :xml
+  end
+  
   it &quot;should properly add formats when only_provides is called in action&quot; do
     controller = dispatch_to(Merb::Test::Fixtures::Controllers::OnlyProvides, :index, {}, :http_accept =&gt; &quot;application/xml&quot;)
+    controller._provided_formats.should == [:text, :xml]
     controller.content_type.should == :xml
   end
 
   it &quot;should properly remove formats when only_provides is called in action&quot; do
-    controller = dispatch_to(Merb::Test::Fixtures::Controllers::OnlyProvides, :index, {}, :http_accept =&gt; &quot;application/html&quot;)
+    controller = dispatch_to(Merb::Test::Fixtures::Controllers::OnlyProvides, :index, {}, :http_accept =&gt; &quot;text/html&quot;)
     lambda { controller.content_type }.should raise_error(Merb::ControllerExceptions::NotAcceptable)
   end
 
   it &quot;should properly add formats when only_provides is called in controller&quot; do
     controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassOnlyProvides, :index, {}, :http_accept =&gt; &quot;application/xml&quot;)
+    controller._provided_formats.should == [:text, :xml]
     controller.content_type.should == :xml
   end
 
   it &quot;should properly remove formats when only_provides is called in controller&quot; do
-    controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassOnlyProvides, :index, {}, :http_accept =&gt; &quot;application/html&quot;)
+    controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassOnlyProvides, :index, {}, :http_accept =&gt; &quot;text/html&quot;)
     lambda { controller.content_type }.should raise_error(Merb::ControllerExceptions::NotAcceptable)
   end
-
-  it &quot;should properly remove formats when does_not_provide is called in action&quot; do
-    controller = dispatch_to(Merb::Test::Fixtures::Controllers::OnlyProvides, :index, {}, :http_accept =&gt; &quot;application/html&quot;)
+  
+  it &quot;should properly remove formats when does_not_provide is called in controller&quot; do
+    controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassDoesntProvides, :index, {}, :http_accept =&gt; &quot;text/html&quot;)
+    controller._provided_formats.should == [:xml]
     lambda { controller.content_type }.should raise_error(Merb::ControllerExceptions::NotAcceptable)
   end
 
-  it &quot;should properly remove formats when does_not_provide is called in controller&quot; do
-    controller = dispatch_to(Merb::Test::Fixtures::Controllers::ClassOnlyProvides, :index, {}, :http_accept =&gt; &quot;application/html&quot;)
+  it &quot;should properly remove formats when does_not_provide is called in action&quot; do
+    controller = dispatch_to(Merb::Test::Fixtures::Controllers::DoesntProvide, :index, {}, :http_accept =&gt; &quot;text/html&quot;)
+    controller._provided_formats.should == [:xml]
     lambda { controller.content_type }.should raise_error(Merb::ControllerExceptions::NotAcceptable)
   end
   </diff>
      <filename>spec/public/controller/responder_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>df7306d346d9ee721f15e3adb0367f0c188f2e66</id>
    </parent>
  </parents>
  <author>
    <name>Fabien Franzen</name>
    <email>info@atelierfabien.be</email>
  </author>
  <url>http://github.com/wycats/merb-core/commit/105a206920f0fb4bea379e968770527fcac6876b</url>
  <id>105a206920f0fb4bea379e968770527fcac6876b</id>
  <committed-date>2008-07-25T03:43:34-07:00</committed-date>
  <authored-date>2008-07-25T03:43:34-07:00</authored-date>
  <message>Fixed nasty bugs in controller/mixins/responder and its specs.</message>
  <tree>7093017540aed63e8af13486e17667f66c5b20bc</tree>
  <committer>
    <name>Fabien Franzen</name>
    <email>info@atelierfabien.be</email>
  </committer>
</commit>
