forked from External/greenlight
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:
committed by
Jesus Federico
parent
5521402ee7
commit
c60e25f71c
@ -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)
|
||||
|
Reference in New Issue
Block a user