Skip to content

Instantly share code, notes, and snippets.

@jamesbrink
Created March 6, 2011 07:07
Show Gist options
  • Save jamesbrink/857097 to your computer and use it in GitHub Desktop.
Save jamesbrink/857097 to your computer and use it in GitHub Desktop.
require 'test_helper'
class PatientsControllerTest < ActionController::TestCase
setup do
@patient = patients(:one)
activate_authlogic
end
test "patient actions without user" do
PatientsController.action_methods.each do |action|
if action == "index"
get action.to_sym
assert_redirected_to :login
else
get action.to_sym, :id => @patient.to_param
assert_redirected_to :login
end
end
end
test "patient index as admin" do
UserSession.create(users(:admin))
get :index
assert_response :success
end
test "patient new as admin" do
UserSession.create(users(:admin))
get :new
assert_response :success
end
test "patient create as admin" do
UserSession.create(users(:admin))
assert_difference('patients.count') do
post :create, :patient => @patient.attributes
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment