0
0
Fork 0

Add polling and automatic redirection to /start on email confirmation (#25013)

This commit is contained in:
Claire 2023-05-16 18:03:52 +02:00 committed by GitHub
parent 2ce0b666a1
commit e60414792d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 3 deletions

View file

@ -63,4 +63,72 @@ RSpec.describe Api::V1::Emails::ConfirmationsController do
end
end
end
describe '#check' do
let(:scopes) { 'read' }
context 'with an oauth token' do
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
context 'when the account is not confirmed' do
it 'returns http success' do
get :check
expect(response).to have_http_status(200)
end
it 'returns false' do
get :check
expect(body_as_json).to be false
end
end
context 'when the account is confirmed' do
let(:confirmed_at) { Time.now.utc }
it 'returns http success' do
get :check
expect(response).to have_http_status(200)
end
it 'returns true' do
get :check
expect(body_as_json).to be true
end
end
end
context 'with an authentication cookie' do
before do
sign_in user, scope: :user
end
context 'when the account is not confirmed' do
it 'returns http success' do
get :check
expect(response).to have_http_status(200)
end
it 'returns false' do
get :check
expect(body_as_json).to be false
end
end
context 'when the account is confirmed' do
let(:confirmed_at) { Time.now.utc }
it 'returns http success' do
get :check
expect(response).to have_http_status(200)
end
it 'returns true' do
get :check
expect(body_as_json).to be true
end
end
end
end
end