Include timestamp in messages to user.

Permit email param in checkout_controller
Fix failing tests
This commit is contained in:
Chris Beach 2018-01-18 00:21:41 +00:00
parent c6f416788c
commit dd7e86930f
5 changed files with 8 additions and 7 deletions

View File

@ -45,7 +45,7 @@ module DiscourseDonations
end
if charge['paid'] == true
output['messages'] << I18n.t('donations.payment.success')
output['messages'] << I18n.l(Time.now(), format: :long) + ': ' + I18n.t('donations.payment.success')
output['rewards'] << { type: :group, name: group_name } if group_name
output['rewards'] << { type: :badge, name: badge_name } if badge_name

View File

@ -28,7 +28,7 @@ module DiscourseDonations
end
if charge['paid']
output['messages'] << I18n.t('donations.payment.success')
output['messages'] << I18n.l(Time.now(), format: :long) + ': ' + I18n.t('donations.payment.success')
output['rewards'] << { type: :group, name: group_name } if group_name
output['rewards'] << { type: :badge, name: badge_name } if badge_name
end
@ -57,6 +57,7 @@ module DiscourseDonations
def user_params
params.permit(:amount,
:email,
:stripeToken,
:stripeTokenType,
:stripeEmail,

View File

@ -18,7 +18,7 @@ export default Ember.Component.extend({
init() {
this._super();
this.set('anon', (Discourse.User.current() == null));
this.set('anon', (!Discourse.User.current()));
this.set('settings', getRegister(this).lookup('site-settings:main'));
this.set('create_accounts', this.get('anon') && this.get('settings').discourse_donations_enable_create_accounts);
this.set('stripe', Stripe(this.get('settings').discourse_donations_public_key));

View File

@ -34,14 +34,14 @@ module DiscourseDonations
it 'responds ok for anonymous users' do
post :create, params: { email: 'foobar@example.com' }
expect(body['messages']).to include(I18n.t('donations.payment.success'))
expect(body['messages'][0]).to end_with(I18n.t('donations.payment.success'))
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, params: { create_account: 'false' }
expect(body['messages']).to include(I18n.t('donations.payment.success'))
expect(body['messages'][0]).to end_with(I18n.t('donations.payment.success'))
expect(response).to have_http_status(200)
end
@ -129,7 +129,7 @@ module DiscourseDonations
end
describe 'new user' do
let(:params) { { create_account: 'true', email: 'dood@example.com', password: 'secret', name: 'dood', username: 'mr-dood' } }
let(:params) { { create_account: 'true', email: 'dood@example.com', password: 'secretsecret', name: 'dood', username: 'mr-dood' } }
before { SiteSetting.stubs(:discourse_donations_enable_create_accounts).returns(true) }

View File

@ -1,7 +1,7 @@
require 'rails_helper'
RSpec.describe Jobs::DonationUser, type: :job do
let(:args) { { email: 'captain-sensible@example.com', username: 'wot', name: 'captain', password: 'wot' } }
let(:args) { { email: 'captain-sensible@example.com', username: 'wot', name: 'captain', password: 'secret121321' } }
before do
SiteSetting.stubs(:enable_badges).returns(true)