@@ -91,4 +91,65 class WelcomeControllerTest < ActionController::TestCase | |||
|
91 | 91 | :attributes => {:type => "text/javascript"}, |
|
92 | 92 | :content => %r{new WarnLeavingUnsaved} |
|
93 | 93 | end |
|
94 | ||
|
95 | def test_call_hook_mixed_in | |
|
96 | assert @controller.respond_to?(:call_hook) | |
|
97 | end | |
|
98 | ||
|
99 | context "test_api_offset_and_limit" do | |
|
100 | context "without params" do | |
|
101 | should "return 0, 25" do | |
|
102 | assert_equal [0, 25], @controller.api_offset_and_limit({}) | |
|
103 | end | |
|
104 | end | |
|
105 | ||
|
106 | context "with limit" do | |
|
107 | should "return 0, limit" do | |
|
108 | assert_equal [0, 30], @controller.api_offset_and_limit({:limit => 30}) | |
|
109 | end | |
|
110 | ||
|
111 | should "not exceed 100" do | |
|
112 | assert_equal [0, 100], @controller.api_offset_and_limit({:limit => 120}) | |
|
113 | end | |
|
114 | ||
|
115 | should "not be negative" do | |
|
116 | assert_equal [0, 25], @controller.api_offset_and_limit({:limit => -10}) | |
|
117 | end | |
|
118 | end | |
|
119 | ||
|
120 | context "with offset" do | |
|
121 | should "return offset, 25" do | |
|
122 | assert_equal [10, 25], @controller.api_offset_and_limit({:offset => 10}) | |
|
123 | end | |
|
124 | ||
|
125 | should "not be negative" do | |
|
126 | assert_equal [0, 25], @controller.api_offset_and_limit({:offset => -10}) | |
|
127 | end | |
|
128 | ||
|
129 | context "and limit" do | |
|
130 | should "return offset, limit" do | |
|
131 | assert_equal [10, 50], @controller.api_offset_and_limit({:offset => 10, :limit => 50}) | |
|
132 | end | |
|
133 | end | |
|
134 | end | |
|
135 | ||
|
136 | context "with page" do | |
|
137 | should "return offset, 25" do | |
|
138 | assert_equal [0, 25], @controller.api_offset_and_limit({:page => 1}) | |
|
139 | assert_equal [50, 25], @controller.api_offset_and_limit({:page => 3}) | |
|
140 | end | |
|
141 | ||
|
142 | should "not be negative" do | |
|
143 | assert_equal [0, 25], @controller.api_offset_and_limit({:page => 0}) | |
|
144 | assert_equal [0, 25], @controller.api_offset_and_limit({:page => -2}) | |
|
145 | end | |
|
146 | ||
|
147 | context "and limit" do | |
|
148 | should "return offset, limit" do | |
|
149 | assert_equal [0, 100], @controller.api_offset_and_limit({:page => 1, :limit => 100}) | |
|
150 | assert_equal [200, 100], @controller.api_offset_and_limit({:page => 3, :limit => 100}) | |
|
151 | end | |
|
152 | end | |
|
153 | end | |
|
154 | end | |
|
94 | 155 | end |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now