mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2025-01-18 12:44:04 +01:00
Convert auth/setup
spec controller->system/request (#33604)
This commit is contained in:
parent
72abf05269
commit
998cf0dd53
4 changed files with 58 additions and 26 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
27
spec/requests/auth/setup_spec.rb
Normal file
27
spec/requests/auth/setup_spec.rb
Normal 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
|
30
spec/system/auth/setup_spec.rb
Normal file
30
spec/system/auth/setup_spec.rb
Normal 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
|
Loading…
Reference in a new issue