2023-02-21 16:55:31 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-14 09:01:27 -07: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
|
2023-04-19 07:07:29 -07:00
|
|
|
get :show
|
2017-06-14 09:01:27 -07:00
|
|
|
end
|
|
|
|
|
2023-11-10 07:13:42 -08:00
|
|
|
it 'renders confirmation page with private cache control headers', :aggregate_failures do
|
2018-04-21 12:35:07 -07:00
|
|
|
expect(response).to have_http_status(200)
|
2023-04-19 07:07:29 -07:00
|
|
|
expect(response.headers['Cache-Control']).to include('private, no-store')
|
|
|
|
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 01:48:50 -07:00
|
|
|
context 'when suspended' do
|
2022-01-27 15:46:42 -08: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 01:48:50 -07:00
|
|
|
|
2023-11-10 07:13:42 -08:00
|
|
|
it 'returns http forbidden with private cache control headers', :aggregate_failures do
|
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 01:48:50 -07:00
|
|
|
expect(response).to have_http_status(403)
|
2023-04-19 07:07:29 -07:00
|
|
|
expect(response.headers['Cache-Control']).to include('private, no-store')
|
|
|
|
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 01:48:50 -07:00
|
|
|
end
|
2017-06-14 09:01:27 -07: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 11:30:12 -07:00
|
|
|
delete :destroy, params: { form_delete_confirmation: { password: 'petsmoldoggos' } }
|
2017-06-14 09:01:27 -07:00
|
|
|
end
|
|
|
|
|
2024-07-08 09:01:08 -07:00
|
|
|
it 'removes user record and redirects', :aggregate_failures, :inline_jobs do
|
2017-06-14 09:01:27 -07:00
|
|
|
expect(response).to redirect_to '/auth/sign_in'
|
|
|
|
expect(User.find_by(id: user.id)).to be_nil
|
|
|
|
expect(user.account.reload).to be_suspended
|
2021-07-13 20:35:49 -07:00
|
|
|
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 01:48:50 -07:00
|
|
|
context 'when suspended' do
|
2022-01-27 15:46:42 -08: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 01:48:50 -07:00
|
|
|
|
|
|
|
it 'returns http forbidden' do
|
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
end
|
2017-06-14 09:01:27 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with incorrect password' do
|
|
|
|
before do
|
2017-06-14 11:30:12 -07:00
|
|
|
delete :destroy, params: { form_delete_confirmation: { password: 'blaze420' } }
|
2017-06-14 09:01:27 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects back to confirmation page' do
|
|
|
|
expect(response).to redirect_to settings_delete_path
|
|
|
|
end
|
|
|
|
end
|
2020-09-11 11:56:35 -07:00
|
|
|
end
|
2017-06-19 06:12:31 -07:00
|
|
|
|
2020-09-11 11:56:35 -07:00
|
|
|
context 'when not signed in' do
|
2017-06-19 06:12:31 -07:00
|
|
|
it 'redirects' do
|
|
|
|
delete :destroy
|
2020-09-11 11:56:35 -07:00
|
|
|
expect(response).to redirect_to '/auth/sign_in'
|
2017-06-19 06:12:31 -07:00
|
|
|
end
|
|
|
|
end
|
2017-06-14 09:01:27 -07:00
|
|
|
end
|
|
|
|
end
|