Skip to content

Commit

Permalink
Fixed navigating into folders in branches. Fix #541
Browse files Browse the repository at this point in the history
  • Loading branch information
RedX2501 committed Jun 21, 2016
1 parent fef3fa7 commit 70b45d7
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 8 deletions.
Expand Up @@ -306,5 +306,6 @@ public void AnonymousPushModeNotAcceptInvalidValueWhenCreatingRepo()

ITH.AssertThatValidationErrorContains(Resources.Repository_Edit_InvalidAnonymousPushMode);
}

}
}
47 changes: 47 additions & 0 deletions Bonobo.Git.Server.Test/IntegrationTests/MsysgitIntegrationTests.cs
Expand Up @@ -4,6 +4,8 @@
using Bonobo.Git.Server.Test.IntegrationTests;
using Bonobo.Git.Server.Test.IntegrationTests.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Support.UI;
using SpecsFor.Mvc;
using System;
Expand Down Expand Up @@ -484,6 +486,51 @@ public void CheckTagLinksWorkInViews()
});
}

[TestMethod, TestCategory(TestCategories.IntegrationTest)]
public void CanNavigateIntoBranchesFolder()
{
ForAllGits(git =>
{
var repo = ITH.CreateRepositoryOnWebInterface(RepositoryName);
CloneEmptyRepositoryWithCredentials(git);
CreateIdentity(git);
CreateAndAddTestFiles(git, 1);
RunGitOnRepo(git, "branch branchX");
Directory.CreateDirectory(Path.Combine(RepositoryDirectory, "dir1"));
File.Create(Path.Combine(RepositoryDirectory, "dir1", "file1.txt")).Close();
RunGitOnRepo(git, "add dir1").ExpectSuccess();
RunGitOnRepo(git, "commit -m\"dir1 on master\"").ExpectSuccess();
RunGitOnRepo(git, "push --set-upstream origin master").ExpectSuccess();
RunGitOnRepo(git, "checkout branchX").ExpectSuccess();
Directory.CreateDirectory(Path.Combine(RepositoryDirectory, "dir2"));
File.Create(Path.Combine(RepositoryDirectory, "dir2", "file2.txt")).Close();
RunGitOnRepo(git, "add dir2").ExpectSuccess();
RunGitOnRepo(git, "commit -m\"dir2 on branchX\"").ExpectSuccess();
RunGitOnRepo(git, "push --set-upstream origin branchX").ExpectSuccess();
app.NavigateTo<RepositoryController>(c => c.Tree(repo, null, null));
var elements = app.Browser.FindElementsByCssSelector("table#files td.path a.directory");
Assert.AreEqual(1, elements.Count);
Assert.AreEqual("dir1", elements[0].Text);
elements[0].Click();
app.WaitForElementToBeVisible(By.CssSelector("nav.branches"), TimeSpan.FromSeconds(1));
app.UrlShouldMapTo<RepositoryController>(c => c.Tree(repo, null, "dir1"));
app.NavigateTo<RepositoryController>(c => c.Tree(repo, "branchX", null));
app.WaitForElementToBeVisible(By.CssSelector("nav.branches"), TimeSpan.FromSeconds(1));
app.UrlShouldMapTo<RepositoryController>(c => c.Tree(repo, "branchX", null));
elements = app.Browser.FindElementsByCssSelector("table#files td.path a.directory");
Assert.AreEqual(1, elements.Count);
Assert.AreEqual("dir2", elements[0].Text);
elements[0].Click();
app.WaitForElementToBeVisible(By.CssSelector("nav.branches"), TimeSpan.FromSeconds(1));
app.UrlShouldMapTo<RepositoryController>(c => c.Tree(repo, "branchX", "dir2"));
ITH.DeleteRepositoryUsingWebsite(repo);
});

}

/// <summary>
/// Helper to run a test for every installed Git instance
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions Bonobo.Git.Server/Views/Repository/Blob.cshtml
Expand Up @@ -13,10 +13,10 @@
@{
<div class="controls">
<span>@(Model.IsText ? Model.Text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None).Length + " lines |" : "") @FileDisplayHandler.GetFileSizeString(Model.Data.LongLength)</span>
<a href="@Url.Action("Blame", new { id=ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true)})"><i class="fa fa-comments"></i> @Resources.Repository_Tree_Blame</a>
<a href="@Url.Action("History", new { id=ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true)})"><i class="fa fa-history"></i> @Resources.Repository_Tree_History</a>
<a href="@Url.Action("Raw", new { id=ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true), display = true })"><i class="fa fa-file-text"></i> @Resources.Repository_Tree_RawDisplay</a>
<a href="@Url.Action("Raw", new { id=ViewBag.ID, encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-download"></i> @Resources.Repository_Tree_Download</a>
<a href="@Url.Action("Blame", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true)})"><i class="fa fa-comments"></i> @Resources.Repository_Tree_Blame</a>
<a href="@Url.Action("History", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true)})"><i class="fa fa-history"></i> @Resources.Repository_Tree_History</a>
<a href="@Url.Action("Raw", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true), display = true })"><i class="fa fa-file-text"></i> @Resources.Repository_Tree_RawDisplay</a>
<a href="@Url.Action("Raw", new { id=ViewBag.ID, encodedName = PathEncoder.Encode(Model.TreeName), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-download"></i> @Resources.Repository_Tree_Download</a>
</div>
}
@if (Model.IsImage)
Expand Down
6 changes: 3 additions & 3 deletions Bonobo.Git.Server/Views/Repository/Tree.cshtml
Expand Up @@ -29,11 +29,11 @@
}
else if (item.IsTree)
{
@Html.ActionLink(item.Name, "Tree", new { id= ViewBag.ID, encodedPath = PathEncoder.Encode(item.Path, allowSlash: true) }, new { @class = "directory" })
@Html.ActionLink(item.Name, "Tree", new { id= ViewBag.ID, encodedName = PathEncoder.Encode(Model.Branch), encodedPath = PathEncoder.Encode(item.Path, allowSlash: true) }, new { @class = "directory" })
}
else
{
@Html.ActionLink(item.Name, "Blob", new { id = ViewBag.ID, encodedPath = PathEncoder.Encode(item.Path, allowSlash: true) }, new { @class = item.IsImage ? "image" : "file" })
@Html.ActionLink(item.Name, "Blob", new { id = ViewBag.ID, encodedName = PathEncoder.Encode(Model.Branch), encodedPath = PathEncoder.Encode(item.Path, allowSlash: true) }, new { @class = item.IsImage ? "image" : "file" })
}
</td>
<td class="message"></td>
Expand All @@ -50,7 +50,7 @@

<div class="pure-menu pure-menu-open pure-menu-horizontal repository-menu">
<ul>
<li><a href="@Url.Action("Download", new { encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-download"></i>@Resources.Repository_Tree_Zip</a></li>
<li><a href="@Url.Action("Download", new { encodedName = PathEncoder.Encode(Model.Branch), encodedPath = PathEncoder.Encode(Model.Path, allowSlash: true) })"><i class="fa fa-download"></i>@Resources.Repository_Tree_Zip</a></li>
</ul>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion Bonobo.Git.Server/Views/Repository/_AddressBar.cshtml
Expand Up @@ -22,7 +22,7 @@
}
else
{
@Html.ActionLink(dirs[i], "Tree", new { encodedPath = PathEncoder.Encode(currentPath, allowSlash: true), id = ViewBag.ID })
@Html.ActionLink(dirs[i], "Tree", new { encodedName = PathEncoder.Encode((string)ViewData["referenceName"]), encodedPath = PathEncoder.Encode(currentPath, allowSlash: true), id = ViewBag.ID })
}

if (i + 1 != dirs.Length)
Expand Down

0 comments on commit 70b45d7

Please sign in to comment.