Defect #3692 » settings_hostname_trailing_slash_fix.diff
| test/functional/settings_controller_test.rb (working copy) | ||
|---|---|---|
|
assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
|
||
|
assert_equal 'Test footer', Setting.emails_footer
|
||
|
end
|
||
|
|
||
|
# Test if the host-name is modified so that no forward-slash is at the end of the string.
|
||
|
def test_post_edit_host_name
|
||
|
post :edit, :settings => {:host_name => 'http://www.example.com/'}
|
||
|
assert_redirected_to 'settings/edit'
|
||
|
assert_equal 'http://www.example.com', Setting.host_name
|
||
|
end
|
||
|
end
|
||
| app/controllers/settings_controller.rb (working copy) | ||
|---|---|---|
|
@notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted wiki_content_added wiki_content_updated)
|
||
|
if request.post? && params[:settings] && params[:settings].is_a?(Hash)
|
||
|
settings = (params[:settings] || {}).dup.symbolize_keys
|
||
|
# make sure the host-name has no trailing forward-slash. (#3692)
|
||
|
settings[:host_name].gsub!(/\/$/, '')
|
||
|
settings.each do |name, value|
|
||
|
# remove blank values in array settings
|
||
|
value.delete_if {|v| v.blank? } if value.is_a?(Array)
|
||