From 9c5fa6c4af5e199e2ffb31743a73fdf1aaed17a2 Mon Sep 17 00:00:00 2001 From: Matthew Rider Date: Mon, 9 Sep 2024 11:43:10 +0200 Subject: [PATCH] Test drive Twilio WhatsApp configuration --- app/dashboards/organization_dashboard.rb | 13 +++++++++++- spec/requests/admin/organization_spec.rb | 27 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/app/dashboards/organization_dashboard.rb b/app/dashboards/organization_dashboard.rb index ee22711c2..c95168f34 100644 --- a/app/dashboards/organization_dashboard.rb +++ b/app/dashboards/organization_dashboard.rb @@ -28,7 +28,11 @@ class OrganizationDashboard < Administrate::BaseDashboard telegram_bot_api_key: Field::Password, threemarb_api_identity: Field::String, threemarb_api_secret: Field::Password, - threemarb_private: Field::Password + threemarb_private: Field::Password, + whats_app_server_phone_number: Field::String, + twilio_account_sid: Field::String, + twilio_api_key_sid: Field::String, + twilio_api_key_secret: Field::Password }.freeze COLLECTION_ATTRIBUTES = %i[ @@ -50,6 +54,9 @@ class OrganizationDashboard < Administrate::BaseDashboard email_from_address telegram_bot_username threemarb_api_identity + whats_app_server_phone_number + twilio_account_sid + twilio_api_key_sid ].freeze FORM_ATTRIBUTES_NEW = %i[ @@ -72,6 +79,10 @@ class OrganizationDashboard < Administrate::BaseDashboard threemarb_api_identity threemarb_api_secret threemarb_private + whats_app_server_phone_number + twilio_account_sid + twilio_api_key_sid + twilio_api_key_secret ].freeze FORM_ATTRIBUTES_EDIT = %i[ diff --git a/spec/requests/admin/organization_spec.rb b/spec/requests/admin/organization_spec.rb index e66a4a1c4..1ec20d0f1 100644 --- a/spec/requests/admin/organization_spec.rb +++ b/spec/requests/admin/organization_spec.rb @@ -95,6 +95,33 @@ expect(organization).to have_attributes(threemarb_api_secret: 'valid_secret', threemarb_private: 'valid_private_key') end end + + context 'WhatsApp Twilio' do + let(:whats_app_params) do + { + whats_app_server_phone_number: '+4912345678', + twilio_account_sid: 'valid_account_sid', + twilio_api_key_sid: 'valid_api_key_sid', + twilio_api_key_secret: 'valid_secret' + } + end + let(:params) do + required_params.deep_merge({ organization: whats_app_params }) + end + + it 'allows configuring Twilio WhatsApp' do + subject.call + follow_redirect! + + expect(page).to have_content('+4912345678') + expect(page).to have_content('valid_account_sid') + expect(page).to have_content('valid_api_key_sid') + expect(page).not_to have_content('valid_secret') + + organization = Organization.find_by(whats_app_server_phone_number: '+4912345678') + expect(organization).to have_attributes(whats_app_params) + end + end end end end