0
0
Fork 0

Fix RSpec/NoExpectationExample cop (#25103)

This commit is contained in:
Matt Jankowski 2023-05-26 03:41:12 -04:00 committed by GitHub
parent 38c6216082
commit 0f2c16ac4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 11 deletions

View file

@ -244,9 +244,26 @@ RSpec.describe Auth::RegistrationsController do
end
end
it 'does nothing if user already exists' do
Fabricate(:account, username: 'test')
subject
context 'with an already taken username' do
subject do
Setting.registrations_mode = 'open'
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
end
before do
Fabricate(:account, username: 'test')
end
it 'responds with an error message about the username' do
subject
expect(response).to have_http_status(:success)
expect(username_error_text).to eq(I18n.t('errors.messages.taken'))
end
def username_error_text
Nokogiri::Slop(response.body).css('.user_account_username .error').text
end
end
include_examples 'checks for enabled registrations', :create