Simplify calls to have_current_path

In general, we shold check the contents of the page instead of the
current path, since the contents of the page are what users experience.

In one test, the only reason we check the current path additionally to
the contents of the page is to make sure we're still in the management
section.

Checking just that we avoid querying the database after starting the
browser.
This commit is contained in:
Javi Martín
2021-04-10 20:48:39 +02:00
parent a7664ad817
commit 2732c08f3d
3 changed files with 4 additions and 4 deletions

View File

@@ -317,7 +317,8 @@ describe "Debates" do
click_link "Edit"
expect(page).to have_current_path(edit_debate_path(Debate.last))
expect(page).to have_css "h1", exact_text: "Edit debate"
expect(page).to have_field "Debate title", with: "Testing auto link"
expect(page).not_to have_link("click me")
expect(page.html).not_to include "<script>alert('hey')</script>"
end

View File

@@ -26,14 +26,13 @@ describe "Proposals" do
expect(page).to have_content "Proposal created successfully."
expect(page).to have_current_path(/management/)
expect(page).to have_content "Help refugees"
expect(page).to have_content "In summary, what we want is..."
expect(page).to have_content "This is very important because..."
expect(page).to have_content "https://www.youtube.com/watch?v=yRYFKcMa_Ek"
expect(page).to have_content user.name
expect(page).to have_content I18n.l(Date.current)
expect(page).to have_current_path(management_proposal_path(Proposal.last))
end
scenario "Should not allow unverified users to create proposals" do

View File

@@ -560,7 +560,7 @@ describe "Proposals" do
click_link "Edit proposal"
expect(page).to have_current_path(edit_proposal_path(Proposal.last))
expect(page).to have_field "Proposal title", with: "Testing auto link"
expect(page).not_to have_link("click me")
expect(page.html).not_to include "<script>alert('hey')</script>"
end