comparison test/unit/setting_test.rb @ 1526:404aa68d4227

Merge from live branch
author Chris Cannam
date Thu, 11 Sep 2014 12:46:20 +0100
parents dffacf8a6908
children
comparison
equal deleted inserted replaced
1493:a5f2bdf3b486 1526:404aa68d4227
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
39 assert_equal "My other title", Setting.app_title 39 assert_equal "My other title", Setting.app_title
40 # make sure db has been updated (UPDATE) 40 # make sure db has been updated (UPDATE)
41 assert_equal "My other title", Setting.find_by_name('app_title').value 41 assert_equal "My other title", Setting.find_by_name('app_title').value
42 end 42 end
43 43
44 def test_setting_with_int_format_should_accept_numeric_only
45 with_settings :session_timeout => 30 do
46 Setting.session_timeout = 'foo'
47 assert_equal "30", Setting.session_timeout
48 Setting.session_timeout = 40
49 assert_equal "40", Setting.session_timeout
50 end
51 end
52
53 def test_setting_with_invalid_name_should_be_valid
54 setting = Setting.new(:name => "does_not_exist", :value => "should_not_be_allowed")
55 assert !setting.save
56 end
57
44 def test_serialized_setting 58 def test_serialized_setting
45 Setting.notified_events = ['issue_added', 'issue_updated', 'news_added'] 59 Setting.notified_events = ['issue_added', 'issue_updated', 'news_added']
46 assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.notified_events 60 assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.notified_events
47 assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.find_by_name('notified_events').value 61 assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.find_by_name('notified_events').value
48 end 62 end
49 63
50 def test_setting_should_be_reloaded_after_clear_cache 64 def test_setting_should_be_reloaded_after_clear_cache
51 Setting.app_title = "My title" 65 Setting.app_title = "My title"
52 assert_equal "My title", Setting.app_title 66 assert_equal "My title", Setting.app_title
53 67
54 s = Setting.find_by_name("app_title") 68 s = Setting.find_by_name("app_title")
55 s.value = 'New title' 69 s.value = 'New title'
56 s.save! 70 s.save!
57 assert_equal "My title", Setting.app_title 71 assert_equal "My title", Setting.app_title
58 72
59 Setting.clear_cache 73 Setting.clear_cache
60 assert_equal "New title", Setting.app_title 74 assert_equal "New title", Setting.app_title
61 end 75 end
62 76
63 def test_per_page_options_array_should_be_an_empty_array_when_setting_is_blank 77 def test_per_page_options_array_should_be_an_empty_array_when_setting_is_blank