Commit 9de44187 authored by Markus Koller's avatar Markus Koller

Merge branch 'fix-issues-list-with-invalid-due-date' into 'master'

Fix issues list when due date parameter is invalid

See merge request gitlab-org/gitlab!47524
parents 696340d8 dff3480d
...@@ -97,6 +97,8 @@ class IssuesFinder < IssuableFinder ...@@ -97,6 +97,8 @@ class IssuesFinder < IssuableFinder
items.due_between(Date.today.beginning_of_month, Date.today.end_of_month) items.due_between(Date.today.beginning_of_month, Date.today.end_of_month)
elsif params.filter_by_due_next_month_and_previous_two_weeks? elsif params.filter_by_due_next_month_and_previous_two_weeks?
items.due_between(Date.today - 2.weeks, (Date.today + 1.month).end_of_month) items.due_between(Date.today - 2.weeks, (Date.today + 1.month).end_of_month)
else
items.none
end end
end end
......
---
title: Fix issues list when due date parameter is invalid
merge_request: 47524
author:
type: fixed
...@@ -831,6 +831,46 @@ RSpec.describe IssuesFinder do ...@@ -831,6 +831,46 @@ RSpec.describe IssuesFinder do
let(:project_params) { { project_id: project.id } } let(:project_params) { { project_id: project.id } }
end end
end end
context 'filtering by due date' do
let_it_be(:issue_overdue) { create(:issue, project: project1, due_date: 2.days.ago) }
let_it_be(:issue_due_soon) { create(:issue, project: project1, due_date: 2.days.from_now) }
let(:scope) { 'all' }
let(:base_params) { { project_id: project1.id } }
context 'with param set to no due date' do
let(:params) { base_params.merge(due_date: Issue::NoDueDate.name) }
it 'returns issues with no due date' do
expect(issues).to contain_exactly(issue1)
end
end
context 'with param set to overdue' do
let(:params) { base_params.merge(due_date: Issue::Overdue.name) }
it 'returns overdue issues' do
expect(issues).to contain_exactly(issue_overdue)
end
end
context 'with param set to next month and previous two weeks' do
let(:params) { base_params.merge(due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name) }
it 'returns issues from the previous two weeks and next month' do
expect(issues).to contain_exactly(issue_overdue, issue_due_soon)
end
end
context 'with invalid param' do
let(:params) { base_params.merge(due_date: 'foo') }
it 'returns no issues' do
expect(issues).to be_empty
end
end
end
end end
describe '#row_count', :request_store do describe '#row_count', :request_store do
......
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