Remove redundant database checks in system tests

These tests check what happens from the user's point of view. For
instance, we check that after disabling recommendations, they are not
shown. What happens in the database is not related to the user
experience.

Furthermore, checking the database after the browser has started is
proving to be a major source for inconsistent data in specs.
This commit is contained in:
Javi Martín
2021-04-10 14:27:31 +02:00
parent 747da42972
commit 907c0fc679
11 changed files with 3 additions and 30 deletions

View File

@@ -78,7 +78,6 @@ describe "Admin geozones", :admin do
expect(page).to have_content "Geozone successfully deleted" expect(page).to have_content "Geozone successfully deleted"
expect(page).not_to have_content("Delete me!") expect(page).not_to have_content("Delete me!")
expect(Geozone.where(id: geozone.id)).to be_empty
end end
scenario "Delete geozone with associated element" do scenario "Delete geozone with associated element" do

View File

@@ -40,8 +40,6 @@ describe "Admin hidden budget investments", :admin do
click_link("Confirmed") click_link("Confirmed")
expect(page).to have_content(investment.title) expect(page).to have_content(investment.title)
expect(investment.reload).to be_confirmed_hide
end end
scenario "Current filter is properly highlighted" do scenario "Current filter is properly highlighted" do

View File

@@ -84,8 +84,6 @@ describe "Admin hidden comments", :admin do
expect(page).not_to have_content(comment.body) expect(page).not_to have_content(comment.body)
click_link("Confirmed") click_link("Confirmed")
expect(page).to have_content(comment.body) expect(page).to have_content(comment.body)
expect(comment.reload).to be_confirmed_hide
end end
scenario "Current filter is properly highlighted" do scenario "Current filter is properly highlighted" do

View File

@@ -22,8 +22,6 @@ describe "Admin hidden debates", :admin do
expect(page).not_to have_content(debate.title) expect(page).not_to have_content(debate.title)
click_link("Confirmed") click_link("Confirmed")
expect(page).to have_content(debate.title) expect(page).to have_content(debate.title)
expect(debate.reload).to be_confirmed_hide
end end
scenario "Current filter is properly highlighted" do scenario "Current filter is properly highlighted" do

View File

@@ -35,8 +35,6 @@ describe "Admin hidden proposals", :admin do
expect(page).not_to have_content(proposal.title) expect(page).not_to have_content(proposal.title)
click_link("Confirmed") click_link("Confirmed")
expect(page).to have_content(proposal.title) expect(page).to have_content(proposal.title)
expect(proposal.reload).to be_confirmed_hide
end end
scenario "Current filter is properly highlighted" do scenario "Current filter is properly highlighted" do

View File

@@ -37,8 +37,6 @@ describe "Admin hidden users", :admin do
expect(page).not_to have_content(user.username) expect(page).not_to have_content(user.username)
click_link("Confirmed") click_link("Confirmed")
expect(page).to have_content(user.username) expect(page).to have_content(user.username)
expect(user.reload).to be_confirmed_hide
end end
scenario "Current filter is properly highlighted" do scenario "Current filter is properly highlighted" do

View File

@@ -31,8 +31,6 @@ describe "Admin proposal notifications", :admin do
expect(page).not_to have_content(proposal_notification.title) expect(page).not_to have_content(proposal_notification.title)
click_link("Confirmed") click_link("Confirmed")
expect(page).to have_content(proposal_notification.title) expect(page).to have_content(proposal_notification.title)
expect(proposal_notification.reload).to be_confirmed_hide
end end
scenario "Current filter is properly highlighted" do scenario "Current filter is properly highlighted" do

View File

@@ -80,7 +80,6 @@ describe "Admin proposals", :admin do
expect(page).to have_content "Proposal updated successfully" expect(page).to have_content "Proposal updated successfully"
expect(find_field("Mark as selected")).to be_checked expect(find_field("Mark as selected")).to be_checked
expect(proposal.reload.selected?).to be true
end end
scenario "Unselect a proposal" do scenario "Unselect a proposal" do
@@ -93,7 +92,6 @@ describe "Admin proposals", :admin do
expect(page).to have_content "Proposal updated successfully" expect(page).to have_content "Proposal updated successfully"
expect(find_field("Mark as selected")).not_to be_checked expect(find_field("Mark as selected")).not_to be_checked
expect(proposal.reload.selected?).to be false
end end
end end
end end

View File

@@ -15,13 +15,10 @@ describe "Admin Budgets", :admin do
expect(page).to have_content(budget.name) expect(page).to have_content(budget.name)
expect(page).to have_content(balloting_phase.starts_at.to_date) expect(page).to have_content(balloting_phase.starts_at.to_date)
expect(page).to have_content(balloting_phase.ends_at.to_date) expect(page).to have_content(balloting_phase.ends_at.to_date)
expect(Poll.count).to eq(1)
expect(Poll.last.budget).to eq(budget)
end end
scenario "Create poll in current locale if the budget does not have a poll associated" do scenario "Create poll in current locale if the budget does not have a poll associated" do
budget = create(:budget, create(:budget,
name_en: "Budget for climate change", name_en: "Budget for climate change",
name_fr: "Budget pour le changement climatique") name_fr: "Budget pour le changement climatique")
@@ -32,9 +29,6 @@ describe "Admin Budgets", :admin do
expect(page).to have_current_path(/admin\/polls\/\d+/) expect(page).to have_current_path(/admin\/polls\/\d+/)
expect(page).to have_content("Budget pour le changement climatique") expect(page).to have_content("Budget pour le changement climatique")
expect(Poll.count).to eq(1)
expect(Poll.last.budget).to eq(budget)
end end
scenario "Display link to poll if the budget has a poll associated" do scenario "Display link to poll if the budget has a poll associated" do

View File

@@ -529,12 +529,9 @@ describe "Debates" do
expect(page).not_to have_css(".recommendation", count: 3) expect(page).not_to have_css(".recommendation", count: 3)
expect(page).to have_content("Recommendations for debates are now disabled for this account") expect(page).to have_content("Recommendations for debates are now disabled for this account")
user.reload
visit account_path visit account_path
expect(find("#account_recommended_debates")).not_to be_checked expect(find("#account_recommended_debates")).not_to be_checked
expect(user.recommended_debates).to be(false)
end end
end end
end end

View File

@@ -929,12 +929,9 @@ describe "Proposals" do
expect(page).not_to have_css(".recommendation", count: 3) expect(page).not_to have_css(".recommendation", count: 3)
expect(page).to have_content("Recommendations for proposals are now disabled for this account") expect(page).to have_content("Recommendations for proposals are now disabled for this account")
user.reload
visit account_path visit account_path
expect(find("#account_recommended_proposals")).not_to be_checked expect(find("#account_recommended_proposals")).not_to be_checked
expect(user.recommended_proposals).to be(false)
end end
end end
end end