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:
author🙈 jacopo beschi 🙉 <intrip@gmail.com>2019-09-04 23:13:39 +0300
committerMayra Cabrera <mcabrera@gitlab.com>2019-09-04 23:13:39 +0300
commit9c87275f6ef0b40d905929ce5bcd5480a6dfd369 (patch)
tree91c8f480de432496ff117dc86319ff98e067c28b /spec/services/quick_actions
parent1961fd1f06d8028a971fed4adea38180999d70e9 (diff)
Show meaningful message on /due quick action with invalid date
When using /due quick action with an invalid date a meaninful error message is shown.
Diffstat (limited to 'spec/services/quick_actions')
-rw-r--r--spec/services/quick_actions/interpret_service_spec.rb61
1 files changed, 33 insertions, 28 deletions
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb
index c9714964fc9..6ca0a3fa448 100644
--- a/spec/services/quick_actions/interpret_service_spec.rb
+++ b/spec/services/quick_actions/interpret_service_spec.rb
@@ -970,34 +970,6 @@ describe QuickActions::InterpretService do
let(:issuable) { merge_request }
end
- it_behaves_like 'due command' do
- let(:content) { '/due 2016-08-28' }
- let(:issuable) { issue }
- end
-
- it_behaves_like 'due command' do
- let(:content) { '/due tomorrow' }
- let(:issuable) { issue }
- let(:expected_date) { Date.tomorrow }
- end
-
- it_behaves_like 'due command' do
- let(:content) { '/due 5 days from now' }
- let(:issuable) { issue }
- let(:expected_date) { 5.days.from_now.to_date }
- end
-
- it_behaves_like 'due command' do
- let(:content) { '/due in 2 days' }
- let(:issuable) { issue }
- let(:expected_date) { 2.days.from_now.to_date }
- end
-
- it_behaves_like 'empty command' do
- let(:content) { '/due foo bar' }
- let(:issuable) { issue }
- end
-
it_behaves_like 'empty command' do
let(:content) { '/due 2016-08-28' }
let(:issuable) { merge_request }
@@ -1131,6 +1103,39 @@ describe QuickActions::InterpretService do
end
end
+ context '/due command' do
+ it 'returns invalid date format message when the due date is invalid' do
+ issue = build(:issue, project: project)
+
+ _, _, message = service.execute('/due invalid date', issue)
+
+ expect(message).to eq('Failed to set due date because the date format is invalid.')
+ end
+
+ it_behaves_like 'due command' do
+ let(:content) { '/due 2016-08-28' }
+ let(:issuable) { issue }
+ end
+
+ it_behaves_like 'due command' do
+ let(:content) { '/due tomorrow' }
+ let(:issuable) { issue }
+ let(:expected_date) { Date.tomorrow }
+ end
+
+ it_behaves_like 'due command' do
+ let(:content) { '/due 5 days from now' }
+ let(:issuable) { issue }
+ let(:expected_date) { 5.days.from_now.to_date }
+ end
+
+ it_behaves_like 'due command' do
+ let(:content) { '/due in 2 days' }
+ let(:issuable) { issue }
+ let(:expected_date) { 2.days.from_now.to_date }
+ end
+ end
+
context '/copy_metadata command' do
let(:todo_label) { create(:label, project: project, title: 'To Do') }
let(:inreview_label) { create(:label, project: project, title: 'In Review') }