From e5c502b1cc58fa7829dca0e74946f948e9793e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 28 Sep 2019 01:35:31 +0200 Subject: [PATCH] Split tests checking permissions to vote in a poll The test was hard to follow, and splitting the test in three it's easier to read and doesn't create unused variables anymore. On the minus side, now there's one extra request during the tests. --- spec/features/polls/polls_spec.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spec/features/polls/polls_spec.rb b/spec/features/polls/polls_spec.rb index e24ebc692..df60a0499 100644 --- a/spec/features/polls/polls_spec.rb +++ b/spec/features/polls/polls_spec.rb @@ -84,18 +84,25 @@ describe "Polls" do expect(page).to have_css(".unverified", count: 3) expect(page).to have_content("You must verify your account to participate") + end - poll_district = create(:poll, geozone_restricted: true) - verified = create(:user, :level_two) - login_as(verified) + scenario "Geozone poll" do + create(:poll, geozone_restricted: true) + login_as(create(:user, :level_two)) visit polls_path expect(page).to have_css(".cant-answer", count: 1) expect(page).to have_content("This poll is not available on your geozone") + end + scenario "Already participated in a poll", :js do poll_with_question = create(:poll) question = create(:poll_question, :yes_no, poll: poll_with_question) + + login_as(create(:user, :level_two)) + visit polls_path + vote_for_poll_via_web(poll_with_question, question, "Yes") visit polls_path