Admin::Tests
February 07, 2008
Been struggling a little with testing Admin::Controllers, mainly because I don’t fully understand the scaffold functional test code. Anyhow just generated Admin::Poop!! so we can see how the nesting affects the tests
class Admin::PoopsControllerTest < ActionController::TestCase
def test_should_get_index
get :index
assert_response :success
assert_not_nil assigns(:admin_poops)
end
def test_should_get_new
get :new
assert_response :success
end
def test_should_create_poop
assert_difference('Admin::Poop.count') do
post :create, :poop => { }
end
assert_redirected_to poop_path(assigns(:poop))
end
def test_should_show_poop
get :show, :id => admin_poops(:one).id
assert_response :success
end
def test_should_get_edit
get :edit, :id => admin_poops(:one).id
assert_response :success
end
def test_should_update_poop
put :update, :id => admin_poops(:one).id, :poop => { }
assert_redirected_to poop_path(assigns(:poop))
end
def test_should_destroy_poop
assert_difference('Admin::Poop.count', -1) do
delete :destroy, :id => admin_poops(:one).id
end
assert_redirected_to admin_poops_path
end
end