Skip to content

Commit

Permalink
Updates test for verification
Browse files Browse the repository at this point in the history
  • Loading branch information
decabeza committed Oct 2, 2015
1 parent ebcb100 commit 8188879
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 54 deletions.
4 changes: 2 additions & 2 deletions config/locales/verification.en.yml
Expand Up @@ -76,7 +76,7 @@ en:
office: "Verify in any %{office}"
offices: "Office of Citizen"
offices_url: "http://www.madrid.es/portales/munimadrid/es/Inicio/El-Ayuntamiento/Atencion-al-ciudadano/Oficinas-de-Atencion-al-Ciudadano?vgnextfmt=default&vgnextchannel=5b99cde2e09a4310VgnVCM1000000b205a0aRCRD"
send_letter: "request a letter"
send_letter: "Request a letter"
go_to_index: "See proposals and debates"
create:
flash:
Expand All @@ -85,7 +85,7 @@ en:
offices_url: "http://www.madrid.es/portales/munimadrid/es/Inicio/El-Ayuntamiento/Atencion-al-ciudadano/Oficinas-de-Atencion-al-Ciudadano?vgnextfmt=default&vgnextchannel=5b99cde2e09a4310VgnVCM1000000b205a0aRCRD"
edit:
title: "Letter requested"
see_all: "Ver debates y propuestas"
see_all: "See proposals and debates"
update:
flash:
success: "Correct code. Your account is verified"
Expand Down
1 change: 0 additions & 1 deletion config/locales/verification.es.yml
Expand Up @@ -11,7 +11,6 @@ es:
user_permission_proposal: "Crear nuevas propuestas"
user_permission_support_proposal: "Apoyar propuestas"
user_permission_votes: "Participar en las votaciones finales"
user_permission_verify_info: ""
residence:
new:
title: "Verificar residencia"
Expand Down
41 changes: 5 additions & 36 deletions spec/features/verification/letter_spec.rb
Expand Up @@ -10,15 +10,9 @@
login_as(user)
visit new_letter_path

click_button "Send me a letter with the code"
click_link "Request a letter"

expect(page).to have_content "Thank you for requesting a maximum security code in a few days we will send it to the address on your census data."

user.reload
fill_in "letter_verification_code", with: user.letter_verification_code
click_button "Send"

expect(page).to have_content "Correct code. Your account is verified"
expect(page).to have_content "Before voting you'll receive a letter whith the instructions for verify your account."
end

scenario 'Go to office instead of send letter' do
Expand All @@ -29,7 +23,7 @@
login_as(user)
visit new_letter_path

expect(page).to have_link "See Office of Citizen", href: "http://www.madrid.es/portales/munimadrid/es/Inicio/El-Ayuntamiento/Atencion-al-ciudadano/Oficinas-de-Atencion-al-Ciudadano?vgnextfmt=default&vgnextchannel=5b99cde2e09a4310VgnVCM1000000b205a0aRCRD"
expect(page).to have_link "Office of Citizen", href: "http://www.madrid.es/portales/munimadrid/es/Inicio/El-Ayuntamiento/Atencion-al-ciudadano/Oficinas-de-Atencion-al-Ciudadano?vgnextfmt=default&vgnextchannel=5b99cde2e09a4310VgnVCM1000000b205a0aRCRD"
end

scenario 'Errors on verification code' do
Expand All @@ -40,13 +34,9 @@
login_as(user)
visit new_letter_path

click_button "Send me a letter with the code"
expect(page).to have_content "Thank you for requesting a maximum security code in a few days we will send it to the address on your census data."
click_link "Request a letter"
expect(page).to have_content "Before voting you'll receive a letter whith the instructions for verify your account."

fill_in "letter_verification_code", with: "1"
click_button "Send"

expect(page).to have_content "Incorrect confirmation code"
end

scenario "Deny access unless verified residence" do
Expand All @@ -68,25 +58,4 @@
expect(page).to have_content 'You have not yet enter the confirmation code'
expect(current_path).to eq(new_sms_path)
end

scenario '6 tries allowed' do
user = create(:user, residence_verified_at: Time.now, confirmed_phone: "611111111")
login_as(user)

visit new_letter_path
click_button 'Send me a letter with the code'

6.times do
fill_in 'letter_verification_code', with: "999999"
click_button 'Send'
end

expect(page).to have_content "You have reached the maximum number of verification tries. Please try again later."
expect(current_path).to eq(account_path)

visit new_letter_path
expect(page).to have_content "You have reached the maximum number of verification tries. Please try again later."
expect(current_path).to eq(account_path)
end

end
14 changes: 4 additions & 10 deletions spec/features/verification/level_three_verification_spec.rb
Expand Up @@ -20,7 +20,7 @@
click_button "Send code"
end

expect(page).to have_content 'Security code confirmation'
expect(page).to have_content 'Phone confirmation'

user = user.reload
fill_in 'sms_confirmation_code', with: user.sms_confirmation_code
Expand Down Expand Up @@ -75,22 +75,16 @@
fill_in 'sms_phone', with: "611111111"
click_button 'Send'

expect(page).to have_content 'Security code confirmation'
expect(page).to have_content 'Phone confirmation'

user = user.reload
fill_in 'sms_confirmation_code', with: user.sms_confirmation_code
click_button 'Send'

expect(page).to have_content 'Correct code'

click_button "Send me a letter with the code"
click_link "Request a letter"

expect(page).to have_content "Thank you for requesting a maximum security code in a few days we will send it to the address on your census data."

user.reload
fill_in "letter_verification_code", with: user.letter_verification_code
click_button "Send"

expect(page).to have_content "We have not sent you the letter with the code yet"
expect(page).to have_content "Before voting you'll receive a letter whith the instructions for verify your account."
end
end
2 changes: 1 addition & 1 deletion spec/features/verification/level_two_verification_spec.rb
Expand Up @@ -14,7 +14,7 @@
fill_in 'sms_phone', with: "611111111"
click_button 'Send'

expect(page).to have_content 'Security code confirmation'
expect(page).to have_content 'Phone confirmation'

user = user.reload
fill_in 'sms_confirmation_code', with: user.sms_confirmation_code
Expand Down
6 changes: 3 additions & 3 deletions spec/features/verification/sms_spec.rb
Expand Up @@ -11,7 +11,7 @@
fill_in 'sms_phone', with: "611111111"
click_button 'Send'

expect(page).to have_content 'Security code confirmation'
expect(page).to have_content 'Phone confirmation'

user = user.reload
fill_in 'sms_confirmation_code', with: user.sms_confirmation_code
Expand Down Expand Up @@ -40,7 +40,7 @@
fill_in 'sms_phone', with: "611111111"
click_button 'Send'

expect(page).to have_content 'Security code confirmation'
expect(page).to have_content 'Phone confirmation'

click_button 'Send'

Expand All @@ -66,7 +66,7 @@
5.times do
fill_in 'sms_phone', with: "611111111"
click_button 'Send'
click_link 'Click here to send the confirmation code again'
click_link 'Request a new code'
end

expect(page).to have_content "You have reached the maximum number of verification tries. Please try again later."
Expand Down
2 changes: 1 addition & 1 deletion spec/support/common_actions.rb
Expand Up @@ -127,7 +127,7 @@ def confirm_phone
fill_in 'sms_phone', with: "611111111"
click_button 'Send'

expect(page).to have_content 'Security code confirmation'
expect(page).to have_content 'Phone confirmation'

user = User.last.reload
fill_in 'sms_confirmation_code', with: user.sms_confirmation_code
Expand Down

0 comments on commit 8188879

Please sign in to comment.