@@ -137,71 +137,41 class MyControllerTest < ActionController::TestCase | |||
|
137 | 137 | assert_equal ['documents', 'calendar', 'latestnews'], User.find(2).pref[:my_page_layout]['left'] |
|
138 | 138 | end |
|
139 | 139 | |
|
140 | context "POST to reset_rss_key" do | |
|
141 | context "with an existing rss_token" do | |
|
142 | setup do | |
|
143 | @previous_token_value = User.find(2).rss_key # Will generate one if it's missing | |
|
144 | post :reset_rss_key | |
|
145 | end | |
|
146 | ||
|
147 | should "destroy the existing token" do | |
|
148 | assert_not_equal @previous_token_value, User.find(2).rss_key | |
|
149 | end | |
|
150 | ||
|
151 | should "create a new token" do | |
|
152 | assert User.find(2).rss_token | |
|
153 | end | |
|
154 | ||
|
155 | should_set_the_flash_to /reset/ | |
|
156 |
|
|
|
157 | end | |
|
158 | ||
|
159 | context "with no rss_token" do | |
|
160 | setup do | |
|
161 | assert_nil User.find(2).rss_token | |
|
162 | post :reset_rss_key | |
|
163 | end | |
|
164 | ||
|
165 | should "create a new token" do | |
|
166 | assert User.find(2).rss_token | |
|
167 | end | |
|
168 | ||
|
169 | should_set_the_flash_to /reset/ | |
|
170 | should_redirect_to('my account') {'/my/account' } | |
|
171 | end | |
|
140 | def test_reset_rss_key_with_existing_key | |
|
141 | @previous_token_value = User.find(2).rss_key # Will generate one if it's missing | |
|
142 | post :reset_rss_key | |
|
143 | ||
|
144 | assert_not_equal @previous_token_value, User.find(2).rss_key | |
|
145 | assert User.find(2).rss_token | |
|
146 | assert_match /reset/, flash[:notice] | |
|
147 | assert_redirected_to '/my/account' | |
|
148 | end | |
|
149 | ||
|
150 | def test_reset_rss_key_without_existing_key | |
|
151 | assert_nil User.find(2).rss_token | |
|
152 | post :reset_rss_key | |
|
153 | ||
|
154 | assert User.find(2).rss_token | |
|
155 | assert_match /reset/, flash[:notice] | |
|
156 | assert_redirected_to '/my/account' | |
|
172 | 157 | end |
|
173 | 158 | |
|
174 | context "POST to reset_api_key" do | |
|
175 | context "with an existing api_token" do | |
|
176 | setup do | |
|
177 | @previous_token_value = User.find(2).api_key # Will generate one if it's missing | |
|
178 | post :reset_api_key | |
|
179 | end | |
|
180 | ||
|
181 | should "destroy the existing token" do | |
|
182 | assert_not_equal @previous_token_value, User.find(2).api_key | |
|
183 | end | |
|
184 | ||
|
185 | should "create a new token" do | |
|
186 | assert User.find(2).api_token | |
|
187 | end | |
|
188 | ||
|
189 | should_set_the_flash_to /reset/ | |
|
190 |
|
|
|
191 | end | |
|
192 | ||
|
193 | context "with no api_token" do | |
|
194 | setup do | |
|
195 | assert_nil User.find(2).api_token | |
|
196 | post :reset_api_key | |
|
197 | end | |
|
198 | ||
|
199 | should "create a new token" do | |
|
200 | assert User.find(2).api_token | |
|
201 | end | |
|
202 | ||
|
203 | should_set_the_flash_to /reset/ | |
|
204 | should_redirect_to('my account') {'/my/account' } | |
|
205 | end | |
|
159 | def test_reset_api_key_with_existing_key | |
|
160 | @previous_token_value = User.find(2).api_key # Will generate one if it's missing | |
|
161 | post :reset_api_key | |
|
162 | ||
|
163 | assert_not_equal @previous_token_value, User.find(2).api_key | |
|
164 | assert User.find(2).api_token | |
|
165 | assert_match /reset/, flash[:notice] | |
|
166 | assert_redirected_to '/my/account' | |
|
167 | end | |
|
168 | ||
|
169 | def test_reset_api_key_without_existing_key | |
|
170 | assert_nil User.find(2).api_token | |
|
171 | post :reset_api_key | |
|
172 | ||
|
173 | assert User.find(2).api_token | |
|
174 | assert_match /reset/, flash[:notice] | |
|
175 | assert_redirected_to '/my/account' | |
|
206 | 176 | end |
|
207 | 177 | end |
General Comments 0
You need to be logged in to leave comments.
Login now