From 67d13d289930a3372a6d5cc7aab8c35685060b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 6 Sep 2022 01:50:00 +0200 Subject: [PATCH] Show the time when a poll starts and ends This is consistent with the way we show the duration of a budget and its phases. Since budgets are the section with the most recent changes in the admin area, we're using it as a reference. Note that, unlike budgets (which are shown to finish at the beginning of their ending day), a poll has always been considered to finish at the end of their ending day, so we're showing it this way. We're also solving a minor usability issue. While it's pretty intuitive that a poll starting on a certain date will start at the beginning of the day, a poll ending on a certain date isn't clear about when it finishes exactly: is it at the beginning of the day, or at the end of the day? So now we're making this point clear. --- app/views/admin/poll/polls/_poll.html.erb | 4 ++-- app/views/admin/poll/polls/_poll_header.html.erb | 2 +- spec/system/admin/poll/polls_spec.rb | 6 +++--- spec/system/budget_polls/budgets_spec.rb | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/admin/poll/polls/_poll.html.erb b/app/views/admin/poll/polls/_poll.html.erb index a578bfe60..8f477c586 100644 --- a/app/views/admin/poll/polls/_poll.html.erb +++ b/app/views/admin/poll/polls/_poll.html.erb @@ -1,7 +1,7 @@ <%= poll.name %> - <%= l poll.starts_at.to_date %> - <%= l poll.ends_at.to_date %> + <%= l poll.starts_at.beginning_of_day, format: :short_datetime %> + <%= l poll.ends_at.end_of_day, format: :short_datetime %> <% if feature?(:sdg) %> <%= poll.sdg_goal_list %> <%= poll.sdg_target_list %> diff --git a/app/views/admin/poll/polls/_poll_header.html.erb b/app/views/admin/poll/polls/_poll_header.html.erb index 2b1ade5fb..ef24e0e0c 100644 --- a/app/views/admin/poll/polls/_poll_header.html.erb +++ b/app/views/admin/poll/polls/_poll_header.html.erb @@ -12,7 +12,7 @@
<%= t("admin.polls.index.dates") %>
- <%= l @poll.starts_at.to_date %> - <%= l @poll.ends_at.to_date %> + <%= render Admin::DateRangeComponent.new(@poll.starts_at.beginning_of_day, @poll.ends_at.end_of_day) %>
<% if @poll.geozone_restricted %> diff --git a/spec/system/admin/poll/polls_spec.rb b/spec/system/admin/poll/polls_spec.rb index ede4bd5f3..7bd857ecc 100644 --- a/spec/system/admin/poll/polls_spec.rb +++ b/spec/system/admin/poll/polls_spec.rb @@ -67,8 +67,8 @@ describe "Admin polls", :admin do expect(page).to have_content "Poll created successfully" expect(page).to have_content "Upcoming poll" - expect(page).to have_content I18n.l(start_date) - expect(page).to have_content I18n.l(end_date) + expect(page).to have_content "#{I18n.l(start_date)} 00:00" + expect(page).to have_content "#{I18n.l(end_date)} 23:59" visit poll_path(id: "upcoming-poll") @@ -93,7 +93,7 @@ describe "Admin polls", :admin do expect(page).to have_content "Poll updated successfully" expect(page).to have_content "Next Poll" - expect(page).to have_content I18n.l(end_date.to_date) + expect(page).to have_content "#{I18n.l(end_date)} 23:59" end scenario "Edit from index" do diff --git a/spec/system/budget_polls/budgets_spec.rb b/spec/system/budget_polls/budgets_spec.rb index bb5152f76..6a4f1c56b 100644 --- a/spec/system/budget_polls/budgets_spec.rb +++ b/spec/system/budget_polls/budgets_spec.rb @@ -12,8 +12,8 @@ describe "Admin Budgets", :admin do expect(page).to have_current_path(/admin\/polls\/\d+/) expect(page).to have_content(budget.name) - expect(page).to have_content(balloting_phase.starts_at.to_date) - expect(page).to have_content(balloting_phase.ends_at.to_date) + expect(page).to have_content("#{balloting_phase.starts_at.to_date} 00:00") + expect(page).to have_content("#{balloting_phase.ends_at.to_date} 23:59") end scenario "Create poll in current locale if the budget does not have a poll associated" do