require 'test_helper' class ApplicationControllerTest < ActionController::TestCase context 'ensure_manually_set_password' do setup do class ::TestingController < ApplicationController def hello render :nothing => true end end ActionController::Routing::Routes.draw do |map| map.hello '', :controller => 'testing', :action => 'hello' end end teardown do Object.send(:remove_const, :TestingController) end context 'when user is logged in' do setup do @controller = TestingController.new end context 'and user has not manually set their password' do setup do @user = Factory(:user, :manually_set_password => false) login_as @user get :hello end should 'redirect user to set their password' do assert_redirected_to new_password_path(@user.password_token) end end end end end