GRN-56: Correctly implemented the account verification flow (#367)

* Correctly implemented the account verification flow

* Fixed issues with redirect locations
This commit is contained in:
farhatahmad
2019-02-22 16:47:02 -05:00
committed by Jesus Federico
parent 5521402ee7
commit c60e25f71c
17 changed files with 337 additions and 141 deletions

View File

@ -166,72 +166,6 @@ describe UsersController, type: :controller do
end
end
describe "GET | POST #resend" do
before { allow(Rails.configuration).to receive(:allow_user_signup).and_return(true) }
before { allow(Rails.configuration).to receive(:enable_email_verification).and_return(true) }
it "redirects to main room if verified" do
params = random_valid_user_params
post :create, params: params
u = User.find_by(name: params[:user][:name], email: params[:user][:email])
u.email_verified = false
get :resend
expect(response).to render_template(:verify)
end
it "resend email upon click if unverified" do
params = random_valid_user_params
post :create, params: params
u = User.find_by(name: params[:user][:name], email: params[:user][:email])
u.email_verified = false
expect { post :resend, params: { email_verified: false } }.to change { ActionMailer::Base.deliveries.count }.by(1)
expect(response).to render_template(:verify)
end
it "should raise if there there is a delivery failure" do
params = random_valid_user_params
post :create, params: params
u = User.find_by(name: params[:user][:name], email: params[:user][:email])
u.email_verified = false
expect do
post :resend, params: { email_verified: false }
raise Net::SMTPAuthenticationError
end.to raise_error { Net::SMTPAuthenticationError }
end
end
describe "GET | POST #confirm" do
before { allow(Rails.configuration).to receive(:allow_user_signup).and_return(true) }
before { allow(Rails.configuration).to receive(:enable_email_verification).and_return(true) }
it "redirects to main room if already verified" do
params = random_valid_user_params
post :create, params: params
u = User.find_by(name: params[:user][:name], email: params[:user][:email])
post :confirm, params: { user_uid: u.uid, email_verified: true }
expect(response).to redirect_to(room_path(u.main_room))
end
it "renders confirmation pane if unverified" do
params = random_valid_user_params
post :create, params: params
u = User.find_by(name: params[:user][:name], email: params[:user][:email])
u.email_verified = false
get :confirm, params: { user_uid: u.uid }
expect(response).to render_template(:verify)
end
end
describe "GET #recordings" do
before do
@user1 = create(:user)