GRN2-xx: Restructured email verification and password reset (#1444)

* Restructured email verification and password reset

* Fixed issue with password reset

Co-authored-by: Jesus Federico <jesus@123it.ca>
This commit is contained in:
Ahmad Farhat
2020-04-29 17:56:46 -04:00
committed by GitHub
parent 8f3ba8a038
commit 28302107bd
10 changed files with 46 additions and 81 deletions

View File

@ -35,8 +35,7 @@ describe AccountActivationsController, type: :controller do
it "renders the verify view if the user is not signed in and is not verified" do
user = create(:user, email_verified: false, provider: "greenlight")
user.create_activation_token
get :show, params: { token: user.activation_token }
get :show, params: { token: user.create_activation_token }
expect(response).to render_template(:show)
end
@ -46,8 +45,7 @@ describe AccountActivationsController, type: :controller do
it "activates a user if they have the correct activation token" do
@user = create(:user, email_verified: false, provider: "greenlight")
@user.create_activation_token
get :edit, params: { token: @user.activation_token }
get :edit, params: { token: @user.create_activation_token }
@user.reload
expect(@user.email_verified).to eq(true)
@ -64,8 +62,7 @@ describe AccountActivationsController, type: :controller do
it "does not allow the user to click the verify link again" do
@user = create(:user, provider: "greenlight")
@user.create_activation_token
get :edit, params: { token: @user.activation_token }
get :edit, params: { token: @user.create_activation_token }
expect(flash[:alert]).to be_present
expect(response).to redirect_to(root_path)
end
@ -75,8 +72,7 @@ describe AccountActivationsController, type: :controller do
@user.add_role :pending
@user.create_activation_token
get :edit, params: { token: @user.activation_token }
get :edit, params: { token: @user.create_activation_token }
expect(flash[:success]).to be_present
expect(response).to redirect_to(root_path)
@ -87,8 +83,8 @@ describe AccountActivationsController, type: :controller do
it "resends the email to the current user if the resend button is clicked" do
user = create(:user, email_verified: false, provider: "greenlight")
user.create_activation_token
expect { get :resend, params: { token: user.activation_token } }.to change { ActionMailer::Base.deliveries.count }.by(1)
expect { get :resend, params: { token: user.create_activation_token } }
.to change { ActionMailer::Base.deliveries.count }.by(1)
expect(flash[:success]).to be_present
expect(response).to redirect_to(root_path)
end
@ -96,8 +92,7 @@ describe AccountActivationsController, type: :controller do
it "redirects a verified user to the root path" do
user = create(:user, provider: "greenlight")
user.create_activation_token
get :resend, params: { token: user.activation_token }
get :resend, params: { token: user.create_activation_token }
expect(flash[:alert]).to be_present
expect(response).to redirect_to(root_path)