Mercurial > hg > soundsoftware-site
comparison test/functional/.svn/text-base/trackers_controller_test.rb.svn-base @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children | af80e5618e9b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2009 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
15 # along with this program; if not, write to the Free Software | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.dirname(__FILE__) + '/../test_helper' | |
19 require 'trackers_controller' | |
20 | |
21 # Re-raise errors caught by the controller. | |
22 class TrackersController; def rescue_action(e) raise e end; end | |
23 | |
24 class TrackersControllerTest < ActionController::TestCase | |
25 fixtures :trackers, :projects, :projects_trackers, :users, :issues, :custom_fields | |
26 | |
27 def setup | |
28 @controller = TrackersController.new | |
29 @request = ActionController::TestRequest.new | |
30 @response = ActionController::TestResponse.new | |
31 User.current = nil | |
32 @request.session[:user_id] = 1 # admin | |
33 end | |
34 | |
35 def test_index | |
36 get :index | |
37 assert_response :success | |
38 assert_template 'index' | |
39 end | |
40 | |
41 def test_get_new | |
42 get :new | |
43 assert_response :success | |
44 assert_template 'new' | |
45 end | |
46 | |
47 def test_post_new | |
48 post :new, :tracker => { :name => 'New tracker', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] } | |
49 assert_redirected_to :action => 'index' | |
50 tracker = Tracker.find_by_name('New tracker') | |
51 assert_equal [1], tracker.project_ids.sort | |
52 assert_equal [1, 6], tracker.custom_field_ids | |
53 assert_equal 0, tracker.workflows.count | |
54 end | |
55 | |
56 def test_post_new_with_workflow_copy | |
57 post :new, :tracker => { :name => 'New tracker' }, :copy_workflow_from => 1 | |
58 assert_redirected_to :action => 'index' | |
59 tracker = Tracker.find_by_name('New tracker') | |
60 assert_equal 0, tracker.projects.count | |
61 assert_equal Tracker.find(1).workflows.count, tracker.workflows.count | |
62 end | |
63 | |
64 def test_get_edit | |
65 Tracker.find(1).project_ids = [1, 3] | |
66 | |
67 get :edit, :id => 1 | |
68 assert_response :success | |
69 assert_template 'edit' | |
70 | |
71 assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', | |
72 :value => '1', | |
73 :checked => 'checked' } | |
74 | |
75 assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', | |
76 :value => '2', | |
77 :checked => nil } | |
78 | |
79 assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', | |
80 :value => '', | |
81 :type => 'hidden'} | |
82 end | |
83 | |
84 def test_post_edit | |
85 post :edit, :id => 1, :tracker => { :name => 'Renamed', | |
86 :project_ids => ['1', '2', ''] } | |
87 assert_redirected_to :action => 'index' | |
88 assert_equal [1, 2], Tracker.find(1).project_ids.sort | |
89 end | |
90 | |
91 def test_post_edit_without_projects | |
92 post :edit, :id => 1, :tracker => { :name => 'Renamed', | |
93 :project_ids => [''] } | |
94 assert_redirected_to :action => 'index' | |
95 assert Tracker.find(1).project_ids.empty? | |
96 end | |
97 | |
98 def test_move_lower | |
99 tracker = Tracker.find_by_position(1) | |
100 post :edit, :id => 1, :tracker => { :move_to => 'lower' } | |
101 assert_equal 2, tracker.reload.position | |
102 end | |
103 | |
104 def test_destroy | |
105 tracker = Tracker.create!(:name => 'Destroyable') | |
106 assert_difference 'Tracker.count', -1 do | |
107 post :destroy, :id => tracker.id | |
108 end | |
109 assert_redirected_to :action => 'index' | |
110 assert_nil flash[:error] | |
111 end | |
112 | |
113 def test_destroy_tracker_in_use | |
114 assert_no_difference 'Tracker.count' do | |
115 post :destroy, :id => 1 | |
116 end | |
117 assert_redirected_to :action => 'index' | |
118 assert_not_nil flash[:error] | |
119 end | |
120 end |