Project

General

Profile

Defect #3692 » 3692.patch

Gregor Schmidt, 2010-06-21 23:11

View differences:

app/models/setting.rb
84 84
  validates_inclusion_of :name, :in => @@available_settings.keys
85 85
  validates_numericality_of :value, :only_integer => true, :if => Proc.new { |setting| @@available_settings[setting.name]['format'] == 'int' }  
86 86

  
87
  before_save :remove_trailing_slash_from_hostname
88

  
87 89
  # Hash used to cache setting values
88 90
  @cached_settings = {}
89 91
  @cached_cleared_on = Time.now
......
157 159
  end
158 160
  
159 161
private
162
  def remove_trailing_slash_from_hostname
163
    value.gsub!(/\/+$/, '') if name == 'host_name'
164
  end
165

  
160 166
  # Returns the Setting instance for the setting named name
161 167
  # (record found in database or new record with default value)
162 168
  def self.find_or_default(name)
test/functional/settings_controller_test.rb
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
66

  
59 67
end
(3-3/3)