Use polymorphic routes to manage cards

We use a different logic to load the card depending on the controller
we're using, and then share the rest of the code. This way we simplify
the code a bit, since we don't have to check for the page_id parameter.
This commit is contained in:
Javi Martín
2021-01-06 20:09:36 +01:00
parent 04e817e696
commit 4c0bb894eb
12 changed files with 99 additions and 79 deletions

View File

@@ -164,6 +164,19 @@ describe "Polymorphic routes" do
expect(admin_polymorphic_path(shift)).to eq(admin_booth_shift_path(booth, shift))
end
it "routes widget cards" do
card = create(:widget_card)
expect(admin_polymorphic_path(card)).to eq(admin_widget_card_path(card))
end
it "routes site customization page widget cards" do
page = create(:site_customization_page)
card = create(:widget_card, page: page)
expect(admin_polymorphic_path(card)).to eq admin_site_customization_page_widget_card_path(page, card)
end
it "supports routes for actions like edit" do
proposal = create(:proposal)
milestone = create(:milestone, milestoneable: proposal)