diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-06-14 18:01:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-14 18:01:27 +0200 |
commit | 4a618908e836ecb94f70e99f2198ee7b3ba3b2ec (patch) | |
tree | f2a02c2deaf9c1af2b53dae705cc652f83e08db7 /spec/controllers/settings | |
parent | a208e7d65581168cda04be543742f302a162ac1a (diff) |
Account deletion (#3728)
* Add form for account deletion * If avatar or header are gone from source, remove them * Add option to have SuspendAccountService remove user record, add tests * Exclude suspended accounts from search
Diffstat (limited to 'spec/controllers/settings')
-rw-r--r-- | spec/controllers/settings/deletes_controller_spec.rb | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/spec/controllers/settings/deletes_controller_spec.rb b/spec/controllers/settings/deletes_controller_spec.rb new file mode 100644 index 000000000..c9e163261 --- /dev/null +++ b/spec/controllers/settings/deletes_controller_spec.rb @@ -0,0 +1,72 @@ +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 + expect(response).to have_http_status(:success) + end + 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 + delete :destroy, params: { password: 'petsmoldoggos' } + 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 + end + + context 'with incorrect password' do + before do + delete :destroy, params: { password: 'blaze420' } + end + + it 'redirects back to confirmation page' do + expect(response).to redirect_to settings_delete_path + end + end + end + + context 'when not signed in' do + it 'redirects' do + delete :destroy + expect(response).to redirect_to '/auth/sign_in' + end + end + end +end |