From a586ba8069484b6c1c084a2e12d52a97c72f9732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 10 Apr 2021 15:10:50 +0200 Subject: [PATCH] Test restoring data from the user's point of view We were checking the database, but users don't care about what's inside the database; they care about what happens when they visit the page of a record they've just restored. This way we also avoid data inconsistency due to the process running the test accessing the database after the process running the browser has started. --- spec/system/admin/hidden_budget_investments_spec.rb | 4 ++-- spec/system/admin/hidden_comments_spec.rb | 5 +++-- spec/system/admin/hidden_debates_spec.rb | 5 +++-- spec/system/admin/hidden_proposals_spec.rb | 5 +++-- spec/system/admin/hidden_users_spec.rb | 4 +++- spec/system/admin/proposal_notifications_spec.rb | 8 +++++--- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/spec/system/admin/hidden_budget_investments_spec.rb b/spec/system/admin/hidden_budget_investments_spec.rb index f400c5362..0baa84ea8 100644 --- a/spec/system/admin/hidden_budget_investments_spec.rb +++ b/spec/system/admin/hidden_budget_investments_spec.rb @@ -22,9 +22,9 @@ describe "Admin hidden budget investments", :admin do expect(page).not_to have_content(investment.title) - investment.reload + visit budget_investment_path(investment.budget, investment) - expect(investment).to be_ignored_flag + expect(page).to have_content(investment.title) end scenario "Confirm hide" do diff --git a/spec/system/admin/hidden_comments_spec.rb b/spec/system/admin/hidden_comments_spec.rb index 0832f068a..b5e34081e 100644 --- a/spec/system/admin/hidden_comments_spec.rb +++ b/spec/system/admin/hidden_comments_spec.rb @@ -71,8 +71,9 @@ describe "Admin hidden comments", :admin do expect(page).not_to have_content(comment.body) - expect(comment.reload).not_to be_hidden - expect(comment).to be_ignored_flag + visit comment_path(comment) + + expect(page).to have_content(comment.body) end scenario "Confirm hide" do diff --git a/spec/system/admin/hidden_debates_spec.rb b/spec/system/admin/hidden_debates_spec.rb index 0ce7eb035..d9dff151e 100644 --- a/spec/system/admin/hidden_debates_spec.rb +++ b/spec/system/admin/hidden_debates_spec.rb @@ -9,8 +9,9 @@ describe "Admin hidden debates", :admin do expect(page).not_to have_content(debate.title) - expect(debate.reload).not_to be_hidden - expect(debate).to be_ignored_flag + visit debate_path(debate) + + expect(page).to have_content debate.title end scenario "Confirm hide" do diff --git a/spec/system/admin/hidden_proposals_spec.rb b/spec/system/admin/hidden_proposals_spec.rb index 832d61806..b764e1389 100644 --- a/spec/system/admin/hidden_proposals_spec.rb +++ b/spec/system/admin/hidden_proposals_spec.rb @@ -22,8 +22,9 @@ describe "Admin hidden proposals", :admin do expect(page).not_to have_content(proposal.title) - expect(proposal.reload).not_to be_hidden - expect(proposal).to be_ignored_flag + visit proposal_path(proposal) + + expect(page).to have_content proposal.title end scenario "Confirm hide" do diff --git a/spec/system/admin/hidden_users_spec.rb b/spec/system/admin/hidden_users_spec.rb index 13c2da4bc..880485942 100644 --- a/spec/system/admin/hidden_users_spec.rb +++ b/spec/system/admin/hidden_users_spec.rb @@ -25,7 +25,9 @@ describe "Admin hidden users", :admin do expect(page).not_to have_content(user.username) - expect(user.reload).not_to be_hidden + visit user_path(user) + + expect(page).to have_content(user.username) end scenario "Confirm hide" do diff --git a/spec/system/admin/proposal_notifications_spec.rb b/spec/system/admin/proposal_notifications_spec.rb index c3807ad2f..7823d18b8 100644 --- a/spec/system/admin/proposal_notifications_spec.rb +++ b/spec/system/admin/proposal_notifications_spec.rb @@ -17,9 +17,11 @@ describe "Admin proposal notifications", :admin do expect(page).not_to have_content(proposal_notification.title) - expect(proposal_notification.reload).not_to be_hidden - expect(proposal_notification).to be_ignored - expect(proposal_notification).not_to be_moderated + logout + login_as(proposal_notification.author) + visit proposal_notification_path(proposal_notification) + + expect(page).to have_content(proposal_notification.title) end scenario "Confirm hide" do