Convert auth/setup spec controller->system/request (#33604)

This commit is contained in:
Matt Jankowski 2025-01-16 04:03:46 -05:00 committed by GitHub
parent 72abf05269
commit 998cf0dd53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 58 additions and 26 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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