From 1831861eac96e684915ee4e77daf2b8fbbdbf75c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 10 May 2012 18:53:32 +0000 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 --- test/unit/setting_test.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/unit/setting_test.rb b/test/unit/setting_test.rb index 37d7baf11..41bc31aef 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 -- 2.39.5