##// END OF EJS Templates
Test cleanup....
Jean-Philippe Lang -
r8345:be5169249a9a
parent child
Show More
@@ -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
140 def test_reset_rss_key_with_existing_key
143 141 @previous_token_value = User.find(2).rss_key # Will generate one if it's missing
144 142 post :reset_rss_key
145 end
146 143
147 should "destroy the existing token" do
148 144 assert_not_equal @previous_token_value, User.find(2).rss_key
149 end
150
151 should "create a new token" do
152 145 assert User.find(2).rss_token
146 assert_match /reset/, flash[:notice]
147 assert_redirected_to '/my/account'
153 148 end
154 149
155 should_set_the_flash_to /reset/
156 should_redirect_to('my account') {'/my/account' }
157 end
158
159 context "with no rss_token" do
160 setup do
150 def test_reset_rss_key_without_existing_key
161 151 assert_nil User.find(2).rss_token
162 152 post :reset_rss_key
163 end
164 153
165 should "create a new token" do
166 154 assert User.find(2).rss_token
155 assert_match /reset/, flash[:notice]
156 assert_redirected_to '/my/account'
167 157 end
168 158
169 should_set_the_flash_to /reset/
170 should_redirect_to('my account') {'/my/account' }
171 end
172 end
173
174 context "POST to reset_api_key" do
175 context "with an existing api_token" do
176 setup do
159 def test_reset_api_key_with_existing_key
177 160 @previous_token_value = User.find(2).api_key # Will generate one if it's missing
178 161 post :reset_api_key
179 end
180 162
181 should "destroy the existing token" do
182 163 assert_not_equal @previous_token_value, User.find(2).api_key
183 end
184
185 should "create a new token" do
186 164 assert User.find(2).api_token
165 assert_match /reset/, flash[:notice]
166 assert_redirected_to '/my/account'
187 167 end
188 168
189 should_set_the_flash_to /reset/
190 should_redirect_to('my account') {'/my/account' }
191 end
192
193 context "with no api_token" do
194 setup do
169 def test_reset_api_key_without_existing_key
195 170 assert_nil User.find(2).api_token
196 171 post :reset_api_key
197 end
198 172
199 should "create a new token" do
200 173 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
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