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.
This commit is contained in:
Javi Martín
2019-09-28 01:35:31 +02:00
parent 72c10ab279
commit e5c502b1cc

View File

@@ -84,18 +84,25 @@ describe "Polls" do
expect(page).to have_css(".unverified", count: 3) expect(page).to have_css(".unverified", count: 3)
expect(page).to have_content("You must verify your account to participate") expect(page).to have_content("You must verify your account to participate")
end
poll_district = create(:poll, geozone_restricted: true) scenario "Geozone poll" do
verified = create(:user, :level_two) create(:poll, geozone_restricted: true)
login_as(verified)
login_as(create(:user, :level_two))
visit polls_path visit polls_path
expect(page).to have_css(".cant-answer", count: 1) expect(page).to have_css(".cant-answer", count: 1)
expect(page).to have_content("This poll is not available on your geozone") 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) poll_with_question = create(:poll)
question = create(:poll_question, :yes_no, poll: poll_with_question) 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") vote_for_poll_via_web(poll_with_question, question, "Yes")
visit polls_path visit polls_path