diff --git a/app/controllers/verification/verified_user_controller.rb b/app/controllers/verification/verified_user_controller.rb index 6964a2bd5..23045e451 100644 --- a/app/controllers/verification/verified_user_controller.rb +++ b/app/controllers/verification/verified_user_controller.rb @@ -5,6 +5,19 @@ class Verification::VerifiedUserController < ApplicationController def show @verified_users = VerifiedUser.by_user(current_user) - redirect_to new_sms_path if @verified_users.blank? + redirect_to new_sms_path unless user_data_present? end + + private + def user_data_present? + return false if @verified_users.blank? + + data = false + @verified_users.each do |vu| + data = true if vu.phone.present? || vu.email.present? + end + + data + end + end \ No newline at end of file diff --git a/spec/features/verification/letter_spec.rb b/spec/features/verification/letter_spec.rb index dd5e59b96..6378c0eaa 100644 --- a/spec/features/verification/letter_spec.rb +++ b/spec/features/verification/letter_spec.rb @@ -71,7 +71,7 @@ feature 'Verify Letter' do visit new_letter_path expect(page).to have_content 'You have not yet confirmed your residence' - expect(URI.parse(current_url).path).to eq(new_residence_path) + expect(current_path).to eq(new_residence_path) end scenario "Deny access unless verified phone/email" do @@ -81,7 +81,7 @@ feature 'Verify Letter' do visit new_letter_path expect(page).to have_content 'You have not yet enter the confirmation code' - expect(URI.parse(current_url).path).to eq(new_sms_path) + expect(current_path).to eq(new_sms_path) end scenario '6 tries allowed' do @@ -97,11 +97,11 @@ feature 'Verify Letter' do end expect(page).to have_content "You have reached the maximum number of verification tries. Please try again later." - expect(URI.parse(current_url).path).to eq(account_path) + 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(URI.parse(current_url).path).to eq(account_path) + expect(current_path).to eq(account_path) end end diff --git a/spec/features/verification/residence_spec.rb b/spec/features/verification/residence_spec.rb index 5091f9c7c..07fbdcd35 100644 --- a/spec/features/verification/residence_spec.rb +++ b/spec/features/verification/residence_spec.rb @@ -74,10 +74,10 @@ feature 'Residence' do click_button 'Verify residence' expect(page).to have_content "You have reached the maximum number of verification tries. Please try again later." - expect(URI.parse(current_url).path).to eq(account_path) + expect(current_path).to eq(account_path) visit new_residence_path expect(page).to have_content "You have reached the maximum number of verification tries. Please try again later." - expect(URI.parse(current_url).path).to eq(account_path) + expect(current_path).to eq(account_path) end end \ No newline at end of file diff --git a/spec/features/verification/sms_spec.rb b/spec/features/verification/sms_spec.rb index 0d022d188..3afe33a43 100644 --- a/spec/features/verification/sms_spec.rb +++ b/spec/features/verification/sms_spec.rb @@ -54,7 +54,7 @@ feature 'SMS Verification' do visit new_sms_path expect(page).to have_content 'You have not yet confirmed your residence' - expect(URI.parse(current_url).path).to eq(new_residence_path) + expect(current_path).to eq(new_residence_path) end scenario '5 tries allowed' do @@ -70,11 +70,11 @@ feature 'SMS Verification' do end expect(page).to have_content "You have reached the maximum number of verification tries. Please try again later." - expect(URI.parse(current_url).path).to eq(account_path) + expect(current_path).to eq(account_path) visit new_sms_path expect(page).to have_content "You have reached the maximum number of verification tries. Please try again later." - expect(URI.parse(current_url).path).to eq(account_path) + expect(current_path).to eq(account_path) end end \ No newline at end of file diff --git a/spec/features/verification/verified_user_spec.rb b/spec/features/verification/verified_user_spec.rb index 0a74a7798..032136b84 100644 --- a/spec/features/verification/verified_user_spec.rb +++ b/spec/features/verification/verified_user_spec.rb @@ -24,6 +24,7 @@ feature 'Verified users' do expect(page).to have_content 'roc*@example.com' expect(page).to have_content 'rol*@example.com' + expect(page).not_to have_content 'ano*@example.com' end scenario "Verified phones" do @@ -48,8 +49,27 @@ feature 'Verified users' do expect(page).to have_content '******111' expect(page).to have_content '******222' + expect(page).not_to have_content '******333' end + scenario "No emails or phones" do + user = create(:user, + residence_verified_at: Time.now, + document_number: '12345678Z') + + create(:verified_user, + document_number: '12345678Z') + + create(:verified_user, + document_number: '12345678Z') + + login_as(user) + visit verified_user_path + + expect(current_path).to eq new_sms_path + end + + scenario "Select a verified email" do user = create(:user, residence_verified_at: Time.now, @@ -67,7 +87,7 @@ feature 'Verified users' do end expect(page).to have_content 'We have send you a confirmation email to your email account: rock@example.com' - expect(URI.parse(current_url).path).to eq(account_path) + expect(current_path).to eq(account_path) end scenario "Select a verified phone" do @@ -103,7 +123,7 @@ feature 'Verified users' do click_link "Use another phone" - expect(URI.parse(current_url).path).to eq(new_sms_path) + expect(current_path).to eq(new_sms_path) end scenario "No verified information" do @@ -112,7 +132,7 @@ feature 'Verified users' do login_as(user) visit verified_user_path - expect(URI.parse(current_url).path).to eq(new_sms_path) + expect(current_path).to eq(new_sms_path) end end \ No newline at end of file diff --git a/spec/features/votes_spec.rb b/spec/features/votes_spec.rb index 1116d2985..a3cf2e43a 100644 --- a/spec/features/votes_spec.rb +++ b/spec/features/votes_spec.rb @@ -220,7 +220,7 @@ feature 'Votes' do expect(page).to have_content "1 vote" end - expect(URI.parse(current_url).path).to eq(root_path) + expect(current_path).to eq(root_path) end scenario 'Create in index', :js do @@ -242,7 +242,7 @@ feature 'Votes' do expect(page).to have_content "1 vote" end - expect(URI.parse(current_url).path).to eq(debates_path) + expect(current_path).to eq(debates_path) end end end