Commit 4acb76d3 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'ld-fix-timeframefilter-return-logic' into 'master'

Fix TimeFrameFilter return logic

See merge request gitlab-org/gitlab!49082
parents 3f107950 3af34497
......@@ -2,7 +2,7 @@
module TimeFrameFilter
def by_timeframe(items)
return items unless params[:start_date] && params[:start_date]
return items unless params[:start_date] && params[:end_date]
start_date = params[:start_date].to_date
end_date = params[:end_date].to_date
......
......@@ -211,6 +211,20 @@ RSpec.describe EpicsFinder do
expect(epics(params)).to contain_exactly(epic3)
end
describe 'when one of the timeframe params are missing' do
it 'does not filter by timeframe if start_date is missing' do
only_end_date = epics(end_date: 1.year.ago.strftime('%Y-%m-%d'))
expect(only_end_date).to eq(epics)
end
it 'does not filter by timeframe if end_date is missing' do
only_start_date = epics(start_date: 1.year.from_now.strftime('%Y-%m-%d'))
expect(only_start_date).to eq(epics)
end
end
end
context 'by parent' do
......
......@@ -140,6 +140,20 @@ RSpec.describe IterationsFinder do
expect(subject).to match_array([iteration])
end
describe 'when one of the timeframe params are missing' do
it 'does not filter by timeframe if start_date is missing' do
only_end_date = described_class.new(user, params.merge(end_date: 1.year.ago)).execute
expect(only_end_date).to eq(subject)
end
it 'does not filter by timeframe if end_date is missing' do
only_start_date = described_class.new(user, params.merge(start_date: 1.year.from_now)).execute
expect(only_start_date).to eq(subject)
end
end
end
end
......
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