From b8130f9969fa406a52c50116c3fc51cb78b70cae Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Thu, 18 May 2017 12:02:26 +1000 Subject: [PATCH] Revert "use site setting instead of params for create account" This reverts commit 05c31f19099af7c981702590ed980632782c17bd. * also test the create account setting cannot be overwritten --- .../discourse_donations/charges_controller.rb | 2 +- disource-donations | 1 - .../discourse_donations/charges_controller_spec.rb | 13 +++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) delete mode 120000 disource-donations diff --git a/app/controllers/discourse_donations/charges_controller.rb b/app/controllers/discourse_donations/charges_controller.rb index 66e0624..9efc1a9 100644 --- a/app/controllers/discourse_donations/charges_controller.rb +++ b/app/controllers/discourse_donations/charges_controller.rb @@ -48,7 +48,7 @@ module DiscourseDonations private def create_account - SiteSetting.discourse_donations_enable_create_accounts + params[:create_account] == 'true' && SiteSetting.discourse_donations_enable_create_accounts end def reward?(payment) diff --git a/disource-donations b/disource-donations deleted file mode 120000 index 5f94186..0000000 --- a/disource-donations +++ /dev/null @@ -1 +0,0 @@ -disource-donations \ No newline at end of file diff --git a/spec/controllers/discourse_donations/charges_controller_spec.rb b/spec/controllers/discourse_donations/charges_controller_spec.rb index aef28dd..1b981cf 100644 --- a/spec/controllers/discourse_donations/charges_controller_spec.rb +++ b/spec/controllers/discourse_donations/charges_controller_spec.rb @@ -36,7 +36,7 @@ module DiscourseDonations it 'does not expect a username or email if accounts are not being created' do current_user = log_in(:coding_horror) - post :create + post :create, { create_account: 'false' } expect(body['messages']).to include(I18n.t('donations.payment.success')) expect(response).to have_http_status(200) end @@ -58,10 +58,15 @@ module DiscourseDonations log_in :coding_horror post :create, params end + + it 'does not create user accounts when settings are disabled and params are not' do + log_in :coding_horror + post :create, params.merge(create_account: true, email: 'email@example.com', password: 'secret', username: 'mr-brown', name: 'hacker-guy') + end end describe 'creating an account enabled' do - let(:params) { { email: 'email@example.com', password: 'secret', username: 'mr-pink', name: 'kirsten', amount: 100, stripeToken: 'rrurrrurrrrr' } } + let(:params) { { create_account: 'true', email: 'email@example.com', password: 'secret', username: 'mr-pink', amount: 100, stripeToken: 'rrurrrurrrrr-rrruurrrr' } } before do SiteSetting.stubs(:discourse_donations_enable_create_accounts).returns(true) @@ -75,7 +80,7 @@ module DiscourseDonations end describe 'new user' do - let(:params) { { email: 'email@example.com', password: 'secret', username: 'mr-pink' } } + let(:params) { { create_account: 'true', email: 'email@example.com', password: 'secret', username: 'mr-pink', amount: 100, stripeToken: 'rrurrrurrrrr-rrruurrrr' } } before { SiteSetting.stubs(:discourse_donations_enable_create_accounts).returns(true) } @@ -120,7 +125,7 @@ module DiscourseDonations end describe 'new user' do - let(:params) { { email: 'dood@example.com', password: 'secret', name: 'dood', username: 'mr-dood' } } + let(:params) { { create_account: 'true', email: 'dood@example.com', password: 'secret', name: 'dood', username: 'mr-dood' } } before { SiteSetting.stubs(:discourse_donations_enable_create_accounts).returns(true) }