diff --git a/app/controllers/auth/setup_controller.rb b/app/controllers/auth/setup_controller.rb index ad872dc607..376a30c16f 100644 --- a/app/controllers/auth/setup_controller.rb +++ b/app/controllers/auth/setup_controller.rb @@ -18,7 +18,7 @@ class Auth::SetupController < ApplicationController if @user.update(user_params) @user.resend_confirmation_instructions unless @user.confirmed? - redirect_to auth_setup_path, notice: I18n.t('auth.setup.new_confirmation_instructions_sent') + redirect_to auth_setup_path, notice: t('auth.setup.new_confirmation_instructions_sent') else render :show end diff --git a/spec/controllers/auth/setup_controller_spec.rb b/spec/controllers/auth/setup_controller_spec.rb deleted file mode 100644 index 28b07cb4b2..0000000000 --- a/spec/controllers/auth/setup_controller_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe Auth::SetupController do - render_views - - describe 'GET #show' do - context 'with a signed out request' do - it 'returns http redirect' do - get :show - expect(response).to be_redirect - end - end - - context 'with an unconfirmed signed in user' do - before { sign_in Fabricate(:user, confirmed_at: nil) } - - it 'returns http success' do - get :show - expect(response).to have_http_status(200) - end - end - end -end diff --git a/spec/requests/auth/setup_spec.rb b/spec/requests/auth/setup_spec.rb new file mode 100644 index 0000000000..fa3c196805 --- /dev/null +++ b/spec/requests/auth/setup_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Auth Setup' do + describe 'GET /auth/setup' do + context 'with a signed out request' do + it 'redirects to root' do + get '/auth/setup' + + expect(response) + .to redirect_to(new_user_session_url) + end + end + + context 'with a confirmed signed in user' do + before { sign_in Fabricate(:user, confirmed_at: 2.days.ago) } + + it 'redirects to root' do + get '/auth/setup' + + expect(response) + .to redirect_to(root_url) + end + end + end +end diff --git a/spec/system/auth/setup_spec.rb b/spec/system/auth/setup_spec.rb new file mode 100644 index 0000000000..154f8cd5fa --- /dev/null +++ b/spec/system/auth/setup_spec.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Auth Setup' do + context 'with an unconfirmed signed in user' do + let(:user) { Fabricate(:user, confirmed_at: nil) } + + before { sign_in(user) } + + it 'can update email address' do + visit auth_setup_path + + expect(page) + .to have_content(I18n.t('auth.setup.title')) + + find('summary.lead').click + fill_in 'user_email', with: 'new-email@example.host' + + expect { submit_form } + .to(change { user.reload.unconfirmed_email }) + expect(page) + .to have_content(I18n.t('auth.setup.new_confirmation_instructions_sent')) + end + + def submit_form + find('[name=button]').click + end + end +end