summaryrefslogtreecommitdiffstats
path: root/test/unit/time_entry_activity_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/time_entry_activity_test.rb')
-rw-r--r--test/unit/time_entry_activity_test.rb29
1 files changed, 26 insertions, 3 deletions
diff --git a/test/unit/time_entry_activity_test.rb b/test/unit/time_entry_activity_test.rb
index 67e925850..7953a7cee 100644
--- a/test/unit/time_entry_activity_test.rb
+++ b/test/unit/time_entry_activity_test.rb
@@ -144,7 +144,7 @@ class TimeEntryActivityTest < ActiveSupport::TestCase
parent_activity.id.to_s => {
'parent_id' => parent_activity.id.to_s,
'active' => '0',
- 'custom_field_values' => {'7' => ''}
+ 'custom_field_values' => {'7' => '1'}
}
}
)
@@ -158,7 +158,7 @@ class TimeEntryActivityTest < ActiveSupport::TestCase
other_parent_activity.id.to_s => {
'parent_id' => other_parent_activity.id.to_s,
'active' => '0',
- 'custom_field_values' => {'7' => ''}
+ 'custom_field_values' => {'7' => '1'}
}
}
)
@@ -179,7 +179,7 @@ class TimeEntryActivityTest < ActiveSupport::TestCase
parent_activity.id.to_s => {
'parent_id' => parent_activity.id.to_s,
'active' => '0',
- 'custom_field_values' => {'7' => ''}
+ 'custom_field_values' => {'7' => '1'}
}
}
)
@@ -196,4 +196,27 @@ class TimeEntryActivityTest < ActiveSupport::TestCase
assert_equal 'Design2', project_activity.reload.name
assert_equal 'Design3', parent_activity.reload.name
end
+
+ def test_project_activity_should_not_be_created_if_no_custom_value_is_changed
+ system_activity = TimeEntryActivity.find(9) # Design
+ assert_equal true, system_activity.active
+
+ custom_field_value = system_activity.custom_field_values.detect{|cfv| cfv.custom_field.id == 7}
+ assert_nil custom_field_value.value
+
+ project = Project.find(1)
+ assert_equal 0, project.time_entry_activities.count
+
+ assert_no_difference 'TimeEntryActivity.count' do
+ project.update_or_create_time_entry_activities(
+ {
+ '9' => {
+ 'parent_id' => '9',
+ 'active' => '1',
+ 'custom_field_values' => {'7' => ''}
+ }
+ }
+ )
+ end
+ end
end