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/verified_user_spec.rb b/spec/features/verification/verified_user_spec.rb index 0a74a7798..d2f16b38b 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,