@@ -24,7 +24,16 class Mailer < ActionMailer::Base | |||
|
24 | 24 | include Redmine::I18n |
|
25 | 25 | |
|
26 | 26 | def self.default_url_options |
|
27 |
|
|
|
27 | options = {:protocol => Setting.protocol} | |
|
28 | if Setting.host_name.to_s =~ /\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i | |
|
29 | host, port, prefix = $2, $4, $5 | |
|
30 | options.merge!({ | |
|
31 | :host => host, :port => port, :script_name => prefix | |
|
32 | }) | |
|
33 | else | |
|
34 | options[:host] = Setting.host_name | |
|
35 | end | |
|
36 | options | |
|
28 | 37 | end |
|
29 | 38 | |
|
30 | 39 | # Builds a mail for notifying to_users and cc_users about a new issue |
@@ -119,6 +119,24 class MailerTest < ActiveSupport::TestCase | |||
|
119 | 119 | end |
|
120 | 120 | end |
|
121 | 121 | |
|
122 | def test_generated_links_with_port_and_prefix | |
|
123 | with_settings :host_name => '10.0.0.1:81/redmine', :protocol => 'http' do | |
|
124 | Mailer.test_email(User.find(1)).deliver | |
|
125 | mail = last_email | |
|
126 | assert_not_nil mail | |
|
127 | assert_include 'http://10.0.0.1:81/redmine', mail_body(mail) | |
|
128 | end | |
|
129 | end | |
|
130 | ||
|
131 | def test_generated_links_with_port | |
|
132 | with_settings :host_name => '10.0.0.1:81', :protocol => 'http' do | |
|
133 | Mailer.test_email(User.find(1)).deliver | |
|
134 | mail = last_email | |
|
135 | assert_not_nil mail | |
|
136 | assert_include 'http://10.0.0.1:81', mail_body(mail) | |
|
137 | end | |
|
138 | end | |
|
139 | ||
|
122 | 140 | def test_issue_edit_should_generate_url_with_hostname_for_relations |
|
123 | 141 | journal = Journal.new(:journalized => Issue.find(1), :user => User.find(1), :created_on => Time.now) |
|
124 | 142 | journal.details << JournalDetail.new(:property => 'relation', :prop_key => 'label_relates_to', :value => 2) |
General Comments 0
You need to be logged in to leave comments.
Login now