Skip to content

Instantly share code, notes, and snippets.

@clemens
Created April 13, 2009 11:40
Show Gist options
  • Save clemens/94405 to your computer and use it in GitHub Desktop.
Save clemens/94405 to your computer and use it in GitHub Desktop.
# UNTESTED!
# spec
it_should_require_admin_for_actions :new => :get, :create => :post, :edit => :get, :update => :put, :destroy => :delete
# macro
def it_should_require_admin_for_actions(actions={})
actions.each do |action, method|
it "#{action} action (with method #{method}) should require admin" do
send(method, action, :id => 1)
response.should redirect_to(login_url)
flash[:error].should == "Unauthorized Access"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment