出于某种原因,我无法让设计辅助方法 sign_in 工作。current_user 继续为空。知道问题可能是什么吗?
测试:
before :each do
@user = FactoryGirl.create :user
sign_in @user
end
describe "GET index" do
it "assigns all subscribers as @subscribers" do
subscriber = @user.subscribers.create! valid_attributes
get :index
assigns(:subscribers).should eq([subscriber])
end
end
执行:
def index
@subscribers = current_user.subscribers.all <------- ERROR
respond_to do |format|
format.html # index.html.erb
format.json { render json: @subscribers }
end
end
Error:
NoMethodError:
undefined method `subscribers' for nil:NilClass
任何帮助表示赞赏。谢谢!