public
Created

  • Download Gist
application_controller.rb
Ruby
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.