1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'graph_controller'
3 require 'selectricity_service_controller'
5 # Re-raise errors caught by the controller.
6 class GraphController; def rescue_action(e) raise e end; end
8 class GraphControllerTest < Test::Unit::TestCase
13 @controller = GraphController.new
14 @request = ActionController::TestRequest.new
15 @response = ActionController::TestResponse.new
16 @SS = SelectricityService.new
20 # TODO Replace this with your actual tests
21 def test_show_nonexist_votes_per_interval
22 assert_raise(ActiveRecord::RecordNotFound) { get :votes_per_interval, { :id => 42 } }
25 def test_show_nonexist_borda_bar
26 assert_raise(ActiveRecord::RecordNotFound) { get :borda_bar, { :id => 42 } }
29 def test_show_nonexist_choices_positions
30 assert_raise(ActiveRecord::RecordNotFound) { get :choices_positions, { :id => 42 } }
33 def test_show_empty_votes_per_interval
35 get :votes_per_interval, { :id => @election.id }
36 assert_response :success
37 assert_equal 'image/png', @response.headers['Content-Type']
40 def test_show_empty_borda_bar
42 get :borda_bar, { :id => @election.id }
43 assert_response :success
44 assert_equal 'image/png', @response.headers['Content-Type']
47 def test_show_empty_choices_positions
49 get :choices_positions, { :id => @election.id }
50 assert_response :success
51 assert_equal 'image/png', @response.headers['Content-Type']
54 def test_show_single_votes_per_interval
57 get :votes_per_interval, { :id => @election.id }
58 assert_response :success
59 assert_equal 'image/png', @response.headers['Content-Type']
62 def test_show_single_borda_bar
65 get :borda_bar, { :id => @election.id }
66 assert_response :success
67 assert_equal 'image/png', @response.headers['Content-Type']
70 def test_show_single_choices_positions
73 get :choices_positions, { :id => @election.id }
74 assert_response :success
75 assert_equal 'image/png', @response.headers['Content-Type']
78 def test_show_many_votes_per_interval
81 get :votes_per_interval, { :id => @election.id }
82 assert_response :success
83 assert_equal 'image/png', @response.headers['Content-Type']
86 def test_show_many_borda_bar
89 get :borda_bar, { :id => @election.id }
90 assert_response :success
91 assert_equal 'image/png', @response.headers['Content-Type']
94 def test_show_many_choices_positions
97 get :choices_positions, { :id => @election.id }
98 assert_response :success
99 assert_equal 'image/png', @response.headers['Content-Type']
105 e=QuickVoteStruct.new( :name => "test", :description => "This is a test",
106 :candidate_names => ['choice1', 'choice2', 'choice3'])
107 @SS.create_quickvote e
108 @election = @SS.list_quickvotes[0]
109 assert_not_nil @election
114 @SS.cast_quickvote @election.name, 42, [@election.candidate_ids.sort_by {rand}]