From d3618274c07713e4070c14a01f93877c89942680 Mon Sep 17 00:00:00 2001 From: "Jessie A. Young" Date: Fri, 31 Mar 2017 10:07:33 -0700 Subject: [PATCH 1/2] Revert #1288 This reverts commit b84105f09599565f3c0ae9f52ad7a32e3ebaa579. --- app/helpers/application_helper.rb | 2 +- spec/features/visitors/email_confirmation_spec.rb | 4 ---- spec/features/visitors/password_recovery_spec.rb | 2 -- spec/helpers/application_helper_spec.rb | 4 ++-- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5524574fed7..a2c31c27a30 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -42,7 +42,7 @@ def session_with_trust? end def page_with_trust? - current_page?(controller: 'sign_up/passwords', action: 'new') || + current_page?(controller: 'sign_up/email_confirmations', action: 'create') || current_page?(controller: 'users/reset_passwords', action: 'edit') end diff --git a/spec/features/visitors/email_confirmation_spec.rb b/spec/features/visitors/email_confirmation_spec.rb index 6cd314b15ed..038f5f0d88c 100644 --- a/spec/features/visitors/email_confirmation_spec.rb +++ b/spec/features/visitors/email_confirmation_spec.rb @@ -2,14 +2,12 @@ feature 'Email confirmation during sign up' do scenario 'confirms valid email and sets valid password' do - allow(Figaro.env).to receive(:participate_in_dap).and_return('true') reset_email email = 'test@example.com' sign_up_with(email) open_email(email) visit_in_email(t('mailer.confirmation_instructions.link_text')) - expect(page.html).not_to include(t('notices.dap_html')) expect(page).to have_content t('devise.confirmations.confirmed_but_must_set_password') expect(page).to have_title t('titles.confirmations.show') expect(page).to have_content t('forms.confirmation.show_hdr') @@ -67,13 +65,11 @@ context 'confirmed user is signed out and tries to confirm again' do it 'redirects to sign in page with message that user is already confirmed' do - allow(Figaro.env).to receive(:participate_in_dap).and_return('true') sign_up_and_set_password visit destroy_user_session_url visit sign_up_create_email_confirmation_url(confirmation_token: @raw_confirmation_token) - expect(page.html).to include(t('notices.dap_html')) expect(page).to have_content( t('devise.confirmations.already_confirmed', action: 'Please sign in.') ) diff --git a/spec/features/visitors/password_recovery_spec.rb b/spec/features/visitors/password_recovery_spec.rb index 7be2c674941..f4b6e50fd10 100644 --- a/spec/features/visitors/password_recovery_spec.rb +++ b/spec/features/visitors/password_recovery_spec.rb @@ -41,7 +41,6 @@ def reactivate_profile(password, recovery_code) context 'user enters valid email in forgot password form', email: true do it 'redirects to forgot_password path and sends an email to the user' do - allow(Figaro.env).to receive(:participate_in_dap).and_return('true') user = create(:user, :signed_up) visit root_path @@ -64,7 +63,6 @@ def reactivate_profile(password, recovery_code) open_last_email click_email_link_matching(/reset_password_token/) - expect(page.html).not_to include(t('notices.dap_html')) expect(current_path).to eq edit_user_password_path end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 6243c12af4c..4aa30a9395a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -34,7 +34,7 @@ context 'current path is email confirmation path' do it 'returns true' do allow(helper).to receive(:current_page?).with( - controller: 'sign_up/passwords', action: 'new' + controller: 'sign_up/email_confirmations', action: 'create' ).and_return(true) expect(helper.session_with_trust?).to eq true @@ -44,7 +44,7 @@ context 'current path is reset password path' do it 'returns true' do allow(helper).to receive(:current_page?).with( - controller: 'sign_up/passwords', action: 'new' + controller: 'sign_up/email_confirmations', action: 'create' ).and_return(true) allow(helper).to receive(:current_page?).with( controller: 'users/reset_passwords', action: 'edit' From c569891718b45ae0a66942685adebf10be271916 Mon Sep 17 00:00:00 2001 From: "Jessie A. Young" Date: Fri, 31 Mar 2017 10:11:08 -0700 Subject: [PATCH 2/2] Add back feature specs to confirm DAP behavior **WHY**: Testing is ideal --- spec/features/visitors/email_confirmation_spec.rb | 4 ++++ spec/features/visitors/password_recovery_spec.rb | 2 ++ 2 files changed, 6 insertions(+) diff --git a/spec/features/visitors/email_confirmation_spec.rb b/spec/features/visitors/email_confirmation_spec.rb index 038f5f0d88c..6cd314b15ed 100644 --- a/spec/features/visitors/email_confirmation_spec.rb +++ b/spec/features/visitors/email_confirmation_spec.rb @@ -2,12 +2,14 @@ feature 'Email confirmation during sign up' do scenario 'confirms valid email and sets valid password' do + allow(Figaro.env).to receive(:participate_in_dap).and_return('true') reset_email email = 'test@example.com' sign_up_with(email) open_email(email) visit_in_email(t('mailer.confirmation_instructions.link_text')) + expect(page.html).not_to include(t('notices.dap_html')) expect(page).to have_content t('devise.confirmations.confirmed_but_must_set_password') expect(page).to have_title t('titles.confirmations.show') expect(page).to have_content t('forms.confirmation.show_hdr') @@ -65,11 +67,13 @@ context 'confirmed user is signed out and tries to confirm again' do it 'redirects to sign in page with message that user is already confirmed' do + allow(Figaro.env).to receive(:participate_in_dap).and_return('true') sign_up_and_set_password visit destroy_user_session_url visit sign_up_create_email_confirmation_url(confirmation_token: @raw_confirmation_token) + expect(page.html).to include(t('notices.dap_html')) expect(page).to have_content( t('devise.confirmations.already_confirmed', action: 'Please sign in.') ) diff --git a/spec/features/visitors/password_recovery_spec.rb b/spec/features/visitors/password_recovery_spec.rb index f4b6e50fd10..7be2c674941 100644 --- a/spec/features/visitors/password_recovery_spec.rb +++ b/spec/features/visitors/password_recovery_spec.rb @@ -41,6 +41,7 @@ def reactivate_profile(password, recovery_code) context 'user enters valid email in forgot password form', email: true do it 'redirects to forgot_password path and sends an email to the user' do + allow(Figaro.env).to receive(:participate_in_dap).and_return('true') user = create(:user, :signed_up) visit root_path @@ -63,6 +64,7 @@ def reactivate_profile(password, recovery_code) open_last_email click_email_link_matching(/reset_password_token/) + expect(page.html).not_to include(t('notices.dap_html')) expect(current_path).to eq edit_user_password_path end end