]> projects.mako.cc - selectricity/blobdiff - test/unit/quickvote_test.rb
updated schema
[selectricity] / test / unit / quickvote_test.rb
index 4282a70ee88db0ba2b80135b29c3ca7ae2f37ce7..69a7033c3487f3b64280a42e4bdc597e27da55c6 100644 (file)
@@ -1,11 +1,38 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class QuickVoteTest < Test::Unit::TestCase
-  
-  def correct_enddate
-    
+  fixtures :elections, :candidates
+
+  def setup
+    @quickvote_normal = QuickVote.find(1)
+  end
+
+  def test_create_update_delete_quickvote_from_fixture
+    assert_kind_of QuickVote, @quickvote_normal
+    assert_equal 1, @quickvote_normal.id
+    assert_equal 'acetarium', @quickvote_normal.name
+    assert_equal 'who is the winner?', @quickvote_normal.description
+    #assert_equal QuickVote, @quickvote_normal.type
+    assert_equal 'ssd', @quickvote_normal.election_method
+    assert_equal '2007-08-22 12:00:00', @quickvote_normal.startdate_before_type_cast
+    assert_equal '2007-09-21 11:59:59', @quickvote_normal.enddate_before_type_cast
+
+    # make sure that the each of the three andidates
+    (1..3).each do |i|
+      assert @quickvote_normal.candidates.include?(Candidate.find(i))
+    end
+
+    # update and save
+    @quickvote_normal.name = 'foobar'
+    assert @quickvote_normal.save,
+           @quickvote_normal.errors.full_messages.join("; ")
+
+    @quickvote_normal.reload
+    assert_equal 'foobar', @quickvote_normal.name
+  end
+
+  def test_create_invalid_enddate
+    qv = QuickVote.find(2)
+    assert_equal qv.save, false, "created vote with invalid enddate"
   end
-  
-  
-  
-end
\ No newline at end of file
+end

Benjamin Mako Hill || Want to submit a patch?