Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-07 03:09:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-07 03:09:26 +0300
commit418a39f6c20ebaf9572c4ef3ae924b0c6ffc5e3b (patch)
treec4ae73eee4e0a2ba535e87893858d9e76778d09d /spec/services/quick_actions
parent2633d5ef5ed868eccb174c6ff644a3fb8224f990 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/quick_actions')
-rw-r--r--spec/services/quick_actions/interpret_service_spec.rb64
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