From 6b7d38c27aeab8aa4d926f88cb54777526619aba Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 17 Oct 2017 15:00:34 +0200 Subject: [PATCH] adds spec for user voting in poll and then verifying account --- spec/features/polls/voter_spec.rb | 28 +++++++++++++++++++++++++++- spec/support/common_actions.rb | 7 ++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/spec/features/polls/voter_spec.rb b/spec/features/polls/voter_spec.rb index 334696768..b99cb15e9 100644 --- a/spec/features/polls/voter_spec.rb +++ b/spec/features/polls/voter_spec.rb @@ -126,10 +126,36 @@ feature "Voter" do expect(page).to have_link('Yes') expect(page).to have_link('No') end - end end + scenario "Voting in poll and then verifiying account", :js do + user = create(:user) + + question = create(:poll_question, poll: poll) + answer1 = create(:poll_question_answer, question: question, title: 'Yes') + answer2 = create(:poll_question_answer, question: question, title: 'No') + + login_through_form_as_officer(officer.user) + vote_for_poll_via_booth + + visit root_path + click_link "Sign out" + + login_as user + visit account_path + click_link 'Verify my account' + + verify_residence + confirm_phone(user) + + visit poll_path(poll) + + expect(page).to_not have_link('Yes') + expect(page).to have_content "You have already participated in a physical booth. You can not participate again." + expect(Poll::Voter.count).to eq(1) + end + end end diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 256b070e4..a55ebd63c 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -163,14 +163,15 @@ module CommonActions expect(page).to have_content 'Document verified with Census' end - def confirm_phone + def confirm_phone(user=nil) + user ||= User.last + fill_in 'sms_phone', with: "611111111" click_button 'Send' expect(page).to have_content 'Enter the confirmation code sent to you by text message' - user = User.last.reload - fill_in 'sms_confirmation_code', with: user.sms_confirmation_code + fill_in 'sms_confirmation_code', with: user.reload.sms_confirmation_code click_button 'Send' expect(page).to have_content 'Code correct'