diff options
author | Matt Jankowski <mjankowski@thoughtbot.com> | 2017-05-02 17:37:58 -0400 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-02 23:37:58 +0200 |
commit | 268dd32d76b42dc1f2a044cedeee5446cb9185c2 (patch) | |
tree | 874d18715a1c47a575aabf657256b68cf1595ee9 /spec | |
parent | bea97ea76638552e437a3b6d6f48040449849448 (diff) |
Auth sign out (#2511)
* Add a spec for signing out * Add spec showing that suspended user gets a 403 forbidden on sign out * Allow suspended account users to sign out
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/auth/sessions_controller_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb index 393908d97..a2298180a 100644 --- a/spec/controllers/auth/sessions_controller_spec.rb +++ b/spec/controllers/auth/sessions_controller_spec.rb @@ -16,6 +16,33 @@ RSpec.describe Auth::SessionsController, type: :controller do end end + describe 'DELETE #destroy' do + let(:user) { Fabricate(:user) } + + before do + request.env['devise.mapping'] = Devise.mappings[:user] + end + + context 'with a regular user' do + it 'redirects to home after sign out' do + sign_in(user, scope: :user) + delete :destroy + + expect(response).to redirect_to(root_path) + end + end + + context 'with a suspended user' do + it 'redirects to home after sign out' do + Fabricate(:account, user: user, suspended: true) + sign_in(user, scope: :user) + delete :destroy + + expect(response).to redirect_to(root_path) + end + end + end + describe 'POST #create' do before do request.env['devise.mapping'] = Devise.mappings[:user] |