use site setting instead of params for create account

This commit is contained in:
Rimian Perkins 2017-05-17 10:30:28 +10:00
parent b663bf5447
commit 05c31f1909
3 changed files with 7 additions and 6 deletions

View File

@ -46,7 +46,7 @@ module DiscourseDonations
private private
def create_account def create_account
params[:create_account] == 'true' && SiteSetting.discourse_donations_enable_create_accounts SiteSetting.discourse_donations_enable_create_accounts
end end
def reward?(payment) def reward?(payment)

1
disource-donations Symbolic link
View File

@ -0,0 +1 @@
disource-donations

View File

@ -31,7 +31,7 @@ module DiscourseDonations
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, { create_account: 'false' } post :create
expect(body['messages']).to include(I18n.t('donations.payment.success')) expect(body['messages']).to include(I18n.t('donations.payment.success'))
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end end
@ -49,12 +49,12 @@ module DiscourseDonations
it 'does not create user accounts if the user is logged in' do it 'does not create user accounts if the user is logged in' do
log_in :coding_horror log_in :coding_horror
post :create, { create_account: 'true' } post :create
end end
end end
describe 'creating an account' do describe 'creating an account' do
let(:params) { { create_account: 'true', email: 'email@example.com', password: 'secret', username: 'mr-pink' } } let(:params) { { email: 'email@example.com', password: 'secret', username: 'mr-pink' } }
before do before do
SiteSetting.stubs(:discourse_donations_enable_create_accounts).returns(true) SiteSetting.stubs(:discourse_donations_enable_create_accounts).returns(true)
@ -68,7 +68,7 @@ module DiscourseDonations
end end
describe 'new user' do describe 'new user' do
let(:params) { { create_account: 'true', email: 'email@example.com', password: 'secret', username: 'mr-pink' } } let(:params) { { email: 'email@example.com', password: 'secret', username: 'mr-pink' } }
before { SiteSetting.stubs(:discourse_donations_enable_create_accounts).returns(true) } before { SiteSetting.stubs(:discourse_donations_enable_create_accounts).returns(true) }
@ -113,7 +113,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) { { email: 'dood@example.com', password: 'secret', 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) }