diff test/unit/setting_test.rb @ 1337:077b8890835a cannam

Merge from live branch
author Chris Cannam
date Thu, 20 Jun 2013 13:14:02 +0100
parents 433d4f72a19b
children 622f24f53b42 261b3d9a4903
line wrap: on
line diff
--- a/test/unit/setting_test.rb	Fri Jun 14 11:30:07 2013 +0100
+++ b/test/unit/setting_test.rb	Thu Jun 20 13:14:02 2013 +0100
@@ -1,5 +1,5 @@
 # Redmine - project management software
-# Copyright (C) 2006-2011  Jean-Philippe Lang
+# Copyright (C) 2006-2012  Jean-Philippe Lang
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -19,6 +19,10 @@
 
 class SettingTest < ActiveSupport::TestCase
 
+  def teardown
+    Setting.clear_cache
+  end
+
   def test_read_default
     assert_equal "Redmine", Setting.app_title
     assert Setting.self_registration?
@@ -55,4 +59,32 @@
     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