mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-22 00:11:14 +00:00
Incorrect links generated in emails if host setup uses other port (#19323).
git-svn-id: http://svn.redmine.org/redmine/trunk@14081 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
5da48d9293
commit
104615cb6f
@ -24,7 +24,16 @@ class Mailer < ActionMailer::Base
|
|||||||
include Redmine::I18n
|
include Redmine::I18n
|
||||||
|
|
||||||
def self.default_url_options
|
def self.default_url_options
|
||||||
{ :host => Setting.host_name, :protocol => Setting.protocol }
|
options = {:protocol => Setting.protocol}
|
||||||
|
if Setting.host_name.to_s =~ /\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i
|
||||||
|
host, port, prefix = $2, $4, $5
|
||||||
|
options.merge!({
|
||||||
|
:host => host, :port => port, :script_name => prefix
|
||||||
|
})
|
||||||
|
else
|
||||||
|
options[:host] = Setting.host_name
|
||||||
|
end
|
||||||
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds a mail for notifying to_users and cc_users about a new issue
|
# Builds a mail for notifying to_users and cc_users about a new issue
|
||||||
|
|||||||
@ -119,6 +119,24 @@ class MailerTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_generated_links_with_port_and_prefix
|
||||||
|
with_settings :host_name => '10.0.0.1:81/redmine', :protocol => 'http' do
|
||||||
|
Mailer.test_email(User.find(1)).deliver
|
||||||
|
mail = last_email
|
||||||
|
assert_not_nil mail
|
||||||
|
assert_include 'http://10.0.0.1:81/redmine', mail_body(mail)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_generated_links_with_port
|
||||||
|
with_settings :host_name => '10.0.0.1:81', :protocol => 'http' do
|
||||||
|
Mailer.test_email(User.find(1)).deliver
|
||||||
|
mail = last_email
|
||||||
|
assert_not_nil mail
|
||||||
|
assert_include 'http://10.0.0.1:81', mail_body(mail)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_issue_edit_should_generate_url_with_hostname_for_relations
|
def test_issue_edit_should_generate_url_with_hostname_for_relations
|
||||||
journal = Journal.new(:journalized => Issue.find(1), :user => User.find(1), :created_on => Time.now)
|
journal = Journal.new(:journalized => Issue.find(1), :user => User.find(1), :created_on => Time.now)
|
||||||
journal.details << JournalDetail.new(:property => 'relation', :prop_key => 'label_relates_to', :value => 2)
|
journal.details << JournalDetail.new(:property => 'relation', :prop_key => 'label_relates_to', :value => 2)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user