X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/823d530ba46c1fb3518c4deef0081738503837eb..678711ecac3f058c6010ac70c2a3d0ef6c32cbdb:/test/unit/quickvote_test.rb diff --git a/test/unit/quickvote_test.rb b/test/unit/quickvote_test.rb index 99274e4..69a7033 100644 --- a/test/unit/quickvote_test.rb +++ b/test/unit/quickvote_test.rb @@ -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