Skip to content

Instantly share code, notes, and snippets.

@panSarin
Created January 18, 2013 19:52
Show Gist options
  • Save panSarin/4567882 to your computer and use it in GitHub Desktop.
Save panSarin/4567882 to your computer and use it in GitHub Desktop.
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