diff --git a/app/finders/concerns/time_frame_filter.rb b/app/finders/concerns/time_frame_filter.rb index d1ebed730f6e665e7d9bfedc7197597b1ce0b1db..7412bea340e4d9cba41878b36166a86e7c46228b 100644 --- a/app/finders/concerns/time_frame_filter.rb +++ b/app/finders/concerns/time_frame_filter.rb @@ -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 diff --git a/ee/spec/finders/epics_finder_spec.rb b/ee/spec/finders/epics_finder_spec.rb index 33cf00f1f8c9c28f092e5dec3fb09677106337dc..7df9dc6f6fb7e0ecfee75c74acea680343d08e87 100644 --- a/ee/spec/finders/epics_finder_spec.rb +++ b/ee/spec/finders/epics_finder_spec.rb @@ -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 diff --git a/ee/spec/finders/iterations_finder_spec.rb b/ee/spec/finders/iterations_finder_spec.rb index e068f3187d53f99909de4e030bf2924e1a0147f2..6a4acd2a9342f65dee93069b6e62a86a2f4a53e5 100644 --- a/ee/spec/finders/iterations_finder_spec.rb +++ b/ee/spec/finders/iterations_finder_spec.rb @@ -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