Created
January 5, 2010 17:33
-
-
Save phillipkoebbe/269544 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Admin::BaseController < ApplicationController | |
before_filter :require_admin | |
protected | |
def require_admin | |
redirect_to error_path(403) unless current_user.is_administrator? | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe Admin::BaseController do | |
should_be_an_instance_of Admin::BaseController | |
should_descend_from ApplicationController | |
context 'before_filter' do | |
it 'should respond to :require_admin' do | |
controller.should respond_to(:require_admin) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe Admin::HomeController do | |
should_be_an_instance_of Admin::HomeController | |
should_descend_from Admin::BaseController | |
it_should_behave_like 'administrative controllers' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment