Include timestamp in messages to user.
Permit email param in checkout_controller Fix failing tests
This commit is contained in:
parent
c6f416788c
commit
dd7e86930f
|
@ -45,7 +45,7 @@ module DiscourseDonations
|
||||||
end
|
end
|
||||||
|
|
||||||
if charge['paid'] == true
|
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: :group, name: group_name } if group_name
|
||||||
output['rewards'] << { type: :badge, name: badge_name } if badge_name
|
output['rewards'] << { type: :badge, name: badge_name } if badge_name
|
||||||
|
|
|
@ -28,7 +28,7 @@ module DiscourseDonations
|
||||||
end
|
end
|
||||||
|
|
||||||
if charge['paid']
|
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: :group, name: group_name } if group_name
|
||||||
output['rewards'] << { type: :badge, name: badge_name } if badge_name
|
output['rewards'] << { type: :badge, name: badge_name } if badge_name
|
||||||
end
|
end
|
||||||
|
@ -57,6 +57,7 @@ module DiscourseDonations
|
||||||
|
|
||||||
def user_params
|
def user_params
|
||||||
params.permit(:amount,
|
params.permit(:amount,
|
||||||
|
:email,
|
||||||
:stripeToken,
|
:stripeToken,
|
||||||
:stripeTokenType,
|
:stripeTokenType,
|
||||||
:stripeEmail,
|
:stripeEmail,
|
||||||
|
|
|
@ -18,7 +18,7 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super();
|
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('settings', getRegister(this).lookup('site-settings:main'));
|
||||||
this.set('create_accounts', this.get('anon') && this.get('settings').discourse_donations_enable_create_accounts);
|
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));
|
this.set('stripe', Stripe(this.get('settings').discourse_donations_public_key));
|
||||||
|
|
|
@ -34,14 +34,14 @@ module DiscourseDonations
|
||||||
|
|
||||||
it 'responds ok for anonymous users' do
|
it 'responds ok for anonymous users' do
|
||||||
post :create, params: { email: 'foobar@example.com' }
|
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)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not expect a username or email if accounts are not being created' do
|
it 'does not expect a username or email if accounts are not being created' do
|
||||||
current_user = log_in(:coding_horror)
|
current_user = log_in(:coding_horror)
|
||||||
post :create, params: { create_account: 'false' }
|
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)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ module DiscourseDonations
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'new user' do
|
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) }
|
before { SiteSetting.stubs(:discourse_donations_enable_create_accounts).returns(true) }
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Jobs::DonationUser, type: :job do
|
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
|
before do
|
||||||
SiteSetting.stubs(:enable_badges).returns(true)
|
SiteSetting.stubs(:enable_badges).returns(true)
|
||||||
|
|
Loading…
Reference in New Issue