@@ -1,27 +1,41 | |||||
1 | <%= error_messages_for 'tracker' %> |
|
1 | <%= error_messages_for 'tracker' %> | |
2 |
|
2 | |||
3 | <div class="splitcontentleft"> |
|
3 | <div class="splitcontentleft"> | |
4 | <div class="box tabular"> |
|
4 | <div class="box tabular"> | |
5 | <!--[form:tracker]--> |
|
5 | <!--[form:tracker]--> | |
6 | <p><%= f.text_field :name, :required => true %></p> |
|
6 | <p><%= f.text_field :name, :required => true %></p> | |
7 | <p><%= f.check_box :is_in_chlog %></p> |
|
7 | <p><%= f.check_box :is_in_chlog %></p> | |
8 | <p><%= f.check_box :is_in_roadmap %></p> |
|
8 | <p><%= f.check_box :is_in_roadmap %></p> | |
|
9 | ||||
|
10 | <% if IssueCustomField.all.any? %> | |||
|
11 | <p> | |||
|
12 | <label><%= l(:label_custom_field_plural) %></label> | |||
|
13 | <% IssueCustomField.all.each do |field| %> | |||
|
14 | <label class="block"> | |||
|
15 | <%= check_box_tag 'tracker[custom_field_ids][]',field.id, @tracker.custom_fields.include?(field) %> | |||
|
16 | <%=h field.name %> | |||
|
17 | </label> | |||
|
18 | <% end %> | |||
|
19 | </p> | |||
|
20 | <%= hidden_field_tag 'tracker[custom_field_ids][]', '' %> | |||
|
21 | <% end %> | |||
|
22 | ||||
9 | <% if @tracker.new_record? && @trackers.any? %> |
|
23 | <% if @tracker.new_record? && @trackers.any? %> | |
10 | <p><label><%= l(:label_copy_workflow_from) %></label> |
|
24 | <p><label><%= l(:label_copy_workflow_from) %></label> | |
11 | <%= select_tag(:copy_workflow_from, content_tag("option") + options_from_collection_for_select(@trackers, :id, :name)) %></p> |
|
25 | <%= select_tag(:copy_workflow_from, content_tag("option") + options_from_collection_for_select(@trackers, :id, :name)) %></p> | |
12 | <% end %> |
|
26 | <% end %> | |
13 | <!--[eoform:tracker]--> |
|
27 | <!--[eoform:tracker]--> | |
14 | </div> |
|
28 | </div> | |
15 | </div> |
|
29 | </div> | |
16 |
|
30 | |||
17 | <div class="splitcontentright"> |
|
31 | <div class="splitcontentright"> | |
18 | <% if @projects.any? %> |
|
32 | <% if @projects.any? %> | |
19 | <fieldset class="box" id="tracker_project_ids"><legend><%= l(:label_project_plural) %></legend> |
|
33 | <fieldset class="box" id="tracker_project_ids"><legend><%= l(:label_project_plural) %></legend> | |
20 | <%= project_nested_ul(@projects) do |p| |
|
34 | <%= project_nested_ul(@projects) do |p| | |
21 | content_tag('label', check_box_tag('tracker[project_ids][]', p.id, @tracker.projects.include?(p), :id => nil) + ' ' + h(p)) |
|
35 | content_tag('label', check_box_tag('tracker[project_ids][]', p.id, @tracker.projects.include?(p), :id => nil) + ' ' + h(p)) | |
22 | end %> |
|
36 | end %> | |
23 | <%= hidden_field_tag('tracker[project_ids][]', '', :id => nil) %> |
|
37 | <%= hidden_field_tag('tracker[project_ids][]', '', :id => nil) %> | |
24 | <p><%= check_all_links 'tracker_project_ids' %></p> |
|
38 | <p><%= check_all_links 'tracker_project_ids' %></p> | |
25 | </fieldset> |
|
39 | </fieldset> | |
26 | <% end %> |
|
40 | <% end %> | |
27 | </div> |
|
41 | </div> |
@@ -1,119 +1,120 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2009 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2009 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
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 |
|
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. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'trackers_controller' |
|
19 | require 'trackers_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class TrackersController; def rescue_action(e) raise e end; end |
|
22 | class TrackersController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class TrackersControllerTest < ActionController::TestCase |
|
24 | class TrackersControllerTest < ActionController::TestCase | |
25 | fixtures :trackers, :projects, :projects_trackers, :users, :issues |
|
25 | fixtures :trackers, :projects, :projects_trackers, :users, :issues, :custom_fields | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = TrackersController.new |
|
28 | @controller = TrackersController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | User.current = nil |
|
31 | User.current = nil | |
32 | @request.session[:user_id] = 1 # admin |
|
32 | @request.session[:user_id] = 1 # admin | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
35 | def test_index |
|
35 | def test_index | |
36 | get :index |
|
36 | get :index | |
37 | assert_response :success |
|
37 | assert_response :success | |
38 | assert_template 'list' |
|
38 | assert_template 'list' | |
39 | end |
|
39 | end | |
40 |
|
40 | |||
41 | def test_get_new |
|
41 | def test_get_new | |
42 | get :new |
|
42 | get :new | |
43 | assert_response :success |
|
43 | assert_response :success | |
44 | assert_template 'new' |
|
44 | assert_template 'new' | |
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | def test_post_new |
|
47 | def test_post_new | |
48 | post :new, :tracker => { :name => 'New tracker', :project_ids => ['1', '', ''] } |
|
48 | post :new, :tracker => { :name => 'New tracker', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] } | |
49 | assert_redirected_to '/trackers/list' |
|
49 | assert_redirected_to '/trackers/list' | |
50 | tracker = Tracker.find_by_name('New tracker') |
|
50 | tracker = Tracker.find_by_name('New tracker') | |
51 | assert_equal [1], tracker.project_ids.sort |
|
51 | assert_equal [1], tracker.project_ids.sort | |
|
52 | assert_equal [1, 6], tracker.custom_field_ids | |||
52 | assert_equal 0, tracker.workflows.count |
|
53 | assert_equal 0, tracker.workflows.count | |
53 | end |
|
54 | end | |
54 |
|
55 | |||
55 | def test_post_new_with_workflow_copy |
|
56 | def test_post_new_with_workflow_copy | |
56 | post :new, :tracker => { :name => 'New tracker' }, :copy_workflow_from => 1 |
|
57 | post :new, :tracker => { :name => 'New tracker' }, :copy_workflow_from => 1 | |
57 | assert_redirected_to '/trackers/list' |
|
58 | assert_redirected_to '/trackers/list' | |
58 | tracker = Tracker.find_by_name('New tracker') |
|
59 | tracker = Tracker.find_by_name('New tracker') | |
59 | assert_equal 0, tracker.projects.count |
|
60 | assert_equal 0, tracker.projects.count | |
60 | assert_equal Tracker.find(1).workflows.count, tracker.workflows.count |
|
61 | assert_equal Tracker.find(1).workflows.count, tracker.workflows.count | |
61 | end |
|
62 | end | |
62 |
|
63 | |||
63 | def test_get_edit |
|
64 | def test_get_edit | |
64 | Tracker.find(1).project_ids = [1, 3] |
|
65 | Tracker.find(1).project_ids = [1, 3] | |
65 |
|
66 | |||
66 | get :edit, :id => 1 |
|
67 | get :edit, :id => 1 | |
67 | assert_response :success |
|
68 | assert_response :success | |
68 | assert_template 'edit' |
|
69 | assert_template 'edit' | |
69 |
|
70 | |||
70 | assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', |
|
71 | assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', | |
71 | :value => '1', |
|
72 | :value => '1', | |
72 | :checked => 'checked' } |
|
73 | :checked => 'checked' } | |
73 |
|
74 | |||
74 | assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', |
|
75 | assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', | |
75 | :value => '2', |
|
76 | :value => '2', | |
76 | :checked => nil } |
|
77 | :checked => nil } | |
77 |
|
78 | |||
78 | assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', |
|
79 | assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', | |
79 | :value => '', |
|
80 | :value => '', | |
80 | :type => 'hidden'} |
|
81 | :type => 'hidden'} | |
81 | end |
|
82 | end | |
82 |
|
83 | |||
83 | def test_post_edit |
|
84 | def test_post_edit | |
84 | post :edit, :id => 1, :tracker => { :name => 'Renamed', |
|
85 | post :edit, :id => 1, :tracker => { :name => 'Renamed', | |
85 | :project_ids => ['1', '2', ''] } |
|
86 | :project_ids => ['1', '2', ''] } | |
86 | assert_redirected_to '/trackers/list' |
|
87 | assert_redirected_to '/trackers/list' | |
87 | assert_equal [1, 2], Tracker.find(1).project_ids.sort |
|
88 | assert_equal [1, 2], Tracker.find(1).project_ids.sort | |
88 | end |
|
89 | end | |
89 |
|
90 | |||
90 | def test_post_edit_without_projects |
|
91 | def test_post_edit_without_projects | |
91 | post :edit, :id => 1, :tracker => { :name => 'Renamed', |
|
92 | post :edit, :id => 1, :tracker => { :name => 'Renamed', | |
92 | :project_ids => [''] } |
|
93 | :project_ids => [''] } | |
93 | assert_redirected_to '/trackers/list' |
|
94 | assert_redirected_to '/trackers/list' | |
94 | assert Tracker.find(1).project_ids.empty? |
|
95 | assert Tracker.find(1).project_ids.empty? | |
95 | end |
|
96 | end | |
96 |
|
97 | |||
97 | def test_move_lower |
|
98 | def test_move_lower | |
98 | tracker = Tracker.find_by_position(1) |
|
99 | tracker = Tracker.find_by_position(1) | |
99 | post :edit, :id => 1, :tracker => { :move_to => 'lower' } |
|
100 | post :edit, :id => 1, :tracker => { :move_to => 'lower' } | |
100 | assert_equal 2, tracker.reload.position |
|
101 | assert_equal 2, tracker.reload.position | |
101 | end |
|
102 | end | |
102 |
|
103 | |||
103 | def test_destroy |
|
104 | def test_destroy | |
104 | tracker = Tracker.create!(:name => 'Destroyable') |
|
105 | tracker = Tracker.create!(:name => 'Destroyable') | |
105 | assert_difference 'Tracker.count', -1 do |
|
106 | assert_difference 'Tracker.count', -1 do | |
106 | post :destroy, :id => tracker.id |
|
107 | post :destroy, :id => tracker.id | |
107 | end |
|
108 | end | |
108 | assert_redirected_to '/trackers/list' |
|
109 | assert_redirected_to '/trackers/list' | |
109 | assert_nil flash[:error] |
|
110 | assert_nil flash[:error] | |
110 | end |
|
111 | end | |
111 |
|
112 | |||
112 | def test_destroy_tracker_in_use |
|
113 | def test_destroy_tracker_in_use | |
113 | assert_no_difference 'Tracker.count' do |
|
114 | assert_no_difference 'Tracker.count' do | |
114 | post :destroy, :id => 1 |
|
115 | post :destroy, :id => 1 | |
115 | end |
|
116 | end | |
116 | assert_redirected_to '/trackers/list' |
|
117 | assert_redirected_to '/trackers/list' | |
117 | assert_not_nil flash[:error] |
|
118 | assert_not_nil flash[:error] | |
118 | end |
|
119 | end | |
119 | end |
|
120 | end |
General Comments 0
You need to be logged in to leave comments.
Login now