Allow sorting widget_cards on custom pages
This commit is contained in:
@@ -8,7 +8,7 @@ class PagesController < ApplicationController
|
|||||||
@custom_page = SiteCustomization::Page.published.find_by(slug: params[:id])
|
@custom_page = SiteCustomization::Page.published.find_by(slug: params[:id])
|
||||||
|
|
||||||
if @custom_page.present?
|
if @custom_page.present?
|
||||||
@cards = @custom_page.cards
|
@cards = @custom_page.cards.sort_by_order
|
||||||
render action: :custom_page
|
render action: :custom_page
|
||||||
else
|
else
|
||||||
render action: params[:id].split(".").first
|
render action: params[:id].split(".").first
|
||||||
|
|||||||
@@ -94,11 +94,14 @@ describe "Custom Pages" do
|
|||||||
|
|
||||||
scenario "Show widget cards for that page" do
|
scenario "Show widget cards for that page" do
|
||||||
custom_page = create(:site_customization_page, :published)
|
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
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user