X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/a8006b0bf9687f8882c3073eca2e8b4ebc7cde4a..897b987778781e888d458899161c5afdc6afa991:/test/unit/quickvote_test.rb?ds=sidebyside diff --git a/test/unit/quickvote_test.rb b/test/unit/quickvote_test.rb index 4282a70..69a7033 100644 --- a/test/unit/quickvote_test.rb +++ b/test/unit/quickvote_test.rb @@ -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