From 1831861eac96e684915ee4e77daf2b8fbbdbf75c 2012-05-10 18:53:32 From: Jean-Philippe Lang Date: 2012-05-10 18:53:32 Subject: [PATCH] Tests for Setting.per_page_options_array. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9665 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/test/unit/setting_test.rb b/test/unit/setting_test.rb index 37d7baf..41bc31a 100644 --- a/test/unit/setting_test.rb +++ b/test/unit/setting_test.rb @@ -55,4 +55,32 @@ class SettingTest < ActiveSupport::TestCase Setting.clear_cache assert_equal "New title", Setting.app_title end + + def test_per_page_options_array_should_be_an_empty_array_when_setting_is_blank + with_settings :per_page_options => nil do + assert_equal [], Setting.per_page_options_array + end + + with_settings :per_page_options => '' do + assert_equal [], Setting.per_page_options_array + end + end + + def test_per_page_options_array_should_be_an_array_of_integers + with_settings :per_page_options => '10, 25, 50' do + assert_equal [10, 25, 50], Setting.per_page_options_array + end + end + + def test_per_page_options_array_should_omit_non_numerial_values + with_settings :per_page_options => 'a, 25, 50' do + assert_equal [25, 50], Setting.per_page_options_array + end + end + + def test_per_page_options_array_should_be_sorted + with_settings :per_page_options => '25, 10, 50' do + assert_equal [10, 25, 50], Setting.per_page_options_array + end + end end