Browse Source

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
tags/4.1.0
Jean-Philippe Lang 5 years ago
parent
commit
7a11864812
2 changed files with 39 additions and 0 deletions
  1. 2
    0
      app/controllers/issues_controller.rb
  2. 37
    0
      test/functional/issues_controller_test.rb

+ 2
- 0
app/controllers/issues_controller.rb View File

@@ -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

+ 37
- 0
test/functional/issues_controller_test.rb View File

@@ -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 => {

Loading…
Cancel
Save