Blarg, finally got functional testing framework working. Had to override the TestSess...
[selectricity] / test / functional / quickvote_controller_test.rb
index f2b0c2c06c1ddff655fdd08e71c54e813df2472c..3f230b2f56645e3f2878340148e508b97f256a84 100644 (file)
@@ -1,6 +1,13 @@
 require File.dirname(__FILE__) + '/../test_helper'
 require 'quickvote_controller'
 
 require File.dirname(__FILE__) + '/../test_helper'
 require 'quickvote_controller'
 
+class ActionController::TestSession
+  def session_id
+    # Override this so we can set session ID
+    # pass in the 'test_session_id' session variable to override default
+    (@session and @session['test_session_id'])  or "12345678"
+  end
+end
 # Re-raise errors caught by the controller.
 class QuickvoteController; def rescue_action(e) raise e end; end
 
 # Re-raise errors caught by the controller.
 class QuickvoteController; def rescue_action(e) raise e end; end
 
@@ -16,7 +23,16 @@ class QuickvoteControllerTest < Test::Unit::TestCase
     get :index
     assert_response 302
   end
     get :index
     assert_response 302
   end
+
   def test_create_quickvote
   def test_create_quickvote
+    post(:create, {'commit' =>"Create Quickvote", 'quickvote' =>{'name' =>"variable", 'description' =>"Favorite variable."}}, nil, {:candlist=>["foo", "bar", "foobar"]})
+    assert_response :success
+    get :index, { 'ident' => "variable"}
+    assert_response :success
+  end
 
 
+  def test_get_quickvote_nonexistent
+    get :index, { 'ident' => "idontexist" }
+    assert_redirected_to :controller => 'site'
   end
 end
   end
 end

Benjamin Mako Hill || Want to submit a patch?