Skip to content

Commit

Permalink
Test drive Twilio WhatsApp configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwr18 committed Sep 9, 2024
1 parent f4c8f57 commit 9c5fa6c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/dashboards/organization_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand All @@ -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[
Expand All @@ -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[
Expand Down
27 changes: 27 additions & 0 deletions spec/requests/admin/organization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9c5fa6c

Please sign in to comment.