Project

General

Profile

Defect #3692 » settings_hostname_trailing_slash_fix.diff

Settings_controller modification and additional test. - Olafur Gislason, 2010-06-21 22:20

View differences:

test/functional/settings_controller_test.rb (working copy)
56 56
    assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
57 57
    assert_equal 'Test footer', Setting.emails_footer
58 58
  end
59
  
60
  # Test if the host-name is modified so that no forward-slash is at the end of the string.
61
  def test_post_edit_host_name
62
    post :edit, :settings => {:host_name => 'http://www.example.com/'}
63
    assert_redirected_to 'settings/edit'
64
    assert_equal 'http://www.example.com', Setting.host_name
65
  end
59 66
end
app/controllers/settings_controller.rb (working copy)
29 29
    @notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted wiki_content_added wiki_content_updated)
30 30
    if request.post? && params[:settings] && params[:settings].is_a?(Hash)
31 31
      settings = (params[:settings] || {}).dup.symbolize_keys
32
      # make sure the host-name has no trailing forward-slash. (#3692)
33
      settings[:host_name].gsub!(/\/$/, '')
32 34
      settings.each do |name, value|
33 35
        # remove blank values in array settings
34 36
        value.delete_if {|v| v.blank? } if value.is_a?(Array)
(2-2/3)