这是我的控制器
class IdeasController < ApplicationController
load_and_authorize_resource
def create
@idea = Idea.create params[:idea]
end
end
我的能力档案是
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
if user.confirmed?
can :manage, Idea
end
end
end
但是我的规范在创建时返回成功
context "when not logged in"do
it "does not be allowed" do
post :create, FactoryGirl.attributes_for(:idea)
response.should_not be_success
end
end
需要我必须添加before_filter :authenticate_user!
控制器吗?