feat: Show a confirmation banner if the email is not verified (#8808)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Shivam Mishra
2024-02-03 02:01:29 +05:30
committed by GitHub
parent 07ea9694a3
commit 0c35a77d4b
11 changed files with 123 additions and 3 deletions

View File

@@ -242,4 +242,44 @@ RSpec.describe 'Profile API', type: :request do
end
end
end
describe 'POST /api/v1/profile/resend_confirmation' do
context 'when it is an unauthenticated user' do
it 'returns unauthorized' do
post '/api/v1/profile/resend_confirmation'
expect(response).to have_http_status(:unauthorized)
end
end
context 'when it is an authenticated user' do
let(:agent) do
create(:user, password: 'Test123!', email: 'test-unconfirmed@email.com', account: account, role: :agent,
unconfirmed_email: 'test-unconfirmed@email.com')
end
it 'does not send the confirmation email if the user is already confirmed' do
expect do
post '/api/v1/profile/resend_confirmation',
headers: agent.create_new_auth_token,
as: :json
end.not_to have_enqueued_mail(Devise::Mailer, :confirmation_instructions)
expect(response).to have_http_status(:success)
end
it 'resends the confirmation email if the user is unconfirmed' do
agent.confirmed_at = nil
agent.save!
expect do
post '/api/v1/profile/resend_confirmation',
headers: agent.create_new_auth_token,
as: :json
end.to have_enqueued_mail(Devise::Mailer, :confirmation_instructions)
expect(response).to have_http_status(:success)
end
end
end
end