<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -35,8 +35,13 @@ class Merb::Test::RspecStory
   #which is where we get our status and response from. 
   #
   #We have to preserve cookies like this, or the session is lost.
+  #
+  #While (in a web application) a PUT is modelled as a POST with a parameter _method, 
+  #this close to the metal we need to make sure that we actually hit the underlying 'put' method,
+  #so we rewrite 'method'.
   def request_via_redirect(method,path,parameters={},headers={})
-    mycookies = @controller.cookies rescue nil #will be nil if no requests yet
+    method = parameters[&quot;_method&quot;] if !parameters[&quot;_method&quot;].blank?
+    mycookies = defined?(@controller) ? @controller.cookies : nil #will be nil if no requests yet
     @controller=self.send(method, path, parameters, headers) do |new_controller|
       new_controller.cookies = mycookies
     end</diff>
      <filename>lib/boot_merb.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,6 +9,8 @@ class ClicksButtonTest &lt; Test::Unit::TestCase
     @session.stubs(:current_page).returns(@page)
     @response = mock
     @session.stubs(:response).returns(@response)
+    @controller = mock
+    @controller.stubs(:status).returns(200)
   end
   
   def test_should_fail_if_no_buttons
@@ -349,4 +351,29 @@ class ClicksButtonTest &lt; Test::Unit::TestCase
     @session.expects(:get_via_redirect).with(&quot;/login&quot;, &quot;user&quot; =&gt; {&quot;email&quot; =&gt; &quot;&quot;})
     @session.clicks_button
   end
+  
+  def test_should_use_put_method_when_needed
+    @response.stubs(:body).returns(&lt;&lt;-EOS)
+      &lt;form method=&quot;put&quot; action=&quot;/login&quot;&gt;
+        &lt;input id=&quot;user_email&quot; name=&quot;user[email]&quot; value=&quot;test@example.com&quot; type=&quot;hidden&quot; /&gt;
+        &lt;input type=&quot;submit&quot; /&gt;
+      &lt;/form&gt;
+    EOS
+    @session.stubs(:redirect?).returns(false)
+    @session.expects(:put).returns(@controller)
+    @session.clicks_button
+  end
+
+  def test_should_use_delete_method_when_needed
+    @response.stubs(:body).returns(&lt;&lt;-EOS)
+      &lt;form method=&quot;delete&quot; action=&quot;/login&quot;&gt;
+        &lt;input id=&quot;user_email&quot; name=&quot;user[email]&quot; value=&quot;test@example.com&quot; type=&quot;hidden&quot; /&gt;
+        &lt;input type=&quot;submit&quot; /&gt;
+      &lt;/form&gt;
+    EOS
+    @session.stubs(:redirect?).returns(false)
+    @session.expects(:delete).returns(@controller)
+    @session.clicks_button
+  end
+  
 end</diff>
      <filename>test/clicks_button_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>94f0086a55cec2250e226df37094b57149bd2bd1</id>
    </parent>
  </parents>
  <author>
    <name>Gwyn Morfey</name>
    <email>gwyn@new-bamboo.co.uk</email>
  </author>
  <url>http://github.com/gwynm/webrat/commit/580a301984aef358bfaf22977c6ac4d25cea60aa</url>
  <id>580a301984aef358bfaf22977c6ac4d25cea60aa</id>
  <committed-date>2008-04-23T02:41:34-07:00</committed-date>
  <authored-date>2008-04-23T02:41:34-07:00</authored-date>
  <message>Make sure that PUTS and DELETES are handled correctly in merb</message>
  <tree>5d48ab38acf3daa5b46382c82b3f51f345086e95</tree>
  <committer>
    <name>Gwyn Morfey</name>
    <email>gwyn@new-bamboo.co.uk</email>
  </committer>
</commit>
