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