1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-03 07:55:36 +00:00

Fix default repo re-creation bug when web login after desktop

This commit is contained in:
zhengxie
2016-02-01 11:54:02 +08:00
parent 55a23c6926
commit 52b661147e
4 changed files with 111 additions and 8 deletions

View File

@@ -0,0 +1,31 @@
import json
from django.core.urlresolvers import reverse
from seahub.options.models import UserOptions
from seahub.test_utils import BaseTestCase
class DefaultRepoTest(BaseTestCase):
def setUp(self):
self.login_as(self.user)
self.endpoint = reverse('api2-defaultrepo')
def test_default_repo_missing_on_get(self):
resp = self.client.get(self.endpoint)
json_resp = json.loads(resp.content)
assert json_resp['exists'] is False
def test_create_default_repo_on_post(self):
username = self.user.username
assert UserOptions.objects.get_default_repo(username) is None
assert UserOptions.objects.is_user_guide_enabled(username) is True
resp = self.client.post(self.endpoint)
json_resp = json.loads(resp.content)
assert json_resp['exists'] is True
assert len(json_resp['repo_id']) == 36
assert UserOptions.objects.get_default_repo(username) is not None
# so that, default repo won't be created again during web login
assert UserOptions.objects.is_user_guide_enabled(username) is False