Add back link to cards form

As we normally do in other places.
This commit is contained in:
Senén Rodero Rodríguez
2021-01-11 17:43:46 +01:00
committed by Javi Martín
parent 1f6ca4980f
commit 3aaf5ce151
5 changed files with 16 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -1,3 +1,5 @@
<%= back_link_to index_path %>
<h2>
<% if @card.header? %>
<%= t("admin.homepage.edit.header_title") %>

View File

@@ -1,3 +1,5 @@
<%= back_link_to index_path %>
<h2>
<% if @card.header? %>
<%= t("admin.homepage.new.header_title") %>

View File

@@ -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