Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View application_controller.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
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
Something went wrong with that request. Please try again.