Add some empty request testcases.
authorJohn Dong <jdong@mit.edu>
Mon, 20 Aug 2007 19:05:04 +0000 (15:05 -0400)
committerJohn Dong <jdong@mit.edu>
Mon, 20 Aug 2007 19:05:04 +0000 (15:05 -0400)
BREAKAGE: Justin, your new graphs break the results page on empty stuff again (see rake output). Fix.

test/functional/quickvote_controller_test.rb

index ceb1b6b4b5d1cd518f75e305521a2cc8851d2f5f..07c9278696053d3615636a1b176e0e88327800d4 100644 (file)
@@ -41,8 +41,28 @@ class QuickvoteControllerTest < Test::Unit::TestCase
     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

Benjamin Mako Hill || Want to submit a patch?