Skip to content

Instantly share code, notes, and snippets.

@agibralter
Forked from dchelimsky/gist:79624
Created March 16, 2009 01:44
Show Gist options
  • Save agibralter/79641 to your computer and use it in GitHub Desktop.
Save agibralter/79641 to your computer and use it in GitHub Desktop.
require File.dirname(__FILE__) + '/../../spec_helper'
describe Admin::BaseController do
subject do
Class.new(Admin::BaseController) do
def index; end
end.new
end
# class FoobarsController < Admin::BaseController
# def index; end
# end
controller_name :foobars
before(:all) do
# set custom routes
ActionController::Routing::Routes.draw do |map|
map.connect 'foobars/:action', :controller => 'foobars'
end
end
after(:all) do
# reset routes
ActionController::Routing::Routes.reload!
end
describe "filtering" do
def do_get
get :index
end
it "should check for admin" do
user = mock_user
controller.stub!(:current_user).and_return(user)
controller.should_receive(:admin?).and_return(true)
do_get
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment