]> source.dussan.org Git - redmine.git/commitdiff
Fix that selected user on timelog#edit is incorrect (#32959).
authorGo MAEDA <maeda@farend.jp>
Sun, 9 Feb 2020 00:23:18 +0000 (00:23 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 9 Feb 2020 00:23:18 +0000 (00:23 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@19501 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/timelog_helper.rb
test/functional/timelog_controller_test.rb

index 2c3e500a54bd829e8c7c8332323decffbac6641b..d10b57332395f298d5980d2ab0f912fb2a7721cc 100644 (file)
@@ -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)
index f1764b7c996aa6ceb4ca484581b1737616fe1d8f..55c798b4d840aa701c530da91a223f70feacf54b 100644 (file)
@@ -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