From 119f64ac44899b8dfc1a8dbad758e6c49452e370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 22 Jan 2023 17:15:13 +0100 Subject: [PATCH] Fix dates in custom pages admin index We weren't showing the year when a page was created/updated, and we were displaying the created date instead of the updated one. Co-Authored-By: Diego Calvo --- .../pages/index_component.html.erb | 4 ++-- .../pages/index_component_spec.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 spec/components/admin/site_customization/pages/index_component_spec.rb diff --git a/app/components/admin/site_customization/pages/index_component.html.erb b/app/components/admin/site_customization/pages/index_component.html.erb index 1eb35d59c..68db19b5f 100644 --- a/app/components/admin/site_customization/pages/index_component.html.erb +++ b/app/components/admin/site_customization/pages/index_component.html.erb @@ -21,8 +21,8 @@ <%= page.title %> <%= page.slug %> - <%= I18n.l page.created_at, format: :short %> - <%= I18n.l page.created_at, format: :short %> + <%= I18n.l page.created_at, format: :long %> + <%= I18n.l page.updated_at, format: :long %> <%= t("admin.site_customization.pages.page.status_#{page.status}") %> <%= render Admin::TableActionsComponent.new(page) do |actions| %> diff --git a/spec/components/admin/site_customization/pages/index_component_spec.rb b/spec/components/admin/site_customization/pages/index_component_spec.rb new file mode 100644 index 000000000..1792e52cb --- /dev/null +++ b/spec/components/admin/site_customization/pages/index_component_spec.rb @@ -0,0 +1,15 @@ +require "rails_helper" + +describe Admin::SiteCustomization::Pages::IndexComponent, controller: Admin::SiteCustomization::PagesController do + before { SiteCustomization::Page.delete_all } + + it "shows date in created_at and updated_at fields" do + custom_page = create(:site_customization_page, created_at: "2015-07-15 13:32:13") + custom_page.update!(updated_at: "2019-12-09 09:19:29") + + render_inline Admin::SiteCustomization::Pages::IndexComponent.new(SiteCustomization::Page.page(1)) + + expect(page).to have_content "July 15, 2015 13:32" + expect(page).to have_content "December 09, 2019 09:19" + end +end