plataformatec/devise — Issue #1497: Integration testing with Capybara shows different behavior to browser wrt. authenticate_user! in controller
Author: sgharms
Created: 2011-12-09 23:40:34+00:00
State: open

Given a controller:

`before_filter :authenticate_user!, :only => :payment`

Given an integration test (RSpec+Capybara)

```ruby
# Standard as expected
page.should have_content("You need to sign in or sign up before continuing.")
page.should have_selector "#user_username"
page.should have_selector "#user_password"
page.should have_selector "span.button"

click_link "Sign up"
page.should have_content("Sign up")

fill_in "Username", :with => "moopy"
fill_in "Email Address", :with => "moopy@example.com"
fill_in "Password", :with => "password1"
fill_in "Password Confirmation", :with => "password1"

click_button "Sign up"
page.should have_content("Welcome! You have signed up successfully.")
```

This is as one would expect. HOWEVER, hereafter the redirect is to '/'. When I follow the same path with a browser, after "Sign up" I am returned to the page where I would have gone had I been authenticated (The Right Thing™).

I'm open to the idea I'm misusing Capybara, but I'd like to remove Devise as a possible culprit.