check email is not empty

This commit is contained in:
Rimian Perkins 2017-04-04 14:34:33 +10:00
parent 6717317717
commit aaff445019
2 changed files with 8 additions and 2 deletions

View File

@ -7,7 +7,7 @@ module DiscourseDonations
skip_before_filter :verify_authenticity_token, only: [:create]
def create
if email.nil?
if email.nil? || email.empty?
response = {'message' => 'Please enter your email address'}
elsif create_account && params[:username].nil?
response = {'message' => 'Please enter a username'}

View File

@ -17,7 +17,13 @@ module DiscourseDonations
end
it 'responds ok when the email is empty' do
post :create, { }
post :create, { create_account: 'true', email: '' }
expect(body['message']).to eq('Please enter your email address')
expect(response).to have_http_status(200)
end
it 'responds ok when the email is empty' do
post :create, { create_account: 'false' }
expect(body['message']).to eq('Please enter your email address')
expect(response).to have_http_status(200)
end