Commit 1f0aacb8 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch...

Merge branch '64009-show-a-meaningful-error-message-when-due-quick_actions-command-fails-because-the-date-format-is-invalid' into 'master'

Resolve "Show a meaningful error message when /due quick_actions command fails because the date format is invalid"

See merge request gitlab-org/gitlab-ce!32349
parents 1961fd1f 9c87275f
---
title: Show meaningful message on /due quick action with invalid date
merge_request: 32349
author: Jacopo Beschi @jacopo-beschi
type: changed
...@@ -25,7 +25,11 @@ module Gitlab ...@@ -25,7 +25,11 @@ module Gitlab
Chronic.parse(due_date_param).try(:to_date) Chronic.parse(due_date_param).try(:to_date)
end end
command :due do |due_date| command :due do |due_date|
@updates[:due_date] = due_date if due_date if due_date
@updates[:due_date] = due_date
else
@execution_message[:due] = _('Failed to set due date because the date format is invalid.')
end
end end
desc _('Remove due date') desc _('Remove due date')
......
...@@ -4984,6 +4984,9 @@ msgstr "" ...@@ -4984,6 +4984,9 @@ msgstr ""
msgid "Failed to save preferences." msgid "Failed to save preferences."
msgstr "" msgstr ""
msgid "Failed to set due date because the date format is invalid."
msgstr ""
msgid "Failed to update branch!" msgid "Failed to update branch!"
msgstr "" msgstr ""
......
...@@ -970,34 +970,6 @@ describe QuickActions::InterpretService do ...@@ -970,34 +970,6 @@ describe QuickActions::InterpretService do
let(:issuable) { merge_request } let(:issuable) { merge_request }
end 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 it_behaves_like 'empty command' do
let(:content) { '/due 2016-08-28' } let(:content) { '/due 2016-08-28' }
let(:issuable) { merge_request } let(:issuable) { merge_request }
...@@ -1131,6 +1103,39 @@ describe QuickActions::InterpretService do ...@@ -1131,6 +1103,39 @@ describe QuickActions::InterpretService do
end end
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 context '/copy_metadata command' do
let(:todo_label) { create(:label, project: project, title: 'To Do') } let(:todo_label) { create(:label, project: project, title: 'To Do') }
let(:inreview_label) { create(:label, project: project, title: 'In Review') } let(:inreview_label) { create(:label, project: project, title: 'In Review') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment