Skip to content

Instantly share code, notes, and snippets.

@universal
Created July 16, 2013 09:43
Show Gist options
  • Save universal/6007307 to your computer and use it in GitHub Desktop.
Save universal/6007307 to your computer and use it in GitHub Desktop.
cancan and authentication check
describe MatchesController do
let(:group) {FactoryGirl.create(:group)}
context "requires login and checks authorization" do
it "for GET 'new'" do
controller.should_receive(:authenticate_user!).and_return(false)
expect{get :new, group_id: group.id}.to raise_error(CanCan::AccessDenied)
end
it "for POST 'create'" do
controller.should_receive(:authenticate_user!).and_return(false)
expect{post :create, group_id: group.id}.to raise_error(CanCan::AccessDenied)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment