Skip to content

Commit

Permalink
fixup! Update admin general timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Oct 19, 2023
1 parent ec7e691 commit 6a6d53a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/helpers/admin_general_timeline_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 20 additions & 7 deletions spec/controllers/admin_general_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 6a6d53a

Please sign in to comment.