use translations for missing params

This commit is contained in:
Rimian Perkins 2017-05-04 20:11:26 +10:00
parent 4fe5a0462a
commit cc46445b24
2 changed files with 6 additions and 8 deletions

View File

@ -10,12 +10,10 @@ module DiscourseDonations
output = { 'messages' => [], 'rewards' => [] }
if create_account
if (email.nil? || email.empty?)
output['messages'] << 'Please enter your email address'
if !email.present? || params[:username].nil?
output['messages'] << I18n.t('login.missing_user_field')
end
if params[:username].nil?
output['messages'] << 'Please enter a username'
elsif ::User.reserved_username?(params[:username])
if params[:username].present? && ::User.reserved_username?(params[:username])
output['messages'] << I18n.t('login.reserved_username')
end
end

View File

@ -20,7 +20,7 @@ module DiscourseDonations
it 'expects a username if accounts are being created' do
post :create, { email: 'zipitydoodah@example.com', create_account: 'true' }
expect(body['messages']).to include('Please enter a username')
expect(body['messages']).to include(I18n.t('login.missing_user_field'))
expect(response).to have_http_status(200)
end
@ -34,12 +34,12 @@ module DiscourseDonations
describe 'new user' do
it 'has a message when the email is empty' do
post :create, { create_account: 'true', email: '' }
expect(body['messages']).to include('Please enter your email address')
expect(body['messages']).to include(I18n.t('login.missing_user_field'))
end
it 'has a message when the email is empty' do
post :create, { create_account: 'true' }
expect(body['messages']).to include('Please enter your email address')
expect(body['messages']).to include(I18n.t('login.missing_user_field'))
end
it 'has a message when the username is reserved' do