logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

confirmations_controller_spec.rb (1620B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Auth::ConfirmationsController, type: :controller do
  4. describe 'GET #new' do
  5. it 'returns http success' do
  6. @request.env['devise.mapping'] = Devise.mappings[:user]
  7. get :new
  8. expect(response).to have_http_status(:success)
  9. end
  10. end
  11. describe 'GET #show' do
  12. context 'when user is unconfirmed' do
  13. let!(:user) { Fabricate(:user, confirmation_token: 'foobar', confirmed_at: nil) }
  14. before do
  15. allow(BootstrapTimelineWorker).to receive(:perform_async)
  16. @request.env['devise.mapping'] = Devise.mappings[:user]
  17. get :show, params: { confirmation_token: 'foobar' }
  18. end
  19. it 'redirects to login' do
  20. expect(response).to redirect_to(new_user_session_path)
  21. end
  22. it 'queues up bootstrapping of home timeline' do
  23. expect(BootstrapTimelineWorker).to have_received(:perform_async).with(user.account_id)
  24. end
  25. end
  26. context 'when user is updating email' do
  27. let!(:user) { Fabricate(:user, confirmation_token: 'foobar', unconfirmed_email: 'new-email@example.com') }
  28. before do
  29. allow(BootstrapTimelineWorker).to receive(:perform_async)
  30. @request.env['devise.mapping'] = Devise.mappings[:user]
  31. get :show, params: { confirmation_token: 'foobar' }
  32. end
  33. it 'redirects to login' do
  34. expect(response).to redirect_to(new_user_session_path)
  35. end
  36. it 'does not queue up bootstrapping of home timeline' do
  37. expect(BootstrapTimelineWorker).to_not have_received(:perform_async)
  38. end
  39. end
  40. end
  41. end