From 6a6d53ae782ded18650a60a28d38b1ee725f33af Mon Sep 17 00:00:00 2001 From: Graeme Porteous Date: Thu, 19 Oct 2023 17:18:15 +0100 Subject: [PATCH] fixup! Update admin general timeline --- app/helpers/admin_general_timeline_helper.rb | 2 +- .../admin_general_controller_spec.rb | 27 ++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/helpers/admin_general_timeline_helper.rb b/app/helpers/admin_general_timeline_helper.rb index 07758afd7f6..c6fa3d70efe 100644 --- a/app/helpers/admin_general_timeline_helper.rb +++ b/app/helpers/admin_general_timeline_helper.rb @@ -19,7 +19,7 @@ def time_filters end def current_time_filter - time_filters.compact.min_by { |_, time| (time - start_date).abs }&.first + time_filters.min_by { |_, time| (time - start_date).abs }.first end def event_types diff --git a/spec/controllers/admin_general_controller_spec.rb b/spec/controllers/admin_general_controller_spec.rb index 25b49d665c2..4558fd5434d 100644 --- a/spec/controllers/admin_general_controller_spec.rb +++ b/spec/controllers/admin_general_controller_spec.rb @@ -339,16 +339,25 @@ end it 'sets the title appropriately' do - expect(assigns[:events_title]).to eq("All events, all time") + expect(assigns[:events_title]).to eq("All events in the last 2 days") + end + + context 'when start_date is set' do + + before do + get :timeline, params: { all: 1, start_date: Time.utc(1970, 1, 1) } + end + + it 'sets the title appropriately' do + expect(assigns[:events_title]).to eq("All events, all time") + end + end context 'when event_type is info_request_event' do before do - get :timeline, params: { - all: 1, - event_type: 'info_request_event' - } + get :timeline, params: { all: 1, event_type: 'info_request_event' } end it 'assigns an array of info request events in order of descending @@ -358,7 +367,9 @@ end it 'sets the title appropriately' do - expect(assigns[:events_title]).to eq("Request events, all time") + expect(assigns[:events_title]).to eq( + "Request events in the last 2 days" + ) end end @@ -375,7 +386,9 @@ end it 'sets the title appropriately' do - expect(assigns[:events_title]).to eq("Authority changes, all time") + expect(assigns[:events_title]).to eq( + "Authority changes in the last 2 days" + ) end end