summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2022-06-20 17:40:39 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2022-06-20 17:40:39 +0000
commit3f97ec875c6a1d9475dadede6a32044a852d45f1 (patch)
tree2a99e2e02334b1b9e63b1b89d913df9c9ec4e333 /test/unit
parent69a8fe2f6d422c9653a7cc16076c3140040fe349 (diff)
downloadredmine-3f97ec875c6a1d9475dadede6a32044a852d45f1.tar.gz
redmine-3f97ec875c6a1d9475dadede6a32044a852d45f1.zip
Merged r21668 and r21669 to 5.0-stable (#33914).
git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@21670 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/time_entry_activity_test.rb12
-rw-r--r--test/unit/time_entry_test.rb13
2 files changed, 25 insertions, 0 deletions
diff --git a/test/unit/time_entry_activity_test.rb b/test/unit/time_entry_activity_test.rb
index f4437c327..dc2e44c13 100644
--- a/test/unit/time_entry_activity_test.rb
+++ b/test/unit/time_entry_activity_test.rb
@@ -219,4 +219,16 @@ class TimeEntryActivityTest < ActiveSupport::TestCase
)
end
end
+
+ def test_default_should_return_default_activity_if_default_activity_is_included_in_the_project_activities
+ project = Project.find(1)
+ assert_equal TimeEntryActivity.default(project).id, 10
+ end
+
+ def test_default_should_return_project_specific_default_activity_if_default_activity_is_not_included_in_the_project_activities
+ project = Project.find(1)
+ project_specific_default_activity = TimeEntryActivity.create!(name: 'Development', parent_id: 10, project_id: project.id, is_default: false)
+ assert_not_equal TimeEntryActivity.default(project).id, 10
+ assert_equal TimeEntryActivity.default(project).id, project_specific_default_activity.id
+ end
end
diff --git a/test/unit/time_entry_test.rb b/test/unit/time_entry_test.rb
index 0998d98b9..7f9e18173 100644
--- a/test/unit/time_entry_test.rb
+++ b/test/unit/time_entry_test.rb
@@ -126,6 +126,19 @@ class TimeEntryTest < ActiveSupport::TestCase
end
end
+ def test_activity_id_should_default_activity_id
+ project = Project.find(1)
+ default_activity = TimeEntryActivity.find(10)
+ entry = TimeEntry.new(project: project)
+ assert_equal entry.activity_id, default_activity.id
+
+ # If there are project specific activities
+ project_specific_default_activity = TimeEntryActivity.create!(name: 'Development', parent_id: 10, project_id: project.id, is_default: false)
+ entry = TimeEntry.new(project: project)
+ assert_not_equal entry.activity_id, default_activity.id
+ assert_equal entry.activity_id, project_specific_default_activity.id
+ end
+
def test_should_accept_future_dates
entry = TimeEntry.generate
entry.spent_on = User.current.today + 1