From e27e89197bd1ca0083431c48c6ed6ba01bf2ef07 Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Sat, 8 Feb 2020 22:23:13 +0200 Subject: [PATCH] Fix selected user on timelog#edit --- app/helpers/timelog_helper.rb | 2 +- test/functional/timelog_controller_test.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb index 2c3e500a5..d10b57332 100644 --- a/app/helpers/timelog_helper.rb +++ b/app/helpers/timelog_helper.rb @@ -44,7 +44,7 @@ module TimelogHelper def user_collection_for_select_options(time_entry) collection = time_entry.assignable_users - principals_options_for_select(collection, time_entry.user_id) + principals_options_for_select(collection, time_entry.user_id.to_s) end def select_hours(data, criteria, value) diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index f1764b7c9..55c798b4d 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -1458,4 +1458,19 @@ class TimelogControllerTest < Redmine::ControllerTest assert_response :success assert_select "td.issue_cf_#{field.id}", :text => 'This is a long text' end + + def test_edit_for_other_user + Role.find_by_name('Manager').add_permission! :log_time_for_other_users + @request.session[:user_id] = 2 + + get :edit, :params => { + :id => 1 + } + + assert_response :success + + assert_select 'select[name=?]', 'time_entry[user_id]' do + assert_select 'option[value="2"][selected=selected]' + end + end end -- 2.22.0