Project

General

Profile

Defect #3692 » mailer_trailing_slash_fix.patch

Trailing-slash fix + test to cover change. - Olafur Gislason, 2010-06-19 02:23

View differences:

app/models/mailer.rb (working copy)
27 27
  def self.default_url_options
28 28
    h = Setting.host_name
29 29
    h = h.to_s.gsub(%r{\/.*$}, '') unless Redmine::Utils.relative_url_root.blank?
30
    # Ensure that a trailing slash of the Settings.host_name will be removed.
31
    h.gsub!(/\/$/, '')
30 32
    { :host => h, :protocol => Setting.protocol }
31 33
  end
32 34
  
test/unit/mailer_test.rb (working copy)
48 48
    end
49 49
  end
50 50
  
51
  def test_generated_links_in_emails_with_trailing_slash
52
    Setting.host_name = 'mydomain.foo/'
53
    Setting.protocol = 'https'
54
    
55
    journal = Journal.find(2)
56
    assert Mailer.deliver_issue_edit(journal)
57
    
58
    mail = ActionMailer::Base.deliveries.last
59
    assert_kind_of TMail::Mail, mail
60
    
61
    assert_select_email do
62
      # link to the main ticket
63
      assert_select "a[href=?]", "https://mydomain.foo/issues/1", :text => "Bug #1: Can't print recipes"
64
      # link to a referenced ticket
65
      assert_select "a[href=?][title=?]", "https://mydomain.foo/issues/2", "Add ingredients categories (Assigned)", :text => "#2"
66
      # link to a changeset
67
      assert_select "a[href=?][title=?]", "https://mydomain.foo/projects/ecookbook/repository/revisions/2", "This commit fixes #1, #2 and references #1 & #3", :text => "r2"
68
    end
69
  end
70
  
51 71
  def test_generated_links_with_prefix
52 72
    relative_url_root = Redmine::Utils.relative_url_root
53 73
    Setting.host_name = 'mydomain.foo/rdm'
(1-1/3)