Create a gist now

Instantly share code, notes, and snippets.

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