Mercurial > hg > soundsoftware-site
comparison test/functional/application_controller_test.rb @ 117:af80e5618e9b redmine-1.1
* Update to Redmine 1.1-stable branch (Redmine SVN rev 4707)
author | Chris Cannam |
---|---|
date | Thu, 13 Jan 2011 12:53:21 +0000 |
parents | 513646585e45 |
children | 0c939c159af4 |
comparison
equal
deleted
inserted
replaced
39:150ceac17a8d | 117:af80e5618e9b |
---|---|
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. |
17 | 17 |
18 require File.dirname(__FILE__) + '/../test_helper' | 18 require File.expand_path('../../test_helper', __FILE__) |
19 require 'application_controller' | 19 require 'application_controller' |
20 | 20 |
21 # Re-raise errors caught by the controller. | 21 # Re-raise errors caught by the controller. |
22 class ApplicationController; def rescue_action(e) raise e end; end | 22 class ApplicationController; def rescue_action(e) raise e end; end |
23 | 23 |
41 end | 41 end |
42 | 42 |
43 def test_call_hook_mixed_in | 43 def test_call_hook_mixed_in |
44 assert @controller.respond_to?(:call_hook) | 44 assert @controller.respond_to?(:call_hook) |
45 end | 45 end |
46 | |
47 context "test_api_offset_and_limit" do | |
48 context "without params" do | |
49 should "return 0, 25" do | |
50 assert_equal [0, 25], @controller.api_offset_and_limit({}) | |
51 end | |
52 end | |
53 | |
54 context "with limit" do | |
55 should "return 0, limit" do | |
56 assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30}) | |
57 end | |
58 | |
59 should "not exceed 100" do | |
60 assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120}) | |
61 end | |
62 | |
63 should "not be negative" do | |
64 assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10}) | |
65 end | |
66 end | |
67 | |
68 context "with offset" do | |
69 should "return offset, 25" do | |
70 assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10}) | |
71 end | |
72 | |
73 should "not be negative" do | |
74 assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10}) | |
75 end | |
76 | |
77 context "and limit" do | |
78 should "return offset, limit" do | |
79 assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50}) | |
80 end | |
81 end | |
82 end | |
83 | |
84 context "with page" do | |
85 should "return offset, 25" do | |
86 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1}) | |
87 assert_equal [50, 25], @controller.api_offset_and_limit({:page => 3}) | |
88 end | |
89 | |
90 should "not be negative" do | |
91 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0}) | |
92 assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2}) | |
93 end | |
94 | |
95 context "and limit" do | |
96 should "return offset, limit" do | |
97 assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100}) | |
98 assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100}) | |
99 end | |
100 end | |
101 end | |
102 end | |
46 end | 103 end |