@@ -1,16 +1,16 | |||
|
1 |
# |
|
|
2 |
# Copyright (C) 2006-20 |
|
|
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. |
@@ -20,7 +20,7 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 |
@@ -36,23 +36,23 class ApplicationControllerTest < ActionController::TestCase | |||
|
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 |
@@ -61,7 +61,7 class ApplicationControllerTest < ActionController::TestCase | |||
|
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}) |
@@ -70,14 +70,14 class ApplicationControllerTest < ActionController::TestCase | |||
|
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}) |
@@ -88,7 +88,7 class ApplicationControllerTest < ActionController::TestCase | |||
|
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}) |
General Comments 0
You need to be logged in to leave comments.
Login now