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)
context 'when not signed in' do
it 'redirects' do
expect(response).to redirect_to '/auth/sign_in'
describe 'DELETE #destroy' do
let(:user) { Fabricate(:user, password: 'petsmoldoggos') }
context 'with correct password' do
delete :destroy, params: { form_delete_confirmation: { password: 'petsmoldoggos' } }
it 'redirects to sign in page' do
it 'removes user record' do
expect(User.find_by(id: user.id)).to be_nil
it 'marks account as suspended' do
expect(user.account.reload).to be_suspended
context 'with incorrect password' do
delete :destroy, params: { form_delete_confirmation: { password: 'blaze420' } }
it 'redirects back to confirmation page' do
expect(response).to redirect_to settings_delete_path
delete :destroy