Showing 2 changed files with 33 additions and 10 deletions
+24 -10
templates/fork.html.ep
... ...
@@ -18,7 +18,8 @@
18 18
   if ($vresult->is_ok) {
19 19
     unless ($logined) {
20 20
       $self->redirect_to("/$user/$project");
21
-      return 1;
21
+      $self->finish_rendering;
22
+      return;
22 23
     }
23 24
     
24 25
     my $login_user = session('user');
... ...
@@ -28,22 +29,35 @@
28 29
     
29 30
     if ($login_user eq $user) {
30 31
       $self->redirect_to("/$user/$project");
31
-      return 1;
32
+      $self->finish_rendering;
33
+      return;
32 34
     }
33 35
     
34
-    eval { app->manager->fork_project($login_user, $user, $project) };
35
-    if ($@) {
36
-      $self->render_exception($@);
37
-      return $self->res->body;
36
+    # Already exists
37
+    if (app->manager->exists_project($login_user, $project)) {
38
+      $self->redirect_to("/$login_user/$project");
39
+      $self->finish_rendering;
40
+      return;
38 41
     }
42
+    # Fork
39 43
     else {
40
-      flash('original_project', "$user/$project");
41
-      $self->redirect_to("/$login_user/$project");
42
-      return 1;
44
+      eval { app->manager->fork_project($login_user, $user, $project) };
45
+      if ($@) {
46
+        $self->render_exception($@);
47
+        $self->finish_rendering;
48
+        return;
49
+      }
50
+      else {
51
+        flash('original_project', "$user/$project");
52
+        $self->redirect_to("/$login_user/$project");
53
+        $self->finish_rendering;
54
+        return;
55
+      }
43 56
     }
44 57
   }
45 58
   else {
46 59
     $self->redirect_to("/$user/$project");
47
-    return 1;
60
+    $self->finish_rendering;
61
+    return;
48 62
   }
49 63
 %>
+9
xt/basic.t
... ...
@@ -301,4 +301,13 @@ note 'Compare page';
301 301
   $t->get_ok("/$user/$project/compare/refs/heads/b1...refs/heads/master");
302 302
   $t->content_like(qr#renamed dir/a\.txt to dir/b\.txt and added text#);
303 303
 
304
+}
305
+
306
+note 'API References';
307
+{
308
+  # Page access (branch name)
309
+  $t->get_ok("/$user/$project/api/revs");
310
+  my $content = $t->tx->res->body;
311
+  like($content, qr/branch_names/);
312
+  like($content, qr/tag_names/);
304 313
 }