diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-03-01 20:22:08 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-03-01 20:22:08 +0000 |
commit | 7448e0dbc41a53f643ac3c8ebd486d9aa02f593b (patch) | |
tree | ee07026dcfa17c2e13e0723f9dff25150c263d49 | |
parent | ac46497f1abd9e2e69a0b3c4848d8825847d1934 (diff) | |
download | redmine-7448e0dbc41a53f643ac3c8ebd486d9aa02f593b.tar.gz redmine-7448e0dbc41a53f643ac3c8ebd486d9aa02f593b.zip |
Fixed that the bulk edit/copy form does not propose versions and categories for the target project (#10350).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9046 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/issues_controller.rb | 4 | ||||
-rw-r--r-- | app/views/issues/bulk_edit.html.erb | 9 | ||||
-rw-r--r-- | test/functional/issues_controller_test.rb | 22 |
3 files changed, 27 insertions, 8 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 63b3412be..b1a383c66 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -221,7 +221,7 @@ class IssuesController < ApplicationController if User.current.allowed_to?(:move_issues, @projects) @allowed_projects = Issue.allowed_target_projects_on_move if params[:issue] - @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id]} + @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s} if @target_project target_projects = [@target_project] end @@ -233,6 +233,8 @@ class IssuesController < ApplicationController @custom_fields = target_projects.map{|p|p.all_issue_custom_fields}.reduce(:&) @assignables = target_projects.map(&:assignable_users).reduce(:&) @trackers = target_projects.map(&:trackers).reduce(:&) + @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&) + @categories = target_projects.map {|p| p.issue_categories}.reduce(:&) @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) render :layout => false if request.xhr? diff --git a/app/views/issues/bulk_edit.html.erb b/app/views/issues/bulk_edit.html.erb index 13200d726..0263ab916 100644 --- a/app/views/issues/bulk_edit.html.erb +++ b/app/views/issues/bulk_edit.html.erb @@ -43,23 +43,18 @@ content_tag('option', l(:label_nobody), :value => 'none') + principals_options_for_select(@assignables)) %> </p> -<% if @project %> <p> <label for='issue_category_id'><%= l(:field_category) %></label> <%= select_tag('issue[category_id]', content_tag('option', l(:label_no_change_option), :value => '') + content_tag('option', l(:label_none), :value => 'none') + - options_from_collection_for_select(@project.issue_categories, :id, :name)) %> + options_from_collection_for_select(@categories, :id, :name)) %> </p> -<% end %> -<% #TODO: allow editing versions when multiple projects %> -<% if @project %> <p> <label for='issue_fixed_version_id'><%= l(:field_fixed_version) %></label> <%= select_tag('issue[fixed_version_id]', content_tag('option', l(:label_no_change_option), :value => '') + content_tag('option', l(:label_none), :value => 'none') + - version_options_for_select(@project.shared_versions.open.sort)) %> + version_options_for_select(@versions.sort)) %> </p> -<% end %> <% @custom_fields.each do |custom_field| %> <p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('issue', custom_field, @projects) %></p> diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index f85d157ce..04df391a1 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -2672,6 +2672,28 @@ class IssuesControllerTest < ActionController::TestCase :children => {:count => 3} # 2 statuses + "no change" option end + def test_bulk_edit_should_propose_target_project_open_shared_versions + @request.session[:user_id] = 2 + post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1} + assert_response :success + assert_template 'bulk_edit' + assert_equal Project.find(1).shared_versions.open.all.sort, assigns(:versions).sort + assert_tag 'select', + :attributes => {:name => 'issue[fixed_version_id]'}, + :descendant => {:tag => 'option', :content => '2.0'} + end + + def test_bulk_edit_should_propose_target_project_categories + @request.session[:user_id] = 2 + post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1} + assert_response :success + assert_template 'bulk_edit' + assert_equal Project.find(1).issue_categories.sort, assigns(:categories).sort + assert_tag 'select', + :attributes => {:name => 'issue[category_id]'}, + :descendant => {:tag => 'option', :content => 'Recipes'} + end + def test_bulk_update @request.session[:user_id] = 2 # update issues priority |