summaryrefslogtreecommitdiff
path: root/spec/services/system_notes/time_tracking_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/system_notes/time_tracking_service_spec.rb')
-rw-r--r--spec/services/system_notes/time_tracking_service_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/services/system_notes/time_tracking_service_spec.rb b/spec/services/system_notes/time_tracking_service_spec.rb
index ec126cb5447..fdf18f4f29a 100644
--- a/spec/services/system_notes/time_tracking_service_spec.rb
+++ b/spec/services/system_notes/time_tracking_service_spec.rb
@@ -106,6 +106,30 @@ RSpec.describe ::SystemNotes::TimeTrackingService do
end
end
+ describe '#remove_timelog' do
+ subject { described_class.new(noteable: noteable, project: project, author: author).remove_timelog(timelog) }
+
+ context 'when the timelog has a positive time spent value' do
+ let_it_be(:noteable, reload: true) { create(:issue, project: project) }
+
+ let(:timelog) { create(:timelog, user: author, issue: noteable, time_spent: 1800, spent_at: '2022-03-30T00:00:00.000Z')}
+
+ it 'sets the note text' do
+ expect(subject.note).to eq "deleted 30m of spent time from 2022-03-30"
+ end
+ end
+
+ context 'when the timelog has a negative time spent value' do
+ let_it_be(:noteable, reload: true) { create(:issue, project: project) }
+
+ let(:timelog) { create(:timelog, user: author, issue: noteable, time_spent: -1800, spent_at: '2022-03-30T00:00:00.000Z')}
+
+ it 'sets the note text' do
+ expect(subject.note).to eq "deleted -30m of spent time from 2022-03-30"
+ end
+ end
+ end
+
describe '#change_time_spent' do
subject { described_class.new(noteable: noteable, project: project, author: author).change_time_spent }