diff options
Diffstat (limited to 'spec/services/quick_actions/interpret_service_spec.rb')
-rw-r--r-- | spec/services/quick_actions/interpret_service_spec.rb | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 6926ac85de3..c35177f6ebc 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -207,7 +207,11 @@ describe QuickActions::InterpretService do it 'populates spend_time: 3600 if content contains /spend 1h' do _, updates = service.execute(content, issuable) - expect(updates).to eq(spend_time: { duration: 3600, user: developer }) + expect(updates).to eq(spend_time: { + duration: 3600, + user: developer, + spent_at: DateTime.now.to_date + }) end end @@ -215,7 +219,39 @@ describe QuickActions::InterpretService do it 'populates spend_time: -1800 if content contains /spend -30m' do _, updates = service.execute(content, issuable) - expect(updates).to eq(spend_time: { duration: -1800, user: developer }) + expect(updates).to eq(spend_time: { + duration: -1800, + user: developer, + spent_at: DateTime.now.to_date + }) + end + end + + shared_examples 'spend command with valid date' do + it 'populates spend time: 1800 with date in date type format' do + _, updates = service.execute(content, issuable) + + expect(updates).to eq(spend_time: { + duration: 1800, + user: developer, + spent_at: Date.parse(date) + }) + end + end + + shared_examples 'spend command with invalid date' do + it 'will not create any note and timelog' do + _, updates = service.execute(content, issuable) + + expect(updates).to eq({}) + end + end + + shared_examples 'spend command with future date' do + it 'will not create any note and timelog' do + _, updates = service.execute(content, issuable) + + expect(updates).to eq({}) end end @@ -669,6 +705,22 @@ describe QuickActions::InterpretService do let(:issuable) { issue } end + it_behaves_like 'spend command with valid date' do + let(:date) { '2016-02-02' } + let(:content) { "/spend 30m #{date}" } + let(:issuable) { issue } + end + + it_behaves_like 'spend command with invalid date' do + let(:content) { '/spend 30m 17-99-99' } + let(:issuable) { issue } + end + + it_behaves_like 'spend command with future date' do + let(:content) { '/spend 30m 6017-10-10' } + let(:issuable) { issue } + end + it_behaves_like 'empty command' do let(:content) { '/spend' } let(:issuable) { issue } |