Defect #3692 » 3692.patch
| app/models/setting.rb | ||
|---|---|---|
|
validates_inclusion_of :name, :in => @@available_settings.keys
|
||
|
validates_numericality_of :value, :only_integer => true, :if => Proc.new { |setting| @@available_settings[setting.name]['format'] == 'int' }
|
||
|
before_save :remove_trailing_slash_from_hostname
|
||
|
# Hash used to cache setting values
|
||
|
@cached_settings = {}
|
||
|
@cached_cleared_on = Time.now
|
||
| ... | ... | |
|
end
|
||
|
|
||
|
private
|
||
|
def remove_trailing_slash_from_hostname
|
||
|
value.gsub!(/\/+$/, '') if name == 'host_name'
|
||
|
end
|
||
|
# Returns the Setting instance for the setting named name
|
||
|
# (record found in database or new record with default value)
|
||
|
def self.find_or_default(name)
|
||
| test/functional/settings_controller_test.rb | ||
|---|---|---|
|
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
|
||
- « Previous
- 1
- 2
- 3
- Next »