##// END OF EJS Templates
remove trailing white-spaces from test/functional/application_controller_test.rb....
Toshi MARUYAMA -
r6704:44ae210ea0a4
parent child
Show More
@@ -1,100 +1,100
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 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 21 class ApplicationControllerTest < ActionController::TestCase
22 22 include Redmine::I18n
23
23
24 24 def setup
25 25 @controller = ApplicationController.new
26 26 @request = ActionController::TestRequest.new
27 27 @response = ActionController::TestResponse.new
28 28 end
29 29
30 30 # check that all language files are valid
31 31 def test_localization
32 32 lang_files_count = Dir["#{Rails.root}/config/locales/*.yml"].size
33 33 assert_equal lang_files_count, valid_languages.size
34 34 valid_languages.each do |lang|
35 35 assert set_language_if_valid(lang)
36 36 end
37 37 set_language_if_valid('en')
38 38 end
39
39
40 40 def test_call_hook_mixed_in
41 41 assert @controller.respond_to?(:call_hook)
42 42 end
43
43
44 44 context "test_api_offset_and_limit" do
45 45 context "without params" do
46 46 should "return 0, 25" do
47 47 assert_equal [0, 25], @controller.api_offset_and_limit({})
48 48 end
49 49 end
50
50
51 51 context "with limit" do
52 52 should "return 0, limit" do
53 53 assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30})
54 54 end
55
55
56 56 should "not exceed 100" do
57 57 assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120})
58 58 end
59 59
60 60 should "not be negative" do
61 61 assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10})
62 62 end
63 63 end
64
64
65 65 context "with offset" do
66 66 should "return offset, 25" do
67 67 assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10})
68 68 end
69 69
70 70 should "not be negative" do
71 71 assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10})
72 72 end
73
73
74 74 context "and limit" do
75 75 should "return offset, limit" do
76 76 assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50})
77 77 end
78 78 end
79 79 end
80
80
81 81 context "with page" do
82 82 should "return offset, 25" do
83 83 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1})
84 84 assert_equal [50, 25], @controller.api_offset_and_limit({:page => 3})
85 85 end
86 86
87 87 should "not be negative" do
88 88 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0})
89 89 assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2})
90 90 end
91
91
92 92 context "and limit" do
93 93 should "return offset, limit" do
94 94 assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100})
95 95 assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100})
96 96 end
97 97 end
98 98 end
99 99 end
100 100 end
General Comments 0
You need to be logged in to leave comments. Login now