X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/192728d0e5facadf7e41ed737ca59e5c14123efd..4ae380231b08416a3ac3b6966d9dbc00a73fc3ca:/test/functional/quickvote_controller_test.rb diff --git a/test/functional/quickvote_controller_test.rb b/test/functional/quickvote_controller_test.rb index 3f230b2..07c9278 100644 --- a/test/functional/quickvote_controller_test.rb +++ b/test/functional/quickvote_controller_test.rb @@ -26,13 +26,43 @@ class QuickvoteControllerTest < Test::Unit::TestCase def test_create_quickvote post(:create, {'commit' =>"Create Quickvote", 'quickvote' =>{'name' =>"variable", 'description' =>"Favorite variable."}}, nil, {:candlist=>["foo", "bar", "foobar"]}) - assert_response :success + assert_template "quickvote/success" get :index, { 'ident' => "variable"} assert_response :success end + def test_create_quickvote_badname + post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candlist => ["foo", "bar", "foobar"]}) + assert_template "quickvote/create" + end + + def test_create_quickvote_dupe_candidate + post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candlist => ["foo", "bar", "bar", "foobar"]}) + assert_template "quickvote/create" + end + + def test_create_quickvote_nil_candidate + post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candlist => nil}) + assert_template "quickvote/create" + post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candlist => []}) + assert_template "quickvote/create" + end + def test_get_quickvote_nonexistent get :index, { 'ident' => "idontexist" } assert_redirected_to :controller => 'site' end + + def test_get_result_empty_vote + test_create_quickvote + get :results, { 'ident' => 'variable' } + assert_response :success + end + + def test_get_result_nonexistent + test_create_quickvote + get :results, { 'ident' => 'asdflaksdjf' } + assert_redirected_to :controller => 'site' + end + end