+ def test_show_nonexist_votes_per_interval
+ assert_nothing_raised { get :votes_per_interval, { :id => 42 } }
+ end
+
+ def test_show_nonexist_borda_bar
+ assert_nothing_raised { get :borda_bar, { :id => 42 } }
+ end
+
+ def test_show_nonexist_choices_positions
+ assert_nothing_raised { get :choices_positions, { :id => 42 } }
+ end
+
+ def test_show_empty_votes_per_interval
+ make_election
+ get :votes_per_interval, { :id => @election.id }
+ assert_response :success
+ assert_equal 'image/png', @response.headers['Content-Type']
+ end
+
+ def test_show_empty_borda_bar
+ make_election
+ get :borda_bar, { :id => @election.id }
+ assert_response :success
+ assert_equal 'image/png', @response.headers['Content-Type']
+ end
+
+ def test_show_empty_choices_positions
+ make_election
+ get :choices_positions, { :id => @election.id }
+ assert_response :success
+ assert_equal 'image/png', @response.headers['Content-Type']
+ end
+
+ def test_show_single_votes_per_interval
+ make_election
+ cast_vote
+ get :votes_per_interval, { :id => @election.id }
+ assert_response :success
+ assert_equal 'image/png', @response.headers['Content-Type']
+ end
+
+ def test_show_single_borda_bar
+ make_election
+ cast_vote
+ get :borda_bar, { :id => @election.id }
+ assert_response :success
+ assert_equal 'image/png', @response.headers['Content-Type']
+ end
+
+ def test_show_single_choices_positions
+ make_election
+ cast_vote
+ get :choices_positions, { :id => @election.id }
+ assert_response :success
+ assert_equal 'image/png', @response.headers['Content-Type']
+ end
+
+ def test_show_many_votes_per_interval
+ make_election
+ 20.times {cast_vote}
+ get :votes_per_interval, { :id => @election.id }
+ assert_response :success
+ assert_equal 'image/png', @response.headers['Content-Type']
+ end
+
+ def test_show_many_borda_bar
+ make_election
+ 20.times {cast_vote}
+ get :borda_bar, { :id => @election.id }
+ assert_response :success
+ assert_equal 'image/png', @response.headers['Content-Type']
+ end
+
+ def test_show_many_choices_positions
+ make_election
+ 20.times {cast_vote}
+ get :choices_positions, { :id => @election.id }
+ assert_response :success
+ assert_equal 'image/png', @response.headers['Content-Type']
+ end
+
+
+ private
+ def make_election
+ e=ElectionStruct.new( :name => "test", :description => "This is a test",
+ :candidate_names => ['choice1', 'choice2', 'choice3'])
+ @SS.create_quickvote e
+ @election = @SS.list_quickvotes[0]
+ assert_not_nil @election
+ end
+
+ private
+ def cast_vote
+ @SS.cast_quickvote @election.name, 42, [@election.candidate_ids.sort_by {rand}]