Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix UserMailer.backup_ready method bug

Dombi Attila2fa81234ddca
diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb
index dc6ff779a95..586709b18ee 100644
--- a/app/mailers/user_mailer.rb
+++ b/app/mailers/user_mailer.rb
@@ -44,7 +44,7 @@ class UserMailer < ApplicationMailer
User.execute_as user do
@download_url = admin_backups_url
- send_mail(recipient,
+ send_mail(user,
I18n.t("mail_subject_backup_ready"))
end
end
diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb
index d7558283dcc..32b99c06af8 100644
--- a/spec/mailers/user_mailer_spec.rb
+++ b/spec/mailers/user_mailer_spec.rb
@@ -124,6 +124,27 @@ describe UserMailer, type: :mailer do
end
end
+ describe '#backup_ready' do
+ before do
+ described_class.backup_ready(recipient).deliver_now
+ end
+
+ it_behaves_like 'mail is sent' do
+ it 'has the expected subject' do
+ expect(deliveries.first.subject)
+ .to eql I18n.t("mail_subject_backup_ready")
+ end
+
+ it 'includes the url to the instance' do
+ expect(deliveries.first.body.encoded)
+ .to match Regexp.union(
+ /Your requested backup is ready. You can download it here/,
+ /#{Setting.protocol}:\/\/#{Setting.host_name}/
+ )
+ end
+ end
+ end
+
describe '#wiki_content_added' do
let(:wiki_content) { create(:wiki_content) }