Created
January 18, 2013 19:52
-
-
Save panSarin/4567882 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
def sign_in(role) | |
user = create :user, role | |
controller.stub!(:current_user).and_return(user) | |
end | |
def check_privilages(action, role, result) | |
sign_in(role) | |
send(action[:method], action[:action], action[:params]) | |
if result | |
response.should_not redirect_to(controller: :home, action: :access_denied) | |
else | |
response.should redirect_to(controller: :home, action: :access_denied) | |
end | |
end | |
def rest_actions | |
[ | |
{method: :get, action: :index, params: {}}, | |
{method: :get, action: :new, params: {}}, | |
{method: :post, action: :create, params: {}}, | |
{method: :get, action: :edit, params: {id: 1}}, | |
{method: :put, action: :update, params: {id: 1}}, | |
{method: :delete, action: :destroy, params: {id: 1}} | |
] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment