2017-06-15 02:01:27 +10: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-22 05:35:07 +10:00
|
|
|
expect(response).to have_http_status(200)
|
2017-06-15 02:01:27 +10: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 18:48:50 +10:00
|
|
|
|
|
|
|
context 'when suspended' do
|
2022-01-28 10:46:42 +11: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 18:48:50 +10:00
|
|
|
|
|
|
|
it 'returns http forbidden' do
|
|
|
|
get :show
|
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
end
|
2017-06-15 02:01:27 +10: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-15 04:30:12 +10:00
|
|
|
delete :destroy, params: { form_delete_confirmation: { password: 'petsmoldoggos' } }
|
2017-06-15 02:01:27 +10: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 18:48:50 +10:00
|
|
|
|
2021-07-14 13:35:49 +10: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 18:48:50 +10:00
|
|
|
context 'when suspended' do
|
2022-01-28 10:46:42 +11: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 18:48:50 +10:00
|
|
|
|
|
|
|
it 'returns http forbidden' do
|
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
end
|
2017-06-15 02:01:27 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with incorrect password' do
|
|
|
|
before do
|
2017-06-15 04:30:12 +10:00
|
|
|
delete :destroy, params: { form_delete_confirmation: { password: 'blaze420' } }
|
2017-06-15 02:01:27 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects back to confirmation page' do
|
|
|
|
expect(response).to redirect_to settings_delete_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-09-12 04:56:35 +10:00
|
|
|
context 'when account deletions are disabled' do
|
|
|
|
around do |example|
|
|
|
|
open_deletion = Setting.open_deletion
|
|
|
|
example.run
|
|
|
|
Setting.open_deletion = open_deletion
|
|
|
|
end
|
2017-06-19 23:12:31 +10:00
|
|
|
|
2020-09-12 04:56:35 +10:00
|
|
|
it 'redirects' do
|
|
|
|
Setting.open_deletion = false
|
|
|
|
delete :destroy
|
|
|
|
expect(response).to redirect_to root_path
|
|
|
|
end
|
2017-06-19 23:12:31 +10:00
|
|
|
end
|
2020-09-12 04:56:35 +10:00
|
|
|
end
|
2017-06-19 23:12:31 +10:00
|
|
|
|
2020-09-12 04:56:35 +10:00
|
|
|
context 'when not signed in' do
|
2017-06-19 23:12:31 +10:00
|
|
|
it 'redirects' do
|
|
|
|
delete :destroy
|
2020-09-12 04:56:35 +10:00
|
|
|
expect(response).to redirect_to '/auth/sign_in'
|
2017-06-19 23:12:31 +10:00
|
|
|
end
|
|
|
|
end
|
2017-06-15 02:01:27 +10:00
|
|
|
end
|
|
|
|
end
|