|
@ -0,0 +1,49 @@ |
|
|
|
|
|
require 'test_helper' |
|
|
|
|
|
|
|
|
|
|
|
class LoadsControllerTest < ActionController::TestCase |
|
|
|
|
|
def test_index |
|
|
|
|
|
get :index |
|
|
|
|
|
assert_template 'index' |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def test_new |
|
|
|
|
|
get :new |
|
|
|
|
|
assert_template 'new' |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def test_create_invalid |
|
|
|
|
|
Load.any_instance.stubs(:valid?).returns(false) |
|
|
|
|
|
post :create |
|
|
|
|
|
assert_template 'new' |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def test_create_valid |
|
|
|
|
|
Load.any_instance.stubs(:valid?).returns(true) |
|
|
|
|
|
post :create |
|
|
|
|
|
assert_redirected_to loads_url |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def test_edit |
|
|
|
|
|
get :edit, :id => Load.first |
|
|
|
|
|
assert_template 'edit' |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def test_update_invalid |
|
|
|
|
|
Load.any_instance.stubs(:valid?).returns(false) |
|
|
|
|
|
put :update, :id => Load.first |
|
|
|
|
|
assert_template 'edit' |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def test_update_valid |
|
|
|
|
|
Load.any_instance.stubs(:valid?).returns(true) |
|
|
|
|
|
put :update, :id => Load.first |
|
|
|
|
|
assert_redirected_to loads_url |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def test_destroy |
|
|
|
|
|
load = Load.first |
|
|
|
|
|
delete :destroy, :id => load |
|
|
|
|
|
assert_redirected_to loads_url |
|
|
|
|
|
assert !Load.exists?(load.id) |
|
|
|
|
|
end |
|
|
|
|
|
end |