diff --git a/spec/features/polls/voter_spec.rb b/spec/features/polls/voter_spec.rb index c12a9f0e4..d925d3394 100644 --- a/spec/features/polls/voter_spec.rb +++ b/spec/features/polls/voter_spec.rb @@ -10,12 +10,13 @@ feature "Voter" do user = create(:user, :level_two) login_as user - visit question_path(question) + visit poll_path(poll) - click_link 'Go to voting page' - click_link 'Yes' + within("#poll_question_#{question.id}_answers") do + click_link 'Yes' + expect(page).to_not have_link('Yes') + end - expect(page).to_not have_link('Yes') expect(Poll::Voter.count).to eq(1) expect(Poll::Voter.first.origin).to eq("web") end @@ -56,7 +57,7 @@ feature "Voter" do scenario "Trying to vote in web and then in booth", :js do login_as user - vote_for_poll_via_web + vote_for_poll_via_web(poll, question) click_link "Sign out" @@ -79,9 +80,7 @@ feature "Voter" do click_link "Sign out" login_as user - visit question_path(question) - - click_link 'Go to voting page' + visit poll_path(poll) expect(page).to_not have_link('Yes') expect(page).to have_content "You have already participated in a booth for this poll." diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index eda55986f..256b070e4 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -298,13 +298,14 @@ module CommonActions end end - def vote_for_poll_via_web - visit question_path(question) + def vote_for_poll_via_web(poll, question) + visit poll_path(poll) - click_link 'Go to voting page' - click_link 'Yes' + within("#poll_question_#{question.id}_answers") do + click_link 'Yes' + expect(page).to_not have_link('Yes') + end - expect(page).to_not have_link('Yes') expect(Poll::Voter.count).to eq(1) end