##// END OF EJS Templates
Do not clear category on project change if category with same exists (#16941)....
Jean-Philippe Lang -
r14333:bf1f60f65fdb
parent child
Show More
@@ -454,6 +454,11 class Issue < ActiveRecord::Base
454 454 if allowed_target_projects(user).where(:id => p.to_i).exists?
455 455 self.project_id = p
456 456 end
457
458 if project_id_changed? && attrs['category_id'].to_s == category_id_was.to_s
459 # Discard submitted category on previous project
460 attrs.delete('category_id')
461 end
457 462 end
458 463
459 464 if (t = attrs.delete('tracker_id')) && safe_attribute?('tracker_id')
@@ -3096,6 +3096,22 class IssuesControllerTest < ActionController::TestCase
3096 3096 assert_equal 'This is the test_new issue', issue.subject
3097 3097 end
3098 3098
3099 def test_update_form_should_keep_category_with_same_when_changing_project
3100 source = Project.generate!
3101 target = Project.generate!
3102 source_category = IssueCategory.create!(:name => 'Foo', :project => source)
3103 target_category = IssueCategory.create!(:name => 'Foo', :project => target)
3104 issue = Issue.generate!(:project => source, :category => source_category)
3105
3106 @request.session[:user_id] = 1
3107 patch :edit, :id => issue.id,
3108 :issue => {:project_id => target.id, :category_id => source_category.id}
3109 assert_response :success
3110
3111 issue = assigns(:issue)
3112 assert_equal target_category, issue.category
3113 end
3114
3099 3115 def test_update_form_should_propose_default_status_for_existing_issue
3100 3116 @request.session[:user_id] = 2
3101 3117 WorkflowTransition.delete_all
General Comments 0
You need to be logged in to leave comments. Login now