title: Celerity cannot follow a Devise redirect, because Celerity doesn't send an accept header and Devise responds with plain text
body: <p>We've got a Rails application just upgraded to Rails3 using Devise's Rails3 gem for authentication. We've been using Capybara with Celerity backend to test some of the pages.</p>
  
  <p>When accessing the application in a browser, Devise responds with a redirect to the login page when a user is trying to access a protected page/controller.</p>
  
  <p>In the Rails 2.x version of Devise this used to work even if the incoming request had a blank accept header <code>*/*</code>.</p>
  
  <p>In the Rails 3 version, Devise responds with a plain text string when the accept header is blank.</p>
  
  <p>The reason the blank accept header thing matters is because we're using the Celerity backend of Capybara to test some of the pages, and apparently Celerity sends a blank accept header, and thus doesn't get redirected by Devise. This behavior has changed from Devise for Rails 2.x to Devise for Rails 3.</p>
  
  <p>Celerity fails with an UnexpectedPageException and the server log reports that the request was made with <code>*/*</code> as accept header.</p>
  
  <p>When using the Selenium/Webdriver backend on the exact same test suite, the problem goes away.</p>
  
  <p>There are two ways to tackle this:</p>
  
  <ol>
  <li>Tell Devise to somehow always assume text/html as accept header and respond accordingly. How could that be done? Do we have to override the controllers?</li>
  <li>"Fix" Celerity to sent text/html as accept header. How can this be done?</li>
  <li>Is this an HTMLUnit problem/bug?</li>
  </ol>
  
  <p>To me #2 looks like the "right" way to fix this, but I'm not sure if Celerity/HTMLUnit's lack of accept header is a bug or a feature. Thoughts?</p>