]> projects.mako.cc - selectricity/blob - test/unit/quickvote_test.rb
updated and moved ignore file
[selectricity] / test / unit / quickvote_test.rb
1 require File.dirname(__FILE__) + '/../test_helper'
2
3 class QuickVoteTest < Test::Unit::TestCase
4   fixtures :elections, :candidates
5
6   def setup
7     @quickvote_normal = QuickVote.find(1)
8   end
9
10   def test_create_update_delete_quickvote_from_fixture
11     assert_kind_of QuickVote, @quickvote_normal
12     assert_equal 1, @quickvote_normal.id
13     assert_equal 'acetarium', @quickvote_normal.name
14     assert_equal 'who is the winner?', @quickvote_normal.description
15     #assert_equal QuickVote, @quickvote_normal.type
16     assert_equal 'ssd', @quickvote_normal.election_method
17     assert_equal '2007-08-22 12:00:00', @quickvote_normal.startdate_before_type_cast
18     assert_equal '2007-09-21 11:59:59', @quickvote_normal.enddate_before_type_cast
19
20     # make sure that the each of the three andidates
21     (1..3).each do |i|
22       assert @quickvote_normal.candidates.include?(Candidate.find(i))
23     end
24
25     # update and save
26     @quickvote_normal.name = 'foobar'
27     assert @quickvote_normal.save,
28            @quickvote_normal.errors.full_messages.join("; ")
29
30     @quickvote_normal.reload
31     assert_equal 'foobar', @quickvote_normal.name
32   end
33
34   def test_create_invalid_enddate
35     qv = QuickVote.find(2)
36     assert_equal qv.save, false, "created vote with invalid enddate"
37   end
38 end

Benjamin Mako Hill || Want to submit a patch?