]> cat aescling's git repositories - mastodon.git/blob - spec/controllers/auth/confirmations_controller_spec.rb
Change unconfirmed user login behaviour (#11375)
[mastodon.git] / spec / controllers / auth / confirmations_controller_spec.rb
1 # frozen_string_literal: true
2
3 require 'rails_helper'
4
5 describe Auth::ConfirmationsController, type: :controller do
6 render_views
7
8 describe 'GET #new' do
9 it 'returns http success' do
10 @request.env['devise.mapping'] = Devise.mappings[:user]
11 get :new
12 expect(response).to have_http_status(200)
13 end
14 end
15
16 describe 'GET #show' do
17 context 'when user is unconfirmed' do
18 let!(:user) { Fabricate(:user, confirmation_token: 'foobar', confirmed_at: nil) }
19
20 before do
21 allow(BootstrapTimelineWorker).to receive(:perform_async)
22 @request.env['devise.mapping'] = Devise.mappings[:user]
23 get :show, params: { confirmation_token: 'foobar' }
24 end
25
26 it 'redirects to login' do
27 expect(response).to redirect_to(new_user_session_path)
28 end
29
30 it 'queues up bootstrapping of home timeline' do
31 expect(BootstrapTimelineWorker).to have_received(:perform_async).with(user.account_id)
32 end
33 end
34
35 context 'when user is updating email' do
36 let!(:user) { Fabricate(:user, confirmation_token: 'foobar', unconfirmed_email: 'new-email@example.com') }
37
38 before do
39 allow(BootstrapTimelineWorker).to receive(:perform_async)
40 @request.env['devise.mapping'] = Devise.mappings[:user]
41 get :show, params: { confirmation_token: 'foobar' }
42 end
43
44 it 'redirects to login' do
45 expect(response).to redirect_to(new_user_session_path)
46 end
47
48 it 'does not queue up bootstrapping of home timeline' do
49 expect(BootstrapTimelineWorker).to_not have_received(:perform_async)
50 end
51 end
52 end
53 end
This page took 0.22057 seconds and 4 git commands to generate.