FIX: Use correct URL for unsubscribe (#10077)

FIX: Use correct URL for unsubscribe (#10077)

diff --git a/app/mailers/subscription_mailer.rb b/app/mailers/subscription_mailer.rb
index 535dec5..a8c4234 100644
--- a/app/mailers/subscription_mailer.rb
+++ b/app/mailers/subscription_mailer.rb
@@ -9,6 +9,6 @@ class SubscriptionMailer < ActionMailer::Base
                 template: "unsubscribe_mailer",
                 site_title: SiteSetting.title,
                 site_domain_name: Discourse.current_hostname,
-                confirm_unsubscribe_link: "#{Discourse.base_url}/unsubscribe/#{unsubscribe_key}"
+                confirm_unsubscribe_link: email_unsubscribe_url(unsubscribe_key, host: Discourse.base_url)
   end
 end
diff --git a/spec/mailers/subscription_mailer_spec.rb b/spec/mailers/subscription_mailer_spec.rb
new file mode 100644
index 0000000..696231d
--- /dev/null
+++ b/spec/mailers/subscription_mailer_spec.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+describe SubscriptionMailer do
+  fab!(:user) { Fabricate(:user) }
+
+  subject { SubscriptionMailer.confirm_unsubscribe(user) }
+
+  it "contains the right URL" do
+    expect(subject.body).to include("#{Discourse.base_url}/email/unsubscribe/#{UnsubscribeKey.last.key}")
+  end
+end

GitHub sha: 75151f04

This commit appears in #10077 which was approved by ZogStriP. It was merged by ZogStriP.