]> projects.mako.cc - selectricity/blobdiff - test/unit/quickvote_test.rb
Conditional that redircts to user profile page if too many elections in control panel...
[selectricity] / test / unit / quickvote_test.rb
index 99274e4b7b2bd1b6c9ec14bb7294afe112eaf96d..69a7033c3487f3b64280a42e4bdc597e27da55c6 100644 (file)
@@ -1,12 +1,38 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class QuickVoteTest < Test::Unit::TestCase
-  fixtures :quickvote
-  
-  def correct_enddate
-    true
+  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?