1
0

sessions_controller_spec.rb 854 B

123456789101112131415161718192021222324252627282930313233
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Settings::SessionsController do
  4. render_views
  5. let(:user) { Fabricate(:user) }
  6. let(:session_activation) { Fabricate(:session_activation, user: user) }
  7. before { sign_in user, scope: :user }
  8. describe 'DELETE #destroy' do
  9. subject { delete :destroy, params: { id: id } }
  10. context 'when session activation exists' do
  11. let(:id) { session_activation.id }
  12. it 'destroys session activation' do
  13. expect(subject).to redirect_to edit_user_registration_path
  14. expect(SessionActivation.find_by(id: id)).to be_nil
  15. end
  16. end
  17. context 'when session activation does not exist' do
  18. let(:id) { session_activation.id + 1000 }
  19. it 'destroys session activation' do
  20. expect(subject).to have_http_status 404
  21. end
  22. end
  23. end
  24. end