]> source.dussan.org Git - redmine.git/commitdiff
Tests for Setting.per_page_options_array.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 10 May 2012 18:53:32 +0000 (18:53 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 10 May 2012 18:53:32 +0000 (18:53 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9665 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/unit/setting_test.rb

index 37d7baf1103c4777c647548e8ee64642f8563a68..41bc31aef272d2292480a884ae952e93e7e1048f 100644 (file)
@@ -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