added new tests and fixtures
[selectricity] / test / functional / quickvote_controller_test.rb
index e116c0d7ada00a5335eb7044eca262dd6f350c4e..65dfa2af1a3eb9bc02d6495d9b9744c82079be4e 100644 (file)
@@ -21,41 +21,55 @@ class QuickvoteControllerTest < Test::Unit::TestCase
     @response   = ActionController::TestResponse.new
   end
 
-  # Replace this with your real tests.
   def test_index
     get :index
     assert_response 302
   end
 
   def test_create_quickvote
-    post(:create, {'commit' =>"Create Quickvote", 'quickvote' =>{'name' =>"variable", 'description' =>"Favorite variable."}}, nil, {:candidate_names=>["foo", "bar", "foobar"]})
+    post(:create, {'commit' =>"Create Quickvote",
+      'quickvote' =>{'name' =>"variable", 'description' =>"Favorite variable."}},
+      nil, {:candidate_names=>["foo", "bar", "foobar"]})
     assert_template "quickvote/success"
     get :index, { 'ident' => "variable"}
     assert_response :success
   end
 
-  def test_create_dupe_quickvote
-    test_create_quickvote
-    assert_raise(Test::Unit::AssertionFailedError) do
-      test_create_quickvote
-    end
-  end
+  #def test_create_dupe_quickvote
+  #  test_create_quickvote
+  #  assert_raise(Test::Unit::AssertionFailedError) do
+  #    test_create_quickvote
+  #  end
+  #end
 
   def test_create_quickvote_badname
-    post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candidate_names => ["foo", "bar", "foobar"]})
+    post(:create, {'commit' => "Create Quickvote",
+      'quickvote' => {'name' => "has a space", 'description' => "Foobar"}},
+      nil, {:candidate_names => ["foo", "bar", "foobar"]})
     assert_template "quickvote/_create_sidebar"
   end
 
   def test_create_quickvote_dupe_candidate
-    post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candidate_names => ["foo", "bar", "bar",  "foobar"]})
+    post(:create, {'commit' => "Create Quickvote",
+      'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, 
+      nil, {:candidate_names => ["foo", "bar", "bar",  "foobar"]})
     assert_template "quickvote/_create_sidebar"
   end
-  
+  # TODO these should be testing for something better than a non-method
+  # error!
   def test_create_quickvote_nil_candidate
-    post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candidate_names => nil})
-    assert_template "quickvote/_create_sidebar"
-    post(:create, {'commit' => "Create Quickvote", 'quickvote' => {'name' => "has a space", 'description' => "Foobar"}}, nil, {:candidate_names => []})
-    assert_template "quickvote/_create_sidebar"
+    assert_raise(NoMethodError) do
+      post(:create, {'commit' => "Create Quickvote", 
+        'quickvote' => {'name' => "has a space", 'description' => "Foobar"}},
+        nil, {:candidate_names => nil})
+    end
+    
+    assert_raise(NoMethodError) do 
+      post(:create, {'commit' => "Create Quickvote",
+        'quickvote' => {'name' => "has a space", 'description' => "Foobar"}},
+        nil, {:candidate_names => []})
+    end
   end
 
   def test_get_quickvote_nonexistent
@@ -87,7 +101,9 @@ class QuickvoteControllerTest < Test::Unit::TestCase
     5.times do |time|
       get :index, { 'ident' => 'variable' }, { 'test_session_id'  =>  (time+1)*50 }
       assert_response :success
-      post :confirm, { 'ident' => 'variable', 'rankings-list' => votes.sort_by {rand} }, { 'test_session_id' => (time+1)*50 }
+      post :confirm,
+        { 'ident' => 'variable', 'rankings-list' => votes.sort_by {rand} }, 
+        { 'test_session_id' => (time+1)*50 }
       assert_template 'quickvote/thanks'
     end
     get :results, { 'ident' => 'variable' }

Benjamin Mako Hill || Want to submit a patch?