Files
nairobi/spec/support/common_actions/polls.rb
Senén Rodero Rodríguez 527d5691f7 Make poll feature work in browsers with javascript disabled
By using the Rails `button_to` helper (which generates a form), and adapting the
response to `html` and `js` formats, the feature works with or without javascript
enabled.
2022-09-22 17:39:57 +02:00

39 lines
956 B
Ruby

module Polls
def vote_for_poll_via_web(poll, question, answer)
visit poll_path(poll)
within("#poll_question_#{question.id}_answers") do
click_button answer
expect(page).to have_css("span.answered", text: answer)
expect(page).not_to have_button(answer)
end
end
def vote_for_poll_via_booth
visit new_officing_residence_path
officing_verify_residence
expect(page).to have_content poll.name
first(:button, "Confirm vote").click
expect(page).to have_content "Vote introduced!"
expect(Poll::Voter.count).to eq(1)
end
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"
fill_in "sms_confirmation_code", with: user.reload.sms_confirmation_code
click_button "Send"
expect(page).to have_content "Code correct"
end
end