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.
This commit is contained in:
Javi Martín
2021-07-27 20:05:23 +02:00
parent 6f219beff0
commit c3b3bd4502
2 changed files with 3 additions and 4 deletions

View File

@@ -58,7 +58,7 @@ describe "Documents", :admin do
click_button "Upload" click_button "Upload"
expect(page).to have_content "Document uploaded succesfully" 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 end
scenario "Errors on create" do scenario "Errors on create" do

View File

@@ -40,19 +40,18 @@ describe "Cards", :admin do
end end
scenario "Index" do scenario "Index" do
3.times { create(:widget_card) } cards = Array.new(3) { create(:widget_card) }
visit admin_homepage_path visit admin_homepage_path
expect(page).to have_css(".homepage-card", count: 3) expect(page).to have_css(".homepage-card", count: 3)
cards = Widget::Card.all
cards.each do |card| cards.each do |card|
expect(page).to have_content card.title expect(page).to have_content card.title
expect(page).to have_content card.description expect(page).to have_content card.description
expect(page).to have_content card.link_text expect(page).to have_content card.link_text
expect(page).to have_content card.link_url 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
end end