mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
Chore: Making Account Signup Optional (#563)
Introduce new environment variable that lets you control account signups ENABLE_ACCOUNT_SIGNUP :( true | false | api_only ) Fixes: #406 Co-authored-by: Pranav Raj S <pranavrajs@gmail.com>
This commit is contained in:
@@ -9,6 +9,7 @@ RSpec.describe 'Accounts API', type: :request do
|
||||
|
||||
before do
|
||||
allow(AccountBuilder).to receive(:new).and_return(account_builder)
|
||||
ENV['ENABLE_ACCOUNT_SIGNUP'] = nil
|
||||
end
|
||||
|
||||
it 'calls account builder' do
|
||||
@@ -40,5 +41,37 @@ RSpec.describe 'Accounts API', type: :request do
|
||||
expect(response.body).to eq({ message: I18n.t('errors.signup.failed') }.to_json)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ENABLE_ACCOUNT_SIGNUP env variable is set to false' do
|
||||
let(:email) { Faker::Internet.email }
|
||||
|
||||
it 'responds 404 on requests' do
|
||||
params = { account_name: 'test', email: email }
|
||||
ENV['ENABLE_ACCOUNT_SIGNUP'] = 'false'
|
||||
|
||||
post api_v1_accounts_url,
|
||||
params: params,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:not_found)
|
||||
ENV['ENABLE_ACCOUNT_SIGNUP'] = nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ENABLE_ACCOUNT_SIGNUP env variable is set to api_only' do
|
||||
let(:email) { Faker::Internet.email }
|
||||
|
||||
it 'does not respond 404 on requests' do
|
||||
params = { account_name: 'test', email: email }
|
||||
ENV['ENABLE_ACCOUNT_SIGNUP'] = 'api_only'
|
||||
|
||||
post api_v1_accounts_url,
|
||||
params: params,
|
||||
as: :json
|
||||
|
||||
expect(response).not_to have_http_status(:not_found)
|
||||
ENV['ENABLE_ACCOUNT_SIGNUP'] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user