@@ -27,6 +27,7 @@ import (
2727
2828 "github.com/PuerkitoBio/goquery"
2929 "github.com/stretchr/testify/assert"
30+ "github.com/stretchr/testify/require"
3031)
3132
3233func TestRepoView (t * testing.T ) {
@@ -41,6 +42,7 @@ func TestRepoView(t *testing.T) {
4142 t .Run ("BlameFileInRepo" , testBlameFileInRepo )
4243 t .Run ("ViewRepoDirectory" , testViewRepoDirectory )
4344 t .Run ("ViewRepoDirectoryReadme" , testViewRepoDirectoryReadme )
45+ t .Run ("ViewRepoSymlink" , testViewRepoSymlink )
4446 t .Run ("MarkDownReadmeImage" , testMarkDownReadmeImage )
4547 t .Run ("MarkDownReadmeImageSubfolder" , testMarkDownReadmeImageSubfolder )
4648 t .Run ("GeneratedSourceLink" , testGeneratedSourceLink )
@@ -412,6 +414,21 @@ func testViewRepoDirectoryReadme(t *testing.T) {
412414 missing ("symlink-loop" , "/user2/readme-test/src/branch/symlink-loop/" )
413415}
414416
417+ func testViewRepoSymlink (t * testing.T ) {
418+ session := loginUser (t , "user2" )
419+ req := NewRequest (t , "GET" , "/user2/readme-test/src/branch/symlink" )
420+ resp := session .MakeRequest (t , req , http .StatusOK )
421+
422+ htmlDoc := NewHTMLParser (t , resp .Body )
423+ AssertHTMLElement (t , htmlDoc , ".entry-symbol-link" , true )
424+ followSymbolLinkHref := htmlDoc .Find (".entry-symbol-link" ).AttrOr ("href" , "" )
425+ require .Equal (t , "/user2/readme-test/src/branch/symlink/README.md?follow_symlink=1" , followSymbolLinkHref )
426+
427+ req = NewRequest (t , "GET" , followSymbolLinkHref )
428+ resp = session .MakeRequest (t , req , http .StatusSeeOther )
429+ assert .Equal (t , "/user2/readme-test/src/branch/symlink/some/other/path/awefulcake.txt?follow_symlink=1" , resp .Header ().Get ("Location" ))
430+ }
431+
415432func testMarkDownReadmeImage (t * testing.T ) {
416433 defer tests .PrintCurrentTest (t )()
417434
0 commit comments