Allow sorting widget_cards on custom pages

This commit is contained in:
taitus
2023-10-27 10:59:13 +02:00
parent f795c18bec
commit 4e9d5d8c5a
2 changed files with 6 additions and 3 deletions

View File

@@ -8,7 +8,7 @@ class PagesController < ApplicationController
@custom_page = SiteCustomization::Page.published.find_by(slug: params[:id])
if @custom_page.present?
@cards = @custom_page.cards
@cards = @custom_page.cards.sort_by_order
render action: :custom_page
else
render action: params[:id].split(".").first

View File

@@ -94,11 +94,14 @@ describe "Custom Pages" do
scenario "Show widget cards for that page" do
custom_page = create(:site_customization_page, :published)
create(:widget_card, cardable: custom_page, title: "Card Highlights")
create(:widget_card, cardable: custom_page, title: "Medium prominent card", order: 2)
create(:widget_card, cardable: custom_page, title: "Less prominent card", order: 2)
create(:widget_card, cardable: custom_page, title: "Card Highlights", order: 1)
visit custom_page.url
expect(page).to have_content "CARD HIGHLIGHTS"
expect("CARD HIGHLIGHTS").to appear_before("MEDIUM PROMINENT CARD")
expect("MEDIUM PROMINENT CARD").to appear_before("LESS PROMINENT CARD")
end
end
end