diff --git a/lib/ontologies_linked_data/utils/notifications.rb b/lib/ontologies_linked_data/utils/notifications.rb index 340c0d5d..61f8d756 100644 --- a/lib/ontologies_linked_data/utils/notifications.rb +++ b/lib/ontologies_linked_data/utils/notifications.rb @@ -190,7 +190,7 @@ def self.mail_options } if LinkedData.settings.smtp_auth_type && LinkedData.settings.smtp_auth_type != :none - options.merge({ + options.merge!({ user_name: LinkedData.settings.smtp_user, password: LinkedData.settings.smtp_password, authentication: LinkedData.settings.smtp_auth_type diff --git a/test/util/test_notifications.rb b/test/util/test_notifications.rb index 8508dc1e..7d3ad5db 100644 --- a/test/util/test_notifications.rb +++ b/test/util/test_notifications.rb @@ -129,4 +129,30 @@ def test_remote_ontology_pull_notification end end end + + def test_mail_options + options = LinkedData::Utils::Notifier.mail_options + expected_options = { + address: LinkedData.settings.smtp_host, + port: LinkedData.settings.smtp_port, + domain: LinkedData.settings.smtp_domain + } + assert_equal options, expected_options + + # testing SMTP authentification-based login + current_auth_type = LinkedData.settings.smtp_auth_type + LinkedData.settings.smtp_auth_type = :plain + options = LinkedData::Utils::Notifier.mail_options + expected_options = { + address: LinkedData.settings.smtp_host, + port: LinkedData.settings.smtp_port, + domain: LinkedData.settings.smtp_domain, + user_name: LinkedData.settings.smtp_user, + password: LinkedData.settings.smtp_password, + authentication: LinkedData.settings.smtp_auth_type + } + assert_equal options, expected_options + + LinkedData.settings.smtp_auth_type = current_auth_type + end end