diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-07 00:09:26 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-07 00:09:26 +0000 |
commit | 418a39f6c20ebaf9572c4ef3ae924b0c6ffc5e3b (patch) | |
tree | c4ae73eee4e0a2ba535e87893858d9e76778d09d /spec/services/quick_actions/interpret_service_spec.rb | |
parent | 2633d5ef5ed868eccb174c6ff644a3fb8224f990 (diff) | |
download | gitlab-ce-418a39f6c20ebaf9572c4ef3ae924b0c6ffc5e3b.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/quick_actions/interpret_service_spec.rb')
-rw-r--r-- | spec/services/quick_actions/interpret_service_spec.rb | 64 |
1 files changed, 52 insertions, 12 deletions
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 01b9a006ccb..9df238c6dac 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -368,24 +368,24 @@ RSpec.describe QuickActions::InterpretService do spent_at: DateTime.current.to_date }) end - - it 'returns the spend_time message including the formatted duration and verb' do - _, _, message = service.execute('/spend -120m', issuable) - - expect(message).to eq('Subtracted 2h spent time.') - end end shared_examples 'spend command with negative time' do - it 'populates spend_time: -1800 if content contains /spend -30m' do + it 'populates spend_time: -7200 if content contains -120m' do _, updates, _ = service.execute(content, issuable) expect(updates).to eq(spend_time: { - duration: -1800, + duration: -7200, user_id: developer.id, spent_at: DateTime.current.to_date }) end + + it 'returns the spend_time message including the formatted duration and verb' do + _, _, message = service.execute(content, issuable) + + expect(message).to eq('Subtracted 2h spent time.') + end end shared_examples 'spend command with valid date' do @@ -1242,8 +1242,18 @@ RSpec.describe QuickActions::InterpretService do let(:issuable) { issue } end + it_behaves_like 'spend command' do + let(:content) { '/spent 1h' } + let(:issuable) { issue } + end + it_behaves_like 'spend command with negative time' do - let(:content) { '/spend -30m' } + let(:content) { '/spend -120m' } + let(:issuable) { issue } + end + + it_behaves_like 'spend command with negative time' do + let(:content) { '/spent -120m' } let(:issuable) { issue } end @@ -1253,26 +1263,52 @@ RSpec.describe QuickActions::InterpretService do let(:issuable) { issue } end + it_behaves_like 'spend command with valid date' do + let(:date) { '2016-02-02' } + let(:content) { "/spent 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 invalid date' do + let(:content) { '/spent 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 'spend command with future date' do + let(:content) { '/spent 30m 6017-10-10' } + let(:issuable) { issue } + end + it_behaves_like 'failed command' do let(:content) { '/spend' } let(:issuable) { issue } end it_behaves_like 'failed command' do + let(:content) { '/spent' } + let(:issuable) { issue } + end + + it_behaves_like 'failed command' do let(:content) { '/spend abc' } let(:issuable) { issue } end + it_behaves_like 'failed command' do + let(:content) { '/spent abc' } + let(:issuable) { issue } + end + it_behaves_like 'remove_estimate command' do let(:content) { '/remove_estimate' } let(:issuable) { issue } @@ -2247,10 +2283,14 @@ RSpec.describe QuickActions::InterpretService do end describe 'spend command' do - let(:content) { '/spend -120m' } + it 'includes the formatted duration and proper verb when using /spend' do + _, explanations = service.explain('/spend -120m', issue) - it 'includes the formatted duration and proper verb' do - _, explanations = service.explain(content, issue) + expect(explanations).to eq(['Subtracts 2h spent time.']) + end + + it 'includes the formatted duration and proper verb when using /spent' do + _, explanations = service.explain('/spent -120m', issue) expect(explanations).to eq(['Subtracts 2h spent time.']) end |