컨트롤러의 before_filter는 사용자가 로그인 할 것으로 예상합니다. 컨트롤러의 테스트가 실패하는 이유입니다 (before_filter에서 사용자 인증 호출을 제거하면 올바르게 작동합니다). 테스트하는 동안 사용자 인증 호출을 비활성화 할 수 있습니까?레일 컨트롤러 테스트 : 테스트하는 동안 컨트롤러의 before_filter를 비활성화하는 방법은 무엇입니까?
class Company::BranchController < ApplicationController
before_filter **:require_user**, :only => [:show, :edit, :update, :new, :create, :index]
def create
@branch = Company::Branch.new(params[:branch])
if @branch.save
redirect_to :action => :index
else
render :action => :new
end
end
end
이 코드를 어디에 넣어야합니까? –
rspec을 사용하지 않고 있는데, rspec에서만 언급 한 구문입니다. rspec없이 스텁을 사용하는 방법이있다. –