From d4c62e2fc6e0e07c365dd71a56062d0e670553e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 2 Jun 2022 18:55:16 +0200 Subject: [PATCH] Add notice after destroying a banner We were missing a notice in this case. Not only this caused inconsistencies in the user experience, but it also made it hard to add an expectation in the test checking the request had finished before making a new one. Simultaneous requests sometimes cause failures in our test suite. --- app/controllers/admin/banners_controller.rb | 2 +- config/locales/en/admin.yml | 2 ++ config/locales/es/admin.yml | 2 ++ spec/system/admin/banners_spec.rb | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/banners_controller.rb b/app/controllers/admin/banners_controller.rb index 6d154c8d6..c795b4b33 100644 --- a/app/controllers/admin/banners_controller.rb +++ b/app/controllers/admin/banners_controller.rb @@ -32,7 +32,7 @@ class Admin::BannersController < Admin::BaseController def destroy @banner.destroy! - redirect_to admin_banners_path + redirect_to admin_banners_path, notice: t("admin.banners.destroy.notice") end private diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 4ef0cdb33..c6bedf583 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -38,6 +38,8 @@ en: sdg: SDG create: notice: "Banner created successfully" + destroy: + notice: "Banner deleted successfully" edit: editing: Edit banner form: diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index d33daa508..42d446409 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -38,6 +38,8 @@ es: sdg: ODS create: notice: "Banner creado correctamente" + destroy: + notice: "Banner eliminado correctamente" edit: editing: Editar el banner form: diff --git a/spec/system/admin/banners_spec.rb b/spec/system/admin/banners_spec.rb index 67d111acb..e3baf6f86 100644 --- a/spec/system/admin/banners_spec.rb +++ b/spec/system/admin/banners_spec.rb @@ -177,6 +177,8 @@ describe "Admin banners magement", :admin do click_button "Delete" end + expect(page).to have_content "Banner deleted successfully" + visit admin_root_path expect(page).not_to have_content "Ugly banner" end