check account create and email is not empty
This commit is contained in:
parent
aaff445019
commit
906952a11a
|
@ -7,7 +7,7 @@ module DiscourseDonations
|
|||
skip_before_filter :verify_authenticity_token, only: [:create]
|
||||
|
||||
def create
|
||||
if email.nil? || email.empty?
|
||||
if create_account && (email.nil? || email.empty?)
|
||||
response = {'message' => 'Please enter your email address'}
|
||||
elsif create_account && params[:username].nil?
|
||||
response = {'message' => 'Please enter a username'}
|
||||
|
@ -36,7 +36,7 @@ module DiscourseDonations
|
|||
private
|
||||
|
||||
def create_account
|
||||
params[:create_account]
|
||||
params[:create_account] == 'true'
|
||||
end
|
||||
|
||||
def email
|
||||
|
|
|
@ -23,7 +23,7 @@ module DiscourseDonations
|
|||
end
|
||||
|
||||
it 'responds ok when the email is empty' do
|
||||
post :create, { create_account: 'false' }
|
||||
post :create, { create_account: 'true' }
|
||||
expect(body['message']).to eq('Please enter your email address')
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
@ -34,10 +34,10 @@ module DiscourseDonations
|
|||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'responds ok for logged in user' do
|
||||
it 'does not expect a username or email if accounts are not being created' do
|
||||
current_user = log_in(:coding_horror)
|
||||
post :create
|
||||
expect(body['message']).to eq(body['outcome']['seller_message'])
|
||||
post :create, { create_account: 'false' }
|
||||
expect(body['message']).to eq('Payment complete.')
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue