summaryrefslogtreecommitdiffstats
path: root/test/functional/timelog_controller_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2020-04-05 08:21:25 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2020-04-05 08:21:25 +0000
commite91dbcb5a707db117f896ae099480b99b0805b00 (patch)
tree80417c2042d692efa983f9897f306c6b5502b4aa /test/functional/timelog_controller_test.rb
parent214ec3e80655da61874fe0557849cfef8b063fdb (diff)
downloadredmine-e91dbcb5a707db117f896ae099480b99b0805b00.tar.gz
redmine-e91dbcb5a707db117f896ae099480b99b0805b00.zip
Editing a time entry for a locked user changes the user to the current user (#32973).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@19651 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/timelog_controller_test.rb')
-rw-r--r--test/functional/timelog_controller_test.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index a9da5fa42..d98910815 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -186,6 +186,28 @@ class TimelogControllerTest < Redmine::ControllerTest
assert_select 'a[href=?]', '/projects/ecookbook/time_entries', {:text => 'Cancel'}
end
+ def test_get_edit_with_an_existing_time_entry_with_locked_user
+ user = User.find(3)
+ entry = TimeEntry.generate!(:user_id => user.id, :comments => "Time entry on a future locked user")
+ entry.save!
+
+ user.status = User::STATUS_LOCKED
+ user.save!
+ Role.find_by_name('Manager').add_permission! :log_time_for_other_users
+ @request.session[:user_id] = 2
+
+ get :edit, :params => {
+ :id => entry.id
+ }
+
+ assert_response :success
+
+ assert_select 'select[name=?]', 'time_entry[user_id]' do
+ # User with id 3 should be selected even if it's locked
+ assert_select 'option[value="3"][selected=selected]'
+ end
+ end
+
def test_post_create
@request.session[:user_id] = 3
assert_difference 'TimeEntry.count' do
@@ -639,6 +661,26 @@ class TimelogControllerTest < Redmine::ControllerTest
assert_select 'p[id=?]', 'errorExplanation', :text => I18n.t(:error_not_allowed_to_log_time_for_other_users)
end
+ def test_update_should_allow_updating_existing_entry_logged_on_a_locked_user
+ entry = TimeEntry.generate!(:user_id => 2, :hours => 4, :comments => "Time entry on a future locked user")
+ Role.find_by_name('Manager').add_permission! :log_time_for_other_users
+ @request.session[:user_id] = 2
+
+ put :update, :params => {
+ :id => entry.id,
+ :time_entry => {
+ :hours => '6'
+ }
+ }
+
+ assert_response :redirect
+
+ entry.reload
+ # Ensure user didn't change
+ assert_equal 2, entry.user_id
+ assert_equal 6.0, entry.hours
+ end
+
def test_get_bulk_edit
@request.session[:user_id] = 2