Mercurial > hg > soundsoftware-site
comparison test/functional/application_controller_test.rb @ 511:107d36338b70 live
Merge from branch "cannam"
author | Chris Cannam |
---|---|
date | Thu, 14 Jul 2011 10:43:07 +0100 |
parents | 0c939c159af4 |
children | cbb26bc654de |
comparison
equal
deleted
inserted
replaced
451:a9f6345cb43d | 511:107d36338b70 |
---|---|
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 | |
21 # Re-raise errors caught by the controller. | |
22 class ApplicationController; def rescue_action(e) raise e end; end | |
23 | 20 |
24 class ApplicationControllerTest < ActionController::TestCase | 21 class ApplicationControllerTest < ActionController::TestCase |
25 include Redmine::I18n | 22 include Redmine::I18n |
26 | 23 |
27 def setup | 24 def setup |
41 end | 38 end |
42 | 39 |
43 def test_call_hook_mixed_in | 40 def test_call_hook_mixed_in |
44 assert @controller.respond_to?(:call_hook) | 41 assert @controller.respond_to?(:call_hook) |
45 end | 42 end |
43 | |
44 context "test_api_offset_and_limit" do | |
45 context "without params" do | |
46 should "return 0, 25" do | |
47 assert_equal [0, 25], @controller.api_offset_and_limit({}) | |
48 end | |
49 end | |
50 | |
51 context "with limit" do | |
52 should "return 0, limit" do | |
53 assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30}) | |
54 end | |
55 | |
56 should "not exceed 100" do | |
57 assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120}) | |
58 end | |
59 | |
60 should "not be negative" do | |
61 assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10}) | |
62 end | |
63 end | |
64 | |
65 context "with offset" do | |
66 should "return offset, 25" do | |
67 assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10}) | |
68 end | |
69 | |
70 should "not be negative" do | |
71 assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10}) | |
72 end | |
73 | |
74 context "and limit" do | |
75 should "return offset, limit" do | |
76 assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50}) | |
77 end | |
78 end | |
79 end | |
80 | |
81 context "with page" do | |
82 should "return offset, 25" do | |
83 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1}) | |
84 assert_equal [50, 25], @controller.api_offset_and_limit({:page => 3}) | |
85 end | |
86 | |
87 should "not be negative" do | |
88 assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0}) | |
89 assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2}) | |
90 end | |
91 | |
92 context "and limit" do | |
93 should "return offset, limit" do | |
94 assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100}) | |
95 assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100}) | |
96 end | |
97 end | |
98 end | |
99 end | |
46 end | 100 end |