##// END OF EJS Templates
Fixed that rss key is generated twice when user is not reloaded (#10668)....
Jean-Philippe Lang -
r9285:24c361eb0a12
parent child
Show More
@@ -284,14 +284,18 class User < Principal
284 284
285 285 # Return user's RSS key (a 40 chars long string), used to access feeds
286 286 def rss_key
287 token = self.rss_token || Token.create(:user => self, :action => 'feeds')
288 token.value
287 if rss_token.nil?
288 create_rss_token(:action => 'feeds')
289 end
290 rss_token.value
289 291 end
290 292
291 293 # Return user's API key (a 40 chars long string), used to access the API
292 294 def api_key
293 token = self.api_token || self.create_api_token(:action => 'api')
294 token.value
295 if api_token.nil?
296 create_api_token(:action => 'api')
297 end
298 api_token.value
295 299 end
296 300
297 301 # Return an array of project ids for which the user has explicitly turned mail notifications on
@@ -585,6 +585,22 class UserTest < ActiveSupport::TestCase
585 585 assert_equal key, @jsmith.rss_key
586 586 end
587 587
588 def test_rss_key_should_not_be_generated_twice
589 assert_difference 'Token.count', 1 do
590 key1 = @jsmith.rss_key
591 key2 = @jsmith.rss_key
592 assert_equal key1, key2
593 end
594 end
595
596 def test_api_key_should_not_be_generated_twice
597 assert_difference 'Token.count', 1 do
598 key1 = @jsmith.api_key
599 key2 = @jsmith.api_key
600 assert_equal key1, key2
601 end
602 end
603
588 604 context "User#api_key" do
589 605 should "generate a new one if the user doesn't have one" do
590 606 user = User.generate_with_protected!(:api_token => nil)
General Comments 0
You need to be logged in to leave comments. Login now