foreman/test/functional/users_controller_test.rb @ 9c0e127b
1ba05a93 | Ohad Levy | require 'test_helper'
|
|
class UsersControllerTest < ActionController::TestCase
|
|||
72b4a854 | Juan Manuel | test "should get index" do
|
|
9c0e127b | Paul Kelly | get :index, {}, set_session_user
|
|
72b4a854 | Juan Manuel | assert_response :success
|
|
end
|
|||
test "should get edit" do
|
|||
u = User.new :login => "foo", :mail => "foo@bar.com"
|
|||
assert u.save!
|
|||
logger.info "************ ID = #{u.id}"
|
|||
9c0e127b | Paul Kelly | get :edit, {:id => u.id}, set_session_user
|
|
72b4a854 | Juan Manuel | #assert_response :success
|
|
end
|
|||
fa9836c1 | Lucas Tolchinsky | ||
72b4a854 | Juan Manuel | test "should update user" do
|
|
user = User.create :login => "foo", :mail => "foo@bar.com"
|
|||
fa9836c1 | Lucas Tolchinsky | ||
9c0e127b | Paul Kelly | put :update, { :commit => "Update", :id => user.id, :record => {:login => "johnsmith"} }, set_session_user
|
|
72b4a854 | Juan Manuel | mod_user = User.find_by_id(user.id)
|
|
fa9836c1 | Lucas Tolchinsky | ||
72b4a854 | Juan Manuel | assert mod_user.login == "johnsmith"
|
|
assert_redirected_to users_path
|
|||
end
|
|||
fa9836c1 | Lucas Tolchinsky | test "should get show" do
|
|
72b4a854 | Juan Manuel | u = User.create :login => "foo", :mail => "foo@bar.com"
|
|
9c0e127b | Paul Kelly | get :show, {:id => u.id}, set_session_user
|
|
72b4a854 | Juan Manuel | assert_not_nil assigns("record")
|
|
assert_response :success
|
|||
end
|
|||
fa9836c1 | Lucas Tolchinsky | ||
72b4a854 | Juan Manuel | test "should delete" do
|
|
9c0e127b | Paul Kelly | user = User.last
|
|
delete :destroy, {:id => user}, set_session_user
|
|||
assert_redirected_to users_url
|
|||
assert !User.exists?(user.id)
|
|||
1ba05a93 | Ohad Levy | end
|
|
end
|