Sha256: fe61169275139f13e90d558189faec6a01c7271bc67c4c701bb0b134d0cd1ab5
Contents?: true
Size: 1008 Bytes
Versions: 6
Compression:
Stored size: 1008 Bytes
Contents
require File.expand_path('../test_helper', __FILE__) # Mock controller used for testing session handling. class CookieController < ApplicationController authenticates_using_session def show if current_user render :text => "User: #{current_user.id}" else render :text => "No user" end end end class CookieControllerTest < ActionController::TestCase setup do @user = users(:john) end test "no user_id in session" do get :show assert_response :success assert_nil assigns(:current_user) assert_equal 'No user', response.body end test "valid user_id in session" do set_session_current_user @user get :show assert_response :success assert_equal @user, assigns(:current_user) assert_equal "User: #{Fixtures.identify(:john)}", response.body end test "invalid user_pid in session" do get :show, {}, :current_user_pid => 'random@user.com' assert_response :success assert_nil assigns(:current_user) end end
Version data entries
6 entries across 6 versions & 1 rubygems