1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'elections_controller'
4 # Re-raise errors caught by the controller.
5 class ElectionsController; def rescue_action(e) raise e end; end
7 class ElectionsControllerTest < Test::Unit::TestCase
11 @controller = ElectionsController.new
12 @request = ActionController::TestRequest.new
13 @response = ActionController::TestResponse.new
18 assert_response :success
19 assert_template 'list'
25 assert_response :success
26 assert_template 'list'
28 assert_not_nil assigns(:elections)
34 assert_response :success
35 assert_template 'show'
37 assert_not_nil assigns(:election)
38 assert assigns(:election).valid?
44 assert_response :success
47 assert_not_nil assigns(:election)
51 num_elections = Election.count
53 post :create, :election => {}
55 assert_response :redirect
56 assert_redirected_to :action => 'list'
58 assert_equal num_elections + 1, Election.count
64 assert_response :success
65 assert_template 'edit'
67 assert_not_nil assigns(:election)
68 assert assigns(:election).valid?
72 post :update, :id => 1
73 assert_response :redirect
74 assert_redirected_to :action => 'show', :id => 1
78 assert_not_nil Election.find(1)
80 post :destroy, :id => 1
81 assert_response :redirect
82 assert_redirected_to :action => 'list'
84 assert_raise(ActiveRecord::RecordNotFound) {