From 3aaf5ce151a7d673a347d5beb49073167947915e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Mon, 11 Jan 2021 17:43:46 +0100 Subject: [PATCH] Add back link to cards form As we normally do in other places. --- .../admin/site_customization/cards_controller.rb | 1 + app/controllers/admin/widget/cards_controller.rb | 1 + app/views/admin/widget/cards/edit.html.erb | 2 ++ app/views/admin/widget/cards/new.html.erb | 2 ++ spec/system/admin/widgets/cards_spec.rb | 10 ++++++++++ 5 files changed, 16 insertions(+) diff --git a/app/controllers/admin/site_customization/cards_controller.rb b/app/controllers/admin/site_customization/cards_controller.rb index 86c229ffc..0e2e2f190 100644 --- a/app/controllers/admin/site_customization/cards_controller.rb +++ b/app/controllers/admin/site_customization/cards_controller.rb @@ -2,6 +2,7 @@ class Admin::SiteCustomization::CardsController < Admin::SiteCustomization::Base include Admin::Widget::CardsActions load_and_authorize_resource :page, class: "::SiteCustomization::Page" load_and_authorize_resource :card, through: :page, class: "Widget::Card" + helper_method :index_path def index end diff --git a/app/controllers/admin/widget/cards_controller.rb b/app/controllers/admin/widget/cards_controller.rb index 5d676e66a..64ea72bb5 100644 --- a/app/controllers/admin/widget/cards_controller.rb +++ b/app/controllers/admin/widget/cards_controller.rb @@ -1,6 +1,7 @@ class Admin::Widget::CardsController < Admin::BaseController include Admin::Widget::CardsActions load_and_authorize_resource :card, class: "Widget::Card" + helper_method :index_path private diff --git a/app/views/admin/widget/cards/edit.html.erb b/app/views/admin/widget/cards/edit.html.erb index d7ab58339..f4f751fd1 100644 --- a/app/views/admin/widget/cards/edit.html.erb +++ b/app/views/admin/widget/cards/edit.html.erb @@ -1,3 +1,5 @@ +<%= back_link_to index_path %> +

<% if @card.header? %> <%= t("admin.homepage.edit.header_title") %> diff --git a/app/views/admin/widget/cards/new.html.erb b/app/views/admin/widget/cards/new.html.erb index d12f8ab7c..f15f0172e 100644 --- a/app/views/admin/widget/cards/new.html.erb +++ b/app/views/admin/widget/cards/new.html.erb @@ -1,3 +1,5 @@ +<%= back_link_to index_path %> +

<% if @card.header? %> <%= t("admin.homepage.new.header_title") %> diff --git a/spec/system/admin/widgets/cards_spec.rb b/spec/system/admin/widgets/cards_spec.rb index 039f7637d..444968b7d 100644 --- a/spec/system/admin/widgets/cards_spec.rb +++ b/spec/system/admin/widgets/cards_spec.rb @@ -5,6 +5,8 @@ describe "Cards", :admin do visit admin_homepage_path click_link "Create card" + expect(page).to have_link("Go back", href: admin_homepage_path) + fill_in "Label (optional)", with: "Card label" fill_in "Title", with: "Card text" fill_in "Description", with: "Card description" @@ -74,6 +76,8 @@ describe "Cards", :admin do click_link "Edit" end + expect(page).to have_link("Go back", href: admin_homepage_path) + within(".translatable-fields") do fill_in "Label (optional)", with: "Card label updated" fill_in "Title", with: "Card text updated" @@ -160,6 +164,9 @@ describe "Cards", :admin do click_link "Create card" + expect(page).to have_link("Go back", + href: admin_site_customization_page_widget_cards_path(custom_page)) + fill_in "Title", with: "Card for a custom page" click_button "Create card" @@ -205,6 +212,9 @@ describe "Cards", :admin do click_link "Edit" + expect(page).to have_link("Go back", + href: admin_site_customization_page_widget_cards_path(custom_page)) + within(".translatable-fields") do fill_in "Title", with: "Updated title" end