Adds custom field selection on tracker form.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3145 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2009-12-09 10:58:51 +00:00
parent 8f9f56502d
commit 34d14be556
2 changed files with 17 additions and 2 deletions

View File

@ -6,6 +6,20 @@
<p><%= f.text_field :name, :required => true %></p> <p><%= f.text_field :name, :required => true %></p>
<p><%= f.check_box :is_in_chlog %></p> <p><%= f.check_box :is_in_chlog %></p>
<p><%= f.check_box :is_in_roadmap %></p> <p><%= f.check_box :is_in_roadmap %></p>
<% if IssueCustomField.all.any? %>
<p>
<label><%= l(:label_custom_field_plural) %></label>
<% IssueCustomField.all.each do |field| %>
<label class="block">
<%= check_box_tag 'tracker[custom_field_ids][]',field.id, @tracker.custom_fields.include?(field) %>
<%=h field.name %>
</label>
<% end %>
</p>
<%= hidden_field_tag 'tracker[custom_field_ids][]', '' %>
<% end %>
<% if @tracker.new_record? && @trackers.any? %> <% if @tracker.new_record? && @trackers.any? %>
<p><label><%= l(:label_copy_workflow_from) %></label> <p><label><%= l(:label_copy_workflow_from) %></label>
<%= select_tag(:copy_workflow_from, content_tag("option") + options_from_collection_for_select(@trackers, :id, :name)) %></p> <%= select_tag(:copy_workflow_from, content_tag("option") + options_from_collection_for_select(@trackers, :id, :name)) %></p>

View File

@ -22,7 +22,7 @@ require 'trackers_controller'
class TrackersController; def rescue_action(e) raise e end; end class TrackersController; def rescue_action(e) raise e end; end
class TrackersControllerTest < ActionController::TestCase class TrackersControllerTest < ActionController::TestCase
fixtures :trackers, :projects, :projects_trackers, :users, :issues fixtures :trackers, :projects, :projects_trackers, :users, :issues, :custom_fields
def setup def setup
@controller = TrackersController.new @controller = TrackersController.new
@ -45,10 +45,11 @@ class TrackersControllerTest < ActionController::TestCase
end end
def test_post_new def test_post_new
post :new, :tracker => { :name => 'New tracker', :project_ids => ['1', '', ''] } post :new, :tracker => { :name => 'New tracker', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] }
assert_redirected_to '/trackers/list' assert_redirected_to '/trackers/list'
tracker = Tracker.find_by_name('New tracker') tracker = Tracker.find_by_name('New tracker')
assert_equal [1], tracker.project_ids.sort assert_equal [1], tracker.project_ids.sort
assert_equal [1, 6], tracker.custom_field_ids
assert_equal 0, tracker.workflows.count assert_equal 0, tracker.workflows.count
end end