##// END OF EJS Templates
Fixes test failure when running all functional tests....
Jean-Philippe Lang -
r6054:9fca4c440cbc
parent child
Show More
@@ -1,103 +1,100
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19 require 'application_controller'
20 20
21 # Re-raise errors caught by the controller.
22 class ApplicationController; def rescue_action(e) raise e end; end
23
24 21 class ApplicationControllerTest < ActionController::TestCase
25 22 include Redmine::I18n
26 23
27 24 def setup
28 25 @controller = ApplicationController.new
29 26 @request = ActionController::TestRequest.new
30 27 @response = ActionController::TestResponse.new
31 28 end
32 29
33 30 # check that all language files are valid
34 31 def test_localization
35 32 lang_files_count = Dir["#{Rails.root}/config/locales/*.yml"].size
36 33 assert_equal lang_files_count, valid_languages.size
37 34 valid_languages.each do |lang|
38 35 assert set_language_if_valid(lang)
39 36 end
40 37 set_language_if_valid('en')
41 38 end
42 39
43 40 def test_call_hook_mixed_in
44 41 assert @controller.respond_to?(:call_hook)
45 42 end
46 43
47 44 context "test_api_offset_and_limit" do
48 45 context "without params" do
49 46 should "return 0, 25" do
50 47 assert_equal [0, 25], @controller.api_offset_and_limit({})
51 48 end
52 49 end
53 50
54 51 context "with limit" do
55 52 should "return 0, limit" do
56 53 assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30})
57 54 end
58 55
59 56 should "not exceed 100" do
60 57 assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120})
61 58 end
62 59
63 60 should "not be negative" do
64 61 assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10})
65 62 end
66 63 end
67 64
68 65 context "with offset" do
69 66 should "return offset, 25" do
70 67 assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10})
71 68 end
72 69
73 70 should "not be negative" do
74 71 assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10})
75 72 end
76 73
77 74 context "and limit" do
78 75 should "return offset, limit" do
79 76 assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50})
80 77 end
81 78 end
82 79 end
83 80
84 81 context "with page" do
85 82 should "return offset, 25" do
86 83 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1})
87 84 assert_equal [50, 25], @controller.api_offset_and_limit({:page => 3})
88 85 end
89 86
90 87 should "not be negative" do
91 88 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0})
92 89 assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2})
93 90 end
94 91
95 92 context "and limit" do
96 93 should "return offset, limit" do
97 94 assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100})
98 95 assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100})
99 96 end
100 97 end
101 98 end
102 99 end
103 100 end
General Comments 0
You need to be logged in to leave comments. Login now