expect a username if an account is being created
This commit is contained in:
parent
4a2f13f32c
commit
6717317717
|
@ -9,6 +9,8 @@ module DiscourseDonations
|
|||
def create
|
||||
if email.nil?
|
||||
response = {'message' => 'Please enter your email address'}
|
||||
elsif create_account && params[:username].nil?
|
||||
response = {'message' => 'Please enter a username'}
|
||||
else
|
||||
Stripe.api_key = SiteSetting.discourse_donations_secret_key
|
||||
currency = SiteSetting.discourse_donations_currency
|
||||
|
@ -33,6 +35,10 @@ module DiscourseDonations
|
|||
|
||||
private
|
||||
|
||||
def create_account
|
||||
params[:create_account]
|
||||
end
|
||||
|
||||
def email
|
||||
params[:email] || current_user.try(:email)
|
||||
end
|
||||
|
|
|
@ -82,6 +82,8 @@ export default Ember.Component.extend({
|
|||
stripeToken: data.token.id,
|
||||
amount: self.get('amount') * 100,
|
||||
email: self.get('email'),
|
||||
username: self.get('username'),
|
||||
create_account: this.get('create_accounts')
|
||||
};
|
||||
|
||||
if(!self.get('paymentSuccess')) {
|
||||
|
|
|
@ -22,6 +22,12 @@ module DiscourseDonations
|
|||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'expects a username if accounts are being created' do
|
||||
post :create, { email: 'zipitydoodah@example.com', create_account: 'true' }
|
||||
expect(body['message']).to eq('Please enter a username')
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'responds ok for logged in user' do
|
||||
current_user = log_in(:coding_horror)
|
||||
post :create
|
||||
|
|
Loading…
Reference in New Issue