diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index bc997297b..267f659e0 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -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 diff --git a/spec/system/site_customization/custom_pages_spec.rb b/spec/system/site_customization/custom_pages_spec.rb index 79ba0da43..9a9ad7738 100644 --- a/spec/system/site_customization/custom_pages_spec.rb +++ b/spec/system/site_customization/custom_pages_spec.rb @@ -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