From c3b3bd4502375740dd32c918f0eaa0dcb3cdecd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 27 Jul 2021 20:05:23 +0200 Subject: [PATCH] Test attachments from the user's point of view These tests were checking the URLs of documents and images pointed to the URL generated by the `attachment.url` method. In order to do so, we were running database queries after starting the process running the browser, which is sometimes causing database inconsistencies when running the tests. So I'm simply removing the URL check. The tests are slightly less useful now, but it isn't like they were 100% right in the first place. After all, if the `attachment.url` method wasn't working properly, the tests were still passing. --- spec/system/admin/site_customization/documents_spec.rb | 2 +- spec/system/admin/widgets/cards_spec.rb | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/system/admin/site_customization/documents_spec.rb b/spec/system/admin/site_customization/documents_spec.rb index ce7c236b8..92d2e543a 100644 --- a/spec/system/admin/site_customization/documents_spec.rb +++ b/spec/system/admin/site_customization/documents_spec.rb @@ -58,7 +58,7 @@ describe "Documents", :admin do click_button "Upload" expect(page).to have_content "Document uploaded succesfully" - expect(page).to have_link "logo.pdf", href: Document.last.attachment.url + expect(page).to have_link "logo.pdf" end scenario "Errors on create" do diff --git a/spec/system/admin/widgets/cards_spec.rb b/spec/system/admin/widgets/cards_spec.rb index 51e37f965..fae155352 100644 --- a/spec/system/admin/widgets/cards_spec.rb +++ b/spec/system/admin/widgets/cards_spec.rb @@ -40,19 +40,18 @@ describe "Cards", :admin do end scenario "Index" do - 3.times { create(:widget_card) } + cards = Array.new(3) { create(:widget_card) } visit admin_homepage_path expect(page).to have_css(".homepage-card", count: 3) - cards = Widget::Card.all cards.each do |card| expect(page).to have_content card.title expect(page).to have_content card.description expect(page).to have_content card.link_text expect(page).to have_content card.link_url - expect(page).to have_link("Show image", href: card.image_url(:large)) + expect(page).to have_link "Show image" end end