Merge pull request #2066 from consul/poll-voting

Adds spec for user voting in booth and then verifying account
This commit is contained in:
BertoCQ
2017-10-17 21:21:12 +02:00
committed by GitHub
2 changed files with 31 additions and 4 deletions

View File

@@ -147,10 +147,36 @@ feature "Voter" do
expect(page).to have_link('Yes') expect(page).to have_link('Yes')
expect(page).to have_link('No') expect(page).to have_link('No')
end end
end 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
end end

View File

@@ -163,14 +163,15 @@ module CommonActions
expect(page).to have_content 'Document verified with Census' expect(page).to have_content 'Document verified with Census'
end end
def confirm_phone def confirm_phone(user=nil)
user ||= User.last
fill_in 'sms_phone', with: "611111111" fill_in 'sms_phone', with: "611111111"
click_button 'Send' click_button 'Send'
expect(page).to have_content 'Enter the confirmation code sent to you by text message' 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.reload.sms_confirmation_code
fill_in 'sms_confirmation_code', with: user.sms_confirmation_code
click_button 'Send' click_button 'Send'
expect(page).to have_content 'Code correct' expect(page).to have_content 'Code correct'