---
Fixing the last unit-test error test/test_util/ipn.rb.
Fixed .travis.yml
to show an error, when the unit-tests fail.
Creating the unit-tests in test/test_util/mail.rb to define the interface to the definition of email-receiveivers. We want to see something like this in etc/oddb.yml
mail_recipients: - :email: customer@company.com :lists: - oddb - oddb2csv - :email: customer2@another_company.com :lists: - oddb2csv - :email: ywesee_test@ywesee.com :lists: - test - admin - oddb - ipn - oddb2csv # all lists at oddb
Thinking about whether to define a list of ID of good known receiver list either in etc/oddb.yml or src/util/mail.rb.
In etc/oddb.yml we could define it like
mailling_list_ids: - test - ipn - oddb2csvor as constants in src/util/mail.rb. In Ruby 2.0 I would use a statement like
enumerator = %w(test ipn oddb2csv).each
. But as we are still on Ruby 1.9. We could use
class Mail Test = 0 Ipn = 1 Oddb2csv = 2
Migrating from Ruby 1.9 to 2.0 with enumeration would mean replacing Capitalized-name to lowercase names.
Therefore I personally prefer a definition in oddb.yml. Creating a a new fail test/data/oddb_mailing_list_test.yml (in source code repository) with sample entries for unit tests.
Changing the method API to use an list
instead of recipients
like this
def Util.send_mail(recipients, mail_subject, mail_body, override_from = nil, parts = {}) def Util.send_mail_with_attachments(subject, body, attachments)
def Util.send_mail(list_id, mail_subject, mail_body, override_from = nil, parts = {}) def Util.send_mail_with_attachments(list_id, subject, body, attachments)
and adding a helper method def Util.use_mailing_list_configuration(path_to_yml = 'etc/oddb.yml')
to enable switching between different e-mail configuration. Unit tests work now.
Looking in all places to generate a correct definition of all receivers in etc/oddb.yml. Also replacing all recipients by a new list_id.
Found that we have a lot of configuration info also in src/util/oddbconfig.rb
. Is everything still used?
After looking at all unit-tests (specially ipn) I remarked that I must change the semantics of the list_id for the Util.send_mail to accept an array which must include a list_id and optionally one or more recipients, e.g. the actual email user who gets the invoice.
Adapted the receivers in the following files
Remarked that including SimpleCov into the unit test makes some tests fail because coverage is too low and/or simplecov thinks it has dropped a little bit. I should probably rework all unit tests to include test/helpers.rb and configure SimpleCov there correctly for all.