I would copy over Devise Controllers and add a filter before the following:
class Users::SessionsController < Devise::SessionsController before_filter :logout_admin, :only => "create" def create super end private def logout_admin
Then for testing, you can access the current user in the functional (control) specifications by calling subject.current_user or subject.current_admin, go here: https://github.com/plataformatec/devise , to enable test assistants, try something like this:
require 'spec_helper' describe Users::SessionsController do login_admin describe "POST create" do it "should logout admin" do post :create, {:user => {:email => " tester@email.com ", :password => "secret"} } subject.current_user.should_not be_nil subject.current_admin.should be_nil end end end
source share