From d14a5ab099371774d832f8b9f82e65fb8bb30816 Mon Sep 17 00:00:00 2001 From: Finn Bacall Date: Fri, 4 Aug 2023 11:11:30 +0100 Subject: [PATCH] Hide map on index page if no API key. Fixes #879 Also tweak custom Config getters to be dynamic. --- app/models/event.rb | 4 +- app/views/events/index.html.erb | 4 +- config/application.rb | 31 ++++++++++---- test/config/test_secrets.yml | 2 +- test/controllers/events_controller_test.rb | 41 +++++++++++++++++++ test/fixtures/edit_suggestions.yml | 7 +++- .../cookie_consent_integration_test.rb | 14 +++---- test/models/event_test.rb | 14 +++++++ 8 files changed, 94 insertions(+), 23 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 2a54da1d4..1b5d0a419 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -229,9 +229,7 @@ def to_ical_event end def show_map? - Rails.application.secrets.google_maps_api_key.present? && # !self.online? && - ((latitude.present? && longitude.present?) || - (suggested_latitude.present? && suggested_longitude.present?)) + TeSS::Config.map_enabled && ((latitude.present? && longitude.present?) || (suggested_latitude.present? && suggested_longitude.present?)) end def all_day? diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index 11ac9831f..62f1b77dc 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -21,7 +21,7 @@ <% content_for :display_options do %>