pluralize messages name space
This commit is contained in:
parent
e2a12a1b11
commit
53ebcf4625
|
@ -8,13 +8,13 @@ module DiscourseDonations
|
|||
|
||||
def create
|
||||
if create_account && (email.nil? || email.empty?)
|
||||
response = {'message' => 'Please enter your email address'}
|
||||
response = {'messages' => 'Please enter your email address'}
|
||||
elsif create_account && params[:username].nil?
|
||||
response = {'message' => 'Please enter a username'}
|
||||
response = {'messages' => 'Please enter a username'}
|
||||
else
|
||||
payment = DiscourseDonations::Stripe.new(secret_key, stripe_options)
|
||||
response = payment.charge(email, params)
|
||||
response['message'] = response['outcome']['seller_message']
|
||||
response['messages'] = response['outcome']['seller_message']
|
||||
end
|
||||
|
||||
response['rewards'] = []
|
||||
|
|
|
@ -58,7 +58,7 @@ export default Ember.Component.extend({
|
|||
|
||||
ajax('/users', { data: params, method: 'post' }).then(data => {
|
||||
self.setSuccess();
|
||||
self.set('result', self.get('result') + data.message);
|
||||
self.set('result', self.get('result') + data.messages);
|
||||
self.endTranscation();
|
||||
});
|
||||
});
|
||||
|
@ -88,7 +88,7 @@ export default Ember.Component.extend({
|
|||
|
||||
if(!self.get('paymentSuccess')) {
|
||||
ajax('/charges', { data: params, method: 'post' }).then(data => {
|
||||
self.set('result', data.message);
|
||||
self.set('result', data.messages);
|
||||
|
||||
if(!this.get('create_accounts')) {
|
||||
if(data.status == 'succeeded') { this.setSuccess() };
|
||||
|
|
|
@ -14,32 +14,32 @@ module DiscourseDonations
|
|||
|
||||
it 'responds ok for anonymous users' do
|
||||
post :create, { email: 'foobar@example.com' }
|
||||
expect(body['message']).to eq(body['outcome']['seller_message'])
|
||||
expect(body['messages']).to eq(body['outcome']['seller_message'])
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'responds ok when the email is empty' do
|
||||
post :create, { create_account: 'true', email: '' }
|
||||
expect(body['message']).to eq('Please enter your email address')
|
||||
expect(body['messages']).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: 'true' }
|
||||
expect(body['message']).to eq('Please enter your email address')
|
||||
expect(body['messages']).to eq('Please enter your email address')
|
||||
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(body['messages']).to eq('Please enter a username')
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'does not expect a username or email if accounts are not being created' do
|
||||
current_user = log_in(:coding_horror)
|
||||
post :create, { create_account: 'false' }
|
||||
expect(body['message']).to eq('Payment complete.')
|
||||
expect(body['messages']).to eq('Payment complete.')
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue