summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2019-03-15 09:37:04 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2019-03-15 09:37:04 +0000
commit7a11864812f790df7ffbf6ef61c9818caedae027 (patch)
tree99bfda5c4dd80f6a1b4b40b3d0abd6e561ce8964
parent9f24ceb6b3facdac5ae5cb3782779ca00465f991 (diff)
downloadredmine-7a11864812f790df7ffbf6ef61c9818caedae027.tar.gz
redmine-7a11864812f790df7ffbf6ef61c9818caedae027.zip
Support issue[assigned_to_id]=me when prefilling issues (#28502).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@17964 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/issues_controller.rb2
-rw-r--r--test/functional/issues_controller_test.rb37
2 files changed, 39 insertions, 0 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 7d9a9ee6e..0630a1b2d 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -466,6 +466,7 @@ class IssuesController < ApplicationController
@issue.init_journal(User.current)
issue_attributes = params[:issue]
+ issue_attributes[:assigned_to_id] = User.current.id if issue_attributes && issue_attributes[:assigned_to_id] == 'me'
if issue_attributes && params[:conflict_resolution]
case params[:conflict_resolution]
when 'overwrite'
@@ -522,6 +523,7 @@ class IssuesController < ApplicationController
# so we can use the default version for the new project
attrs.delete(:fixed_version_id)
end
+ attrs[:assigned_to_id] = User.current.id if attrs[:assigned_to_id] == 'me'
@issue.safe_attributes = attrs
if @issue.project
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 1d11eac73..30ecd3073 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -2552,6 +2552,17 @@ class IssuesControllerTest < Redmine::ControllerTest
end
end
+ def test_new_with_me_assigned_to_id
+ @request.session[:user_id] = 2
+ get :new, :params => {
+ :issue => { :assigned_to_id => 'me' }
+ }
+ assert_response :success
+ assert_select 'select[name=?]', 'issue[assigned_to_id]' do
+ assert_select 'option[value="2"][selected=selected]'
+ end
+ end
+
def test_new_should_select_default_status
@request.session[:user_id] = 2
@@ -4579,6 +4590,18 @@ class IssuesControllerTest < Redmine::ControllerTest
end
end
+ def test_get_edit_with_me_assigned_to_id
+ @request.session[:user_id] = 2
+ get :edit, :params => {
+ :id => 1,
+ :issue => { :assigned_to_id => 'me' }
+ }
+ assert_response :success
+ assert_select 'select[name=?]', 'issue[assigned_to_id]' do
+ assert_select 'option[value="2"][selected=selected]'
+ end
+ end
+
def test_update_form_for_existing_issue
@request.session[:user_id] = 2
patch :edit, :params => {
@@ -5395,6 +5418,20 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_equal 'Original subject', issue.reload.subject
end
+ def test_update_with_me_assigned_to_id
+ @request.session[:user_id] = 2
+ issue = Issue.find(1)
+ assert_not_equal 2, issue.assigned_to_id
+ put :update, :params => {
+ :id => issue.id,
+ :issue => {
+ :assigned_to_id => 'me'
+ }
+ }
+ assert_response 302
+ assert_equal 2, issue.reload.assigned_to_id
+ end
+
def test_get_bulk_edit
@request.session[:user_id] = 2
get :bulk_edit, :params => {