From 772be11525cb58b6dad8a3c9c335fbf185b48fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 24 Apr 2024 16:49:05 +0200 Subject: [PATCH] Fix budget investments chart in admin stats The JavaScript required to display the chart wasn't loaded on the admin stats page. We're not adding a test because we're going to move the budgets graph to a different page on the pull request containing this commit. Note we're changing the "Go back" link, since using a turbolinks refresh broke this link when using the Chromium browser. Besides, there was an inconsistency where some of the "Go back" links in admin stats pointed to the admin stats page but other links pointed to `:back`. --- app/components/admin/stats/sdg_component.html.erb | 2 +- app/views/admin/stats/direct_messages.html.erb | 2 +- app/views/admin/stats/polls.html.erb | 2 +- app/views/admin/stats/proposal_notifications.html.erb | 2 +- app/views/admin/stats/show.html.erb | 4 ++++ spec/components/admin/stats/sdg_component_spec.rb | 11 +++++++++++ spec/system/admin/stats_spec.rb | 6 ++++++ 7 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 spec/components/admin/stats/sdg_component_spec.rb diff --git a/app/components/admin/stats/sdg_component.html.erb b/app/components/admin/stats/sdg_component.html.erb index 754380b4b..c8900eb52 100644 --- a/app/components/admin/stats/sdg_component.html.erb +++ b/app/components/admin/stats/sdg_component.html.erb @@ -1,4 +1,4 @@ -<%= back_link_to %> +<%= back_link_to admin_stats_path %> <%= header %> diff --git a/app/views/admin/stats/direct_messages.html.erb b/app/views/admin/stats/direct_messages.html.erb index df5621a13..ff9ccbc8c 100644 --- a/app/views/admin/stats/direct_messages.html.erb +++ b/app/views/admin/stats/direct_messages.html.erb @@ -1,4 +1,4 @@ -<%= back_link_to %> +<%= back_link_to admin_stats_path %>

<%= t("admin.stats.direct_messages.title") %>

diff --git a/app/views/admin/stats/polls.html.erb b/app/views/admin/stats/polls.html.erb index 178d06bcb..7c30c0093 100644 --- a/app/views/admin/stats/polls.html.erb +++ b/app/views/admin/stats/polls.html.erb @@ -1,4 +1,4 @@ -<%= back_link_to %> +<%= back_link_to admin_stats_path %>

<%= t("admin.stats.polls.title") %>

diff --git a/app/views/admin/stats/proposal_notifications.html.erb b/app/views/admin/stats/proposal_notifications.html.erb index 4a5501177..4c66ca46e 100644 --- a/app/views/admin/stats/proposal_notifications.html.erb +++ b/app/views/admin/stats/proposal_notifications.html.erb @@ -1,4 +1,4 @@ -<%= back_link_to %> +<%= back_link_to admin_stats_path %>

<%= t("admin.stats.proposal_notifications.title") %>

diff --git a/app/views/admin/stats/show.html.erb b/app/views/admin/stats/show.html.erb index 286ded1f0..c0c6d0706 100644 --- a/app/views/admin/stats/show.html.erb +++ b/app/views/admin/stats/show.html.erb @@ -1,3 +1,7 @@ +<% content_for :head do %> + <%= javascript_include_tag "stat_graphs", "data-turbolinks-track" => "reload" %> +<% end %> +
diff --git a/spec/components/admin/stats/sdg_component_spec.rb b/spec/components/admin/stats/sdg_component_spec.rb new file mode 100644 index 000000000..2f222b44f --- /dev/null +++ b/spec/components/admin/stats/sdg_component_spec.rb @@ -0,0 +1,11 @@ +require "rails_helper" + +describe Admin::Stats::SDGComponent do + include Rails.application.routes.url_helpers + + it "renders a links to go back to the admin stats index" do + render_inline Admin::Stats::SDGComponent.new(SDG::Goal.all) + + expect(page).to have_link "Go back", href: admin_stats_path + end +end diff --git a/spec/system/admin/stats_spec.rb b/spec/system/admin/stats_spec.rb index fe6103b75..9ac12611c 100644 --- a/spec/system/admin/stats_spec.rb +++ b/spec/system/admin/stats_spec.rb @@ -183,6 +183,8 @@ describe "Stats", :admin do visit admin_stats_path click_link "Proposal notifications" + expect(page).to have_link "Go back", href: admin_stats_path + within("#proposal_notifications_count") do expect(page).to have_content "3" end @@ -232,6 +234,8 @@ describe "Stats", :admin do visit admin_stats_path click_link "Direct messages" + expect(page).to have_link "Go back", href: admin_stats_path + within("#direct_messages_count") do expect(page).to have_content "3" end @@ -253,6 +257,8 @@ describe "Stats", :admin do click_link "Polls" end + expect(page).to have_link "Go back", href: admin_stats_path + within("#web_participants") do expect(page).to have_content "3" end