Defect #36318

Saving time tracking activities without any change may turn a system activity into a project activity

Added by Yuichi HARADA about 1 month ago. Updated about 1 month ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Project settings
Target version:5.0.0
Resolution:Fixed Affected version:

Description

If you save system activities without editing them in the project settings, some activities will be created as project-specific activities.

reproduce.gif (436 KB) Yuichi HARADA, 2021-12-15 02:52

36318.patch Magnifier (1.93 KB) Yuichi HARADA, 2021-12-15 03:10

36318-v2.patch Magnifier (3.99 KB) Yuichi HARADA, 2021-12-15 07:55

Associated revisions

Revision 21319
Added by Go MAEDA about 1 month ago

Saving time tracking activities without any change may turn a system activity into a project activity (#36318).

Patch by Yuichi HARADA.

History

#1 Updated by Yuichi HARADA about 1 month ago

The following patch will solve the issue. I have attached a patch.

diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb
index 5f0e023ed9..534d8239e1 100644
--- a/app/models/enumeration.rb
+++ b/app/models/enumeration.rb
@@ -117,7 +117,7 @@ class Enumeration < ActiveRecord::Base
   # Does the +new+ Hash have the same custom values as the previous Enumeration?
   def self.same_custom_values?(new, previous)
     previous.custom_field_values.each do |custom_value|
-      if custom_value.value != new["custom_field_values"][custom_value.custom_field_id.to_s]
+      if custom_value.to_s != new["custom_field_values"][custom_value.custom_field_id.to_s].to_s
         return false
       end
     end

#2 Updated by Go MAEDA about 1 month ago

Could you explain the conditions that cause this issue?

#3 Updated by Go MAEDA about 1 month ago

Go MAEDA wrote:

Could you explain the conditions that cause this issue?

I understand the condition.

The issue occurs when the value of a custom field of the activity is nil, and the new value for the custom field in the "new" hash is unset (the value will be a blank string). As a result, the conditional expression of the if statement will be false and a project-specific activity will be wrongly created.

#4 Updated by Go MAEDA about 1 month ago

  • Status changed from New to Confirmed
  • Target version set to 4.1.6

Setting the target version to 4.1.6.

#5 Updated by Yuichi HARADA about 1 month ago

I forgot to fix test/unit/time_entry_activity_test.rb. Reattached the patch.

#6 Updated by Go MAEDA about 1 month ago

  • Subject changed from Some system activities are created as project-specific activities when there are custom fields for activities to Saving time tracking activities without any change may turn a system activity to a project activity

#7 Updated by Go MAEDA about 1 month ago

  • Subject changed from Saving time tracking activities without any change may turn a system activity to a project activity to Saving time tracking activities without any change may turn a system activity into a project activity
  • Status changed from Confirmed to Closed
  • Assignee set to Go MAEDA
  • Target version changed from 4.1.6 to 5.0.0
  • Resolution set to Fixed

Committed the fix. Thank you.

Also available in: Atom PDF