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

@@ -163,7 +163,7 @@ describe "Cards", :admin do
fill_in "Title", with: "Card for a custom page"
click_button "Create card"
expect(page).to have_current_path admin_site_customization_page_cards_path(custom_page)
expect(page).to have_current_path admin_site_customization_page_widget_cards_path(custom_page)
expect(page).to have_content "Card for a custom page"
end
@@ -199,7 +199,7 @@ describe "Cards", :admin do
scenario "Edit", :js do
create(:widget_card, page: custom_page, title: "Original title")
visit admin_site_customization_page_cards_path(custom_page)
visit admin_site_customization_page_widget_cards_path(custom_page)
expect(page).to have_content("Original title")
@@ -211,7 +211,7 @@ describe "Cards", :admin do
click_button "Save card"
expect(page).to have_current_path admin_site_customization_page_cards_path(custom_page)
expect(page).to have_current_path admin_site_customization_page_widget_cards_path(custom_page)
expect(page).to have_content "Updated title"
expect(page).not_to have_content "Original title"
end
@@ -219,7 +219,7 @@ describe "Cards", :admin do
scenario "Destroy", :js do
create(:widget_card, page: custom_page, title: "Card title")
visit admin_site_customization_page_cards_path(custom_page)
visit admin_site_customization_page_widget_cards_path(custom_page)
expect(page).to have_content("Card title")
@@ -227,7 +227,7 @@ describe "Cards", :admin do
click_link "Delete"
end
expect(page).to have_current_path admin_site_customization_page_cards_path(custom_page)
expect(page).to have_current_path admin_site_customization_page_widget_cards_path(custom_page)
expect(page).not_to have_content "Card title"
end
end