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