Skip to content

Instantly share code, notes, and snippets.

@ahawkins
Created October 24, 2011 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahawkins/1308530 to your computer and use it in GitHub Desktop.
Save ahawkins/1308530 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe ApplicationController do
let(:user) { mock_model(User) }
controller do
before_filter :require_app!, :only => :app_required
def index
raise CanCan::AccessDenied
end
def missing_app_token
end
end
it "should return a 403 if the user is not authorized" do
User.stub(:find_by_api_key).and_return(user)
get :index
response.code.should eql('403')
end
it "should return a 412 if there is no app token when required" do
User.stub(:find_by_api_key).and_return(user)
get :missing_app_token
response.code.should eql('412')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment