##// END OF EJS Templates
Make sure the RSS token is getting destroyed and created....
Eric Davis -
r3096:e1013c44a3b7
parent child
Show More
@@ -97,8 +97,12 class MyController < ApplicationController
97
97
98 # Create a new feeds key
98 # Create a new feeds key
99 def reset_rss_key
99 def reset_rss_key
100 if request.post? && User.current.rss_token
100 if request.post?
101 User.current.rss_token.destroy
101 if User.current.rss_token
102 User.current.rss_token.destroy
103 User.current.reload
104 end
105 User.current.rss_key
102 flash[:notice] = l(:notice_feeds_access_key_reseted)
106 flash[:notice] = l(:notice_feeds_access_key_reseted)
103 end
107 end
104 redirect_to :action => 'account'
108 redirect_to :action => 'account'
@@ -129,4 +129,38 class MyControllerTest < ActionController::TestCase
129 assert_response :success
129 assert_response :success
130 assert_equal ['documents', 'calendar', 'latestnews'], User.find(2).pref[:my_page_layout]['left']
130 assert_equal ['documents', 'calendar', 'latestnews'], User.find(2).pref[:my_page_layout]['left']
131 end
131 end
132
133 context "POST to reset_rss_key" do
134 context "with an existing rss_token" do
135 setup do
136 @previous_token_value = User.find(2).rss_key # Will generate one if it's missing
137 post :reset_rss_key
138 end
139
140 should "destroy the existing token" do
141 assert_not_equal @previous_token_value, User.find(2).rss_key
142 end
143
144 should "create a new token" do
145 assert User.find(2).rss_token
146 end
147
148 should_set_the_flash_to /reset/
149 should_redirect_to('my account') {'/my/account' }
150 end
151
152 context "with no rss_token" do
153 setup do
154 assert_nil User.find(2).rss_token
155 post :reset_rss_key
156 end
157
158 should "create a new token" do
159 assert User.find(2).rss_token
160 end
161
162 should_set_the_flash_to /reset/
163 should_redirect_to('my account') {'/my/account' }
164 end
165 end
132 end
166 end
General Comments 0
You need to be logged in to leave comments. Login now