From 66d0636fffaf7f27be63081180ba53fd515d9377 Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Tue, 10 Mar 2020 23:47:02 +0200 Subject: [PATCH] Show time entry user info in edit page also for users without permission to log time for other users diff --git a/app/views/timelog/_form.html.erb b/app/views/timelog/_form.html.erb index bfeb67337..24bce8b6d 100644 --- a/app/views/timelog/_form.html.erb +++ b/app/views/timelog/_form.html.erb @@ -16,8 +16,14 @@ <%= link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %>

+ <% if User.current.allowed_to?(:log_time_for_other_users, @project) %>

<%= f.select :user_id, user_collection_for_select_options(@time_entry), :required => true %>

+ <% elsif !@time_entry.new_record? %> +

+ <%= f.label_for_field :user_id %> + <%= link_to_user(@time_entry.user) %> +

<% end %>

<%= f.date_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %>

<%= f.hours_field :hours, :size => 6, :required => true %>

diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index b57dfb8c3..61ef00d8e 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -46,6 +46,8 @@ class TimelogControllerTest < Redmine::ControllerTest # blank option for project assert_select 'option[value=""]' end + assert_select 'label[for=?]', 'time_entry_user_id', 0 + assert_select 'select[name=?]', 'time_entry[user_id]', 0 end def test_new_with_project_id @@ -150,6 +152,11 @@ class TimelogControllerTest < Redmine::ControllerTest assert_response :success assert_select 'form[action=?]', '/time_entries/2' + + # Time entry user should be shown as text + # for user without permission to log time for other users + assert_select 'label[for=?]', 'time_entry_user_id', 1 + assert_select 'a.user.active', :text => 'Redmine Admin' end def test_get_edit_with_an_existing_time_entry_with_inactive_activity -- 2.22.0