mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-02-03 05:23:18 -05:00
Convert auth/setup
spec controller->system/request (#33604)
This commit is contained in:
parent
72abf05269
commit
998cf0dd53
@ -18,7 +18,7 @@ class Auth::SetupController < ApplicationController
|
|||||||
|
|
||||||
if @user.update(user_params)
|
if @user.update(user_params)
|
||||||
@user.resend_confirmation_instructions unless @user.confirmed?
|
@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
|
else
|
||||||
render :show
|
render :show
|
||||||
end
|
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…
x
Reference in New Issue
Block a user