项目控制器#show
if !@project.user_allowed_to_view_gallery?(current_user)
render :action => :hidden_gallery
elsif @project.project_type.gallery_template == :written
render :action => :written_gallery
end
我想测试这个动作,这是我的测试文件。
sign_in @creative
get :show, :id => @project.to_param
controller.stub(:current_user).and_return(@creative)
@project.stub!(:user_allowed_to_view_gallery?).with(@creative).and_return(false)
response.should render_template("hidden_gallery")
而且它不起作用。我认为问题是存根实例@project变量和current_user。你知道我该如何解决吗?