clemens (owner)

Revisions

gist: 94405 Download_button fork
public
Public Clone URL: git://gist.github.com/94405.git
Embed All Files: show embed
Hint for Railscasts Episode #157 #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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