spec/workers/*email*_spec.rb fails because it is not reading environment variables
I'm trying to run more tests using gitlab debian package, now with RAILS_ENV=test. But email related tests fail.
1) BuildEmailWorker#perform sends mail
Failure/Error: Notify.build_success_email(build_id, recipient).deliver_now
ArgumentError:
An SMTP From address is required to send a message. Set the message smtp_envelope_from, return_path, sender, or from address.
# ./app/workers/build_email_worker.rb:10:in `block in perform'
# ./app/workers/build_email_worker.rb:6:in `each'
# ./app/workers/build_email_worker.rb:6:in `perform'
# ./spec/workers/build_email_worker_spec.rb:19:in `block (3 levels) in <top (required)>'
I think this is because email address is set as environment variable in debian,
GITLAB_EMAIL_FROM="no-reply@localhost"
GITLAB_EMAIL_DISPLAY_NAME="Gitlab"
GITLAB_EMAIL_REPLY_TO="no-reply@localhost"
Before the tests run, I checked the variable is set with echo email: "GITLAB_EMAIL_FROM"
and it outputs email: "no-reply@localhost"
as expected. I think the tests are not expecting to read this from environment variables.
cc @stanhu