@@ -1,16 +1,16 | |||||
1 |
# |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-20 |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 |
# |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 |
# |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
@@ -20,7 +20,7 require 'application_controller' | |||||
20 |
|
20 | |||
21 | class ApplicationControllerTest < ActionController::TestCase |
|
21 | class ApplicationControllerTest < ActionController::TestCase | |
22 | include Redmine::I18n |
|
22 | include Redmine::I18n | |
23 |
|
23 | |||
24 | def setup |
|
24 | def setup | |
25 | @controller = ApplicationController.new |
|
25 | @controller = ApplicationController.new | |
26 | @request = ActionController::TestRequest.new |
|
26 | @request = ActionController::TestRequest.new | |
@@ -36,23 +36,23 class ApplicationControllerTest < ActionController::TestCase | |||||
36 | end |
|
36 | end | |
37 | set_language_if_valid('en') |
|
37 | set_language_if_valid('en') | |
38 | end |
|
38 | end | |
39 |
|
39 | |||
40 | def test_call_hook_mixed_in |
|
40 | def test_call_hook_mixed_in | |
41 | assert @controller.respond_to?(:call_hook) |
|
41 | assert @controller.respond_to?(:call_hook) | |
42 | end |
|
42 | end | |
43 |
|
43 | |||
44 | context "test_api_offset_and_limit" do |
|
44 | context "test_api_offset_and_limit" do | |
45 | context "without params" do |
|
45 | context "without params" do | |
46 | should "return 0, 25" do |
|
46 | should "return 0, 25" do | |
47 | assert_equal [0, 25], @controller.api_offset_and_limit({}) |
|
47 | assert_equal [0, 25], @controller.api_offset_and_limit({}) | |
48 | end |
|
48 | end | |
49 | end |
|
49 | end | |
50 |
|
50 | |||
51 | context "with limit" do |
|
51 | context "with limit" do | |
52 | should "return 0, limit" do |
|
52 | should "return 0, limit" do | |
53 | assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30}) |
|
53 | assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30}) | |
54 | end |
|
54 | end | |
55 |
|
55 | |||
56 | should "not exceed 100" do |
|
56 | should "not exceed 100" do | |
57 | assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120}) |
|
57 | assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120}) | |
58 | end |
|
58 | end | |
@@ -61,7 +61,7 class ApplicationControllerTest < ActionController::TestCase | |||||
61 | assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10}) |
|
61 | assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10}) | |
62 | end |
|
62 | end | |
63 | end |
|
63 | end | |
64 |
|
64 | |||
65 | context "with offset" do |
|
65 | context "with offset" do | |
66 | should "return offset, 25" do |
|
66 | should "return offset, 25" do | |
67 | assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10}) |
|
67 | assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10}) | |
@@ -70,14 +70,14 class ApplicationControllerTest < ActionController::TestCase | |||||
70 | should "not be negative" do |
|
70 | should "not be negative" do | |
71 | assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10}) |
|
71 | assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10}) | |
72 | end |
|
72 | end | |
73 |
|
73 | |||
74 | context "and limit" do |
|
74 | context "and limit" do | |
75 | should "return offset, limit" do |
|
75 | should "return offset, limit" do | |
76 | assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50}) |
|
76 | assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50}) | |
77 | end |
|
77 | end | |
78 | end |
|
78 | end | |
79 | end |
|
79 | end | |
80 |
|
80 | |||
81 | context "with page" do |
|
81 | context "with page" do | |
82 | should "return offset, 25" do |
|
82 | should "return offset, 25" do | |
83 | assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1}) |
|
83 | assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1}) | |
@@ -88,7 +88,7 class ApplicationControllerTest < ActionController::TestCase | |||||
88 | assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0}) |
|
88 | assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0}) | |
89 | assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2}) |
|
89 | assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2}) | |
90 | end |
|
90 | end | |
91 |
|
91 | |||
92 | context "and limit" do |
|
92 | context "and limit" do | |
93 | should "return offset, limit" do |
|
93 | should "return offset, limit" do | |
94 | assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100}) |
|
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