2023-02-21 19:55:31 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-14 12:01:27 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Settings::DeletesController do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
describe 'GET #show' do
|
|
|
|
context 'when signed in' do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in user, scope: :user
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders confirmation page' do
|
|
|
|
get :show
|
2018-04-21 15:35:07 -04:00
|
|
|
expect(response).to have_http_status(200)
|
2017-06-14 12:01:27 -04:00
|
|
|
end
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 04:48:50 -04:00
|
|
|
|
|
|
|
context 'when suspended' do
|
2022-01-27 18:46:42 -05:00
|
|
|
let(:user) { Fabricate(:user, account_attributes: { suspended_at: Time.now.utc }) }
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 04:48:50 -04:00
|
|
|
|
|
|
|
it 'returns http forbidden' do
|
|
|
|
get :show
|
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
end
|
2017-06-14 12:01:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when not signed in' do
|
|
|
|
it 'redirects' do
|
|
|
|
get :show
|
|
|
|
expect(response).to redirect_to '/auth/sign_in'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'DELETE #destroy' do
|
|
|
|
context 'when signed in' do
|
|
|
|
let(:user) { Fabricate(:user, password: 'petsmoldoggos') }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in user, scope: :user
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with correct password' do
|
|
|
|
before do
|
2017-06-14 14:30:12 -04:00
|
|
|
delete :destroy, params: { form_delete_confirmation: { password: 'petsmoldoggos' } }
|
2017-06-14 12:01:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to sign in page' do
|
|
|
|
expect(response).to redirect_to '/auth/sign_in'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes user record' do
|
|
|
|
expect(User.find_by(id: user.id)).to be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'marks account as suspended' do
|
|
|
|
expect(user.account.reload).to be_suspended
|
|
|
|
end
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 04:48:50 -04:00
|
|
|
|
2021-07-13 23:35:49 -04:00
|
|
|
it 'does not create an email block' do
|
|
|
|
expect(CanonicalEmailBlock.block?(user.email)).to be false
|
|
|
|
end
|
|
|
|
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 04:48:50 -04:00
|
|
|
context 'when suspended' do
|
2022-01-27 18:46:42 -05:00
|
|
|
let(:user) { Fabricate(:user, account_attributes: { suspended_at: Time.now.utc }) }
|
Change unconfirmed user login behaviour (#11375)
Allow access to account settings, 2FA, authorized applications, and
account deletions to unconfirmed and pending users, as well as
users who had their accounts disabled. Suspended users cannot update
their e-mail or password or delete their account.
Display account status on account settings page, for example, when
an account is frozen, limited, unconfirmed or pending review.
After sign up, login users straight away and show a simple page that
tells them the status of their account with links to account settings
and logout, to reduce onboarding friction and allow users to correct
wrongly typed e-mail addresses.
Move the final sign-up step of SSO integrations to be the same
as above to reduce code duplication.
2019-07-22 04:48:50 -04:00
|
|
|
|
|
|
|
it 'returns http forbidden' do
|
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
end
|
2017-06-14 12:01:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with incorrect password' do
|
|
|
|
before do
|
2017-06-14 14:30:12 -04:00
|
|
|
delete :destroy, params: { form_delete_confirmation: { password: 'blaze420' } }
|
2017-06-14 12:01:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects back to confirmation page' do
|
|
|
|
expect(response).to redirect_to settings_delete_path
|
|
|
|
end
|
|
|
|
end
|
2020-09-11 14:56:35 -04:00
|
|
|
end
|
2017-06-19 09:12:31 -04:00
|
|
|
|
2020-09-11 14:56:35 -04:00
|
|
|
context 'when not signed in' do
|
2017-06-19 09:12:31 -04:00
|
|
|
it 'redirects' do
|
|
|
|
delete :destroy
|
2020-09-11 14:56:35 -04:00
|
|
|
expect(response).to redirect_to '/auth/sign_in'
|
2017-06-19 09:12:31 -04:00
|
|
|
end
|
|
|
|
end
|
2017-06-14 12:01:27 -04:00
|
|
|
end
|
|
|
|
end
|