I have this Users::SessionsController, for Devise
class Users::SessionsController < Devise::SessionsController
include ApplicationHelper
after_filter :set_company_id,:only =>[ :new, :create ]
after_filter :clear_company_id, :only =>[:destroy]
def set_company_id
if current_user && current_user.company
set_company_in_cookie(Array(current_user.company.id))
end
end
def clear_company_id
cookies.delete(:company_id)
end
end
require 'test_helper'
Then in my Test I have this... Im using Devise so I use sign_in @user
to log into the system, sign_in should be over
Users::SessionsController then the after_filter must be called and
set_company_in_cookie(Array(current_user.company.id)) be called, this
helper set company id in session.. but do not happend so then in the
view when I try to get the value from session I get nil.. what Im
doing wrong ? thanks
class WorkordersControllerTest < ActionController::TestCase
setup do
@user = FactoryGirl.create(:gustavo_de_antonio)
end
test "should get index" do
sign_in @user
get :index
assert_response :success
assert_template :index
end
end