diff --git a/app/controllers/concerns/account_recovery_concern.rb b/app/controllers/concerns/account_reactivation_concern.rb similarity index 90% rename from app/controllers/concerns/account_recovery_concern.rb rename to app/controllers/concerns/account_reactivation_concern.rb index 46a36b11026..4c0140fcbcf 100644 --- a/app/controllers/concerns/account_recovery_concern.rb +++ b/app/controllers/concerns/account_reactivation_concern.rb @@ -1,4 +1,4 @@ -module AccountRecoveryConcern +module AccountReactivationConcern extend ActiveSupport::Concern def confirm_password_reset_profile diff --git a/app/controllers/reactivate_account_controller.rb b/app/controllers/reactivate_account_controller.rb index a9eff6cc5e4..dbb0eccba49 100644 --- a/app/controllers/reactivate_account_controller.rb +++ b/app/controllers/reactivate_account_controller.rb @@ -1,5 +1,5 @@ class ReactivateAccountController < ApplicationController - include AccountRecoveryConcern + include AccountReactivationConcern before_action :confirm_two_factor_authenticated before_action :confirm_password_reset_profile diff --git a/app/controllers/users/verify_password_controller.rb b/app/controllers/users/verify_password_controller.rb index 67bea6d230f..2dc268cb5e4 100644 --- a/app/controllers/users/verify_password_controller.rb +++ b/app/controllers/users/verify_password_controller.rb @@ -1,6 +1,6 @@ module Users class VerifyPasswordController < ApplicationController - include AccountRecoveryConcern + include AccountReactivationConcern before_action :confirm_two_factor_authenticated before_action :confirm_password_reset_profile diff --git a/app/controllers/users/verify_personal_key_controller.rb b/app/controllers/users/verify_personal_key_controller.rb index 6316fc9441b..0e7fbe39643 100644 --- a/app/controllers/users/verify_personal_key_controller.rb +++ b/app/controllers/users/verify_personal_key_controller.rb @@ -1,10 +1,10 @@ module Users class VerifyPersonalKeyController < ApplicationController - include AccountRecoveryConcern + include AccountReactivationConcern before_action :confirm_two_factor_authenticated before_action :confirm_password_reset_profile - before_action :init_account_recovery, only: [:new] + before_action :init_account_reactivation, only: [:new] def new @personal_key_form = VerifyPersonalKeyForm.new( @@ -25,10 +25,10 @@ def create private - def init_account_recovery + def init_account_reactivation return if reactivate_account_session.started? - flash.now[:notice] = t('notices.account_recovery') + flash.now[:notice] = t('notices.account_reactivation') reactivate_account_session.start end diff --git a/app/controllers/verify_controller.rb b/app/controllers/verify_controller.rb index 1f62949184a..b4ac0e88992 100644 --- a/app/controllers/verify_controller.rb +++ b/app/controllers/verify_controller.rb @@ -1,6 +1,6 @@ class VerifyController < ApplicationController include IdvSession - include AccountRecoveryConcern + include AccountReactivationConcern before_action :confirm_two_factor_authenticated before_action :confirm_idv_needed, only: %i[cancel fail] diff --git a/config/locales/notices/en.yml b/config/locales/notices/en.yml index 98188b14bbd..89edc2ba0a8 100644 --- a/config/locales/notices/en.yml +++ b/config/locales/notices/en.yml @@ -1,7 +1,7 @@ --- en: notices: - account_recovery: Great! You have your personal key. + account_reactivation: Great! You have your personal key. dap_html: > diff --git a/config/locales/notices/es.yml b/config/locales/notices/es.yml index 46c9667b8f6..d9e1d0713e6 100644 --- a/config/locales/notices/es.yml +++ b/config/locales/notices/es.yml @@ -1,7 +1,7 @@ --- es: notices: - account_recovery: NOT TRANSLATED YET + account_reactivation: NOT TRANSLATED YET dap_html: NOT TRANSLATED YET forgot_password: use_diff_email: diff --git a/spec/controllers/users/verify_password_controller_spec.rb b/spec/controllers/users/verify_password_controller_spec.rb index 540ce2967a7..fba5173e971 100644 --- a/spec/controllers/users/verify_password_controller_spec.rb +++ b/spec/controllers/users/verify_password_controller_spec.rb @@ -20,71 +20,72 @@ end end - context 'without personal key flag set' do - let(:profiles) { [create(:profile, deactivation_reason: :password_reset)] } - - describe '#new' do - it 'redirects to the root url' do - get :new - expect(response).to redirect_to(root_url) - end - end - - describe '#update' do - it 'redirects to the root url' do - get :new - expect(response).to redirect_to(root_url) - end - end - end - context 'with password reset profile' do let(:profiles) { [create(:profile, deactivation_reason: :password_reset)] } let(:response_ok) { FormResponse.new(success: true, errors: {}, extra: { personal_key: key }) } let(:response_bad) { FormResponse.new(success: false, errors: {}) } let(:key) { 'key' } - before do - allow(subject.reactivate_account_session).to receive(:personal_key?).and_return(personal_key) - end - - describe '#new' do - it 'renders the `new` template' do - get :new + context 'without personal key flag set' do + describe '#new' do + it 'redirects to the root url' do + get :new + expect(response).to redirect_to(root_url) + end + end - expect(response).to render_template(:new) + describe '#update' do + it 'redirects to the root url' do + get :new + expect(response).to redirect_to(root_url) + end end end - describe '#update' do - let(:form) { instance_double(VerifyPasswordForm) } - + context 'with personal key flag set' do before do - expect(controller).to receive(:verify_password_form).and_return(form) + allow(subject.reactivate_account_session).to receive(:personal_key?). + and_return(personal_key) end - context 'with valid password' do - before do - allow(form).to receive(:submit).and_return(response_ok) - put :update, user: { password: user.password } + describe '#new' do + it 'renders the `new` template' do + get :new + + expect(response).to render_template(:new) end + end - it 'redirects to the account page' do - expect(response).to redirect_to(account_url) + describe '#update' do + let(:form) { instance_double(VerifyPasswordForm) } + + before do + expect(controller).to receive(:verify_password_form).and_return(form) end - it 'sets a new personal key as a flash message' do - expect(flash[:personal_key]).to eq(key) + context 'with valid password' do + before do + allow(form).to receive(:submit).and_return(response_ok) + put :update, user: { password: user.password } + end + + it 'redirects to the account page' do + expect(response).to redirect_to(account_url) + end + + it 'sets a new personal key as a flash message' do + expect(flash[:personal_key]).to eq(key) + end end - end - context 'without valid password' do - it 'renders the new template' do - allow(form).to receive(:submit).and_return(response_bad) + context 'without valid password' do + it 'renders the new template' do + allow(form).to receive(:submit).and_return(response_bad) - put :update, user: { password: user.password } + put :update, user: { password: user.password } - expect(response).to render_template(:new) + expect(response).to render_template(:new) + end end end end diff --git a/spec/controllers/users/verify_personal_key_controller_spec.rb b/spec/controllers/users/verify_personal_key_controller_spec.rb index 0e16e56d7ca..d8d7698bfa3 100644 --- a/spec/controllers/users/verify_personal_key_controller_spec.rb +++ b/spec/controllers/users/verify_personal_key_controller_spec.rb @@ -33,7 +33,7 @@ it 'displays a flash message to the user' do get :new - expect(subject.flash[:notice]).to eq(t('notices.account_recovery')) + expect(subject.flash[:notice]).to eq(t('notices.account_reactivation')) end end end