Allow sorting widget_cards on homepage

Note that we keep :created_at order as complement to new :order field.

We do this so that current installations will not notice any change in the
sorting of their cards when upgrading, as the default "order" field will always
be 1, so it will continue to sort by the "created_at".
This commit is contained in:
taitus
2023-10-27 10:56:20 +02:00
parent 6059aab674
commit 7c85daac3f
3 changed files with 27 additions and 1 deletions

View File

@@ -143,6 +143,21 @@ describe "Home" do
expect(page).not_to have_css(".title", text: "Featured")
end
scenario "cards are first sorted by 'order' field, then by 'created_at' when order is equal" do
create(:widget_card, title: "Card one", order: 1)
create(:widget_card, title: "Card two", order: 3)
create(:widget_card, title: "Card three", order: 2)
create(:widget_card, title: "Card four", order: 3)
visit root_path
within(".cards-container") do
expect("CARD ONE").to appear_before("CARD THREE")
expect("CARD THREE").to appear_before("CARD TWO")
expect("CARD TWO").to appear_before("CARD FOUR")
end
end
describe "Header Card" do
scenario "if there is header card with link, the link content is rendered" do
create(:widget_card, :header, link_text: "Link text", link_url: "consul.dev")