Commits

Marcin Kuzminski committed f955967

added tests for forks and followers pages

  • Participants
  • Parent commits a16f163
  • Branches beta

Comments (0)

Files changed (4)

File rhodecode/controllers/followers.py

 
     def followers(self, repo_name):
         p = int(request.params.get('page', 1))
-        repo_id = Repository.by_repo_name(repo_name).repo_id
+        repo_id = c.rhodecode_db_repo.repo_id
         d = UserFollowing.get_repo_followers(repo_id)\
             .order_by(UserFollowing.follows_from)
         c.followers_pager = Page(d, page=p, items_per_page=20)

File rhodecode/controllers/forks.py

 
     def forks(self, repo_name):
         p = int(request.params.get('page', 1))
-        repo_id = Repository.by_repo_name(repo_name).repo_id
+        repo_id = c.rhodecode_db_repo.repo_id
         d = Repository.get_repo_forks(repo_id)
         c.forks_pager = Page(d, page=p, items_per_page=20)
 

File rhodecode/tests/functional/test_followers.py

+from rhodecode.tests import *
+
+class TestFollowersController(TestController):
+
+    def test_index(self):
+        self.log_user()
+        repo_name = HG_REPO
+        response = self.app.get(url(controller='followers',
+                                    action='followers',
+                                    repo_name=repo_name))
+
+        self.assertTrue("""test_admin""" in response.body)
+        self.assertTrue("""Started following""" in response.body)

File rhodecode/tests/functional/test_forks.py

+from rhodecode.tests import *
+
+from rhodecode.model.db import Repository
+
+class TestForksController(TestController):
+
+    def test_index(self):
+        self.log_user()
+        repo_name = HG_REPO
+        response = self.app.get(url(controller='forks', action='forks',
+                                    repo_name=repo_name))
+
+        self.assertTrue("""There are no forks yet""" in response.body)
+
+
+    def test_index_with_fork(self):
+        self.log_user()
+
+        # create a fork
+        fork_name = HG_FORK
+        description = 'fork of vcs test'
+        repo_name = HG_REPO
+        response = self.app.post(url(controller='settings',
+                                     action='fork_create',
+                                    repo_name=repo_name),
+                                    {'fork_name':fork_name,
+                                     'repo_type':'hg',
+                                     'description':description,
+                                     'private':'False'})
+
+        response = self.app.get(url(controller='forks', action='forks',
+                                    repo_name=repo_name))
+
+
+        self.assertTrue("""<a href="/%s/summary">"""
+                         """vcs_test_hg_fork</a>""" % fork_name
+                         in response.body)
+
+        #remove this fork
+        response = self.app.delete(url('repo', repo_name=fork_name))
+