2023-02-22 01:55:31 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-14 18:01:27 +02:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-09-04 07:12:25 +02:00
|
|
|
RSpec.describe Settings::DeletesController do
|
2017-06-14 18:01:27 +02:00
|
|
|
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 16:07:29 +02:00
|
|
|
get :show
|
2017-06-14 18:01:27 +02:00
|
|
|
end
|
|
|
|
|
2023-11-10 16:13:42 +01:00
|
|
|
it 'renders confirmation page with private cache control headers', :aggregate_failures do
|
2018-04-21 21:35:07 +02:00
|
|
|
expect(response).to have_http_status(200)
|
2023-04-19 16:07:29 +02: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 10:48:50 +02:00
|
|
|
context 'when suspended' do
|
2022-01-28 00:46:42 +01: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 10:48:50 +02:00
|
|
|
|
2023-11-10 16:13:42 +01: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 10:48:50 +02:00
|
|
|
expect(response).to have_http_status(403)
|
2023-04-19 16:07:29 +02: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 10:48:50 +02:00
|
|
|
end
|
2017-06-14 18:01:27 +02: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 20:30:12 +02:00
|
|
|
delete :destroy, params: { form_delete_confirmation: { password: 'petsmoldoggos' } }
|
2017-06-14 18:01:27 +02:00
|
|
|
end
|
|
|
|
|
2024-07-08 18:01:08 +02:00
|
|
|
it 'removes user record and redirects', :aggregate_failures, :inline_jobs do
|
2017-06-14 18:01:27 +02: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-14 05:35:49 +02: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 10:48:50 +02:00
|
|
|
context 'when suspended' do
|
2022-01-28 00:46:42 +01: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 10:48:50 +02:00
|
|
|
|
|
|
|
it 'returns http forbidden' do
|
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
end
|
2017-06-14 18:01:27 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with incorrect password' do
|
|
|
|
before do
|
2017-06-14 20:30:12 +02:00
|
|
|
delete :destroy, params: { form_delete_confirmation: { password: 'blaze420' } }
|
2017-06-14 18:01:27 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects back to confirmation page' do
|
|
|
|
expect(response).to redirect_to settings_delete_path
|
|
|
|
end
|
|
|
|
end
|
2020-09-11 20:56:35 +02:00
|
|
|
end
|
2017-06-19 15:12:31 +02:00
|
|
|
|
2020-09-11 20:56:35 +02:00
|
|
|
context 'when not signed in' do
|
2017-06-19 15:12:31 +02:00
|
|
|
it 'redirects' do
|
|
|
|
delete :destroy
|
2020-09-11 20:56:35 +02:00
|
|
|
expect(response).to redirect_to '/auth/sign_in'
|
2017-06-19 15:12:31 +02:00
|
|
|
end
|
|
|
|
end
|
2017-06-14 18:01:27 +02:00
|
|
|
end
|
|
|
|
end
|