From fb9e7b59485c2882d9f9323fbf196d14dc954464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Silva=20Sim=C3=B5es?= Date: Thu, 24 Jan 2019 22:07:15 -0500 Subject: [PATCH 1/3] Revert #3711 overwrite on #2167 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Silva Simões --- templates/repo/home.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 0a5886381d420..af5ae9723ada6 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -5,7 +5,7 @@ {{template "base/alert" .}}
- {{if .Repository.DescriptionHTML}}{{.Repository.DescriptionHTML}}{{else}}{{.i18n.Tr "repo.no_desc"}}{{end}} + {{if .Repository.DescriptionHTML}}{{.Repository.DescriptionHTML}}{{else if .IsRepositoryAdmin}}{{.i18n.Tr "repo.no_desc"}}{{end}} {{.Repository.Website}}
{{if .RepoSearchEnabled}} From ace7ca3a2ba74bb354975388e1295d762cd26c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Silva=20Sim=C3=B5es?= Date: Fri, 25 Jan 2019 15:51:54 -0500 Subject: [PATCH 2/3] Add tests for PR #2167 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Silva Simões --- integrations/repo_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/integrations/repo_test.go b/integrations/repo_test.go index 165009faa2705..4d5c9f5904f1a 100644 --- a/integrations/repo_test.go +++ b/integrations/repo_test.go @@ -99,3 +99,27 @@ func TestViewRepoWithSymlinks(t *testing.T) { assert.Equal(t, items[3], "link_hi: octicon octicon-file-symlink-file") assert.Equal(t, items[4], "link_link: octicon octicon-file-symlink-file") } + +// TestViewAsRepoAdmin tests PR #2167 +func TestViewAsRepoAdmin(t *testing.T) { + for user, expectedNoDescription := range map[string]int{ + "user2": 1, + "user3": 0, + } { + prepareTestEnv(t) + + session := loginUser(t, user) + + req := NewRequest(t, "GET", "/user2/repo1.git") + resp := session.MakeRequest(t, req, http.StatusOK) + + htmlDoc := NewHTMLParser(t, resp.Body) + noDescription := htmlDoc.doc.Find("#repo-desc").Children() + + if expectedNoDescription == 0 { + assert.False(t, noDescription.HasClass("no-description")) + } else { + assert.True(t, noDescription.HasClass("no-description")) + } + } +} From 1db9e054f2eed78a7921867bd7211bb48dcee471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Silva=20Sim=C3=B5es?= Date: Sat, 26 Jan 2019 13:24:53 -0500 Subject: [PATCH 3/3] Improve PR #2167 tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change 0/1 to false/true and remove repetitive code Signed-off-by: Gabriel Silva Simões --- integrations/repo_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/integrations/repo_test.go b/integrations/repo_test.go index 4d5c9f5904f1a..36672ff62a4aa 100644 --- a/integrations/repo_test.go +++ b/integrations/repo_test.go @@ -102,9 +102,9 @@ func TestViewRepoWithSymlinks(t *testing.T) { // TestViewAsRepoAdmin tests PR #2167 func TestViewAsRepoAdmin(t *testing.T) { - for user, expectedNoDescription := range map[string]int{ - "user2": 1, - "user3": 0, + for user, expectedNoDescription := range map[string]bool{ + "user2": true, + "user3": false, } { prepareTestEnv(t) @@ -116,10 +116,6 @@ func TestViewAsRepoAdmin(t *testing.T) { htmlDoc := NewHTMLParser(t, resp.Body) noDescription := htmlDoc.doc.Find("#repo-desc").Children() - if expectedNoDescription == 0 { - assert.False(t, noDescription.HasClass("no-description")) - } else { - assert.True(t, noDescription.HasClass("no-description")) - } + assert.Equal(t, expectedNoDescription, noDescription.HasClass("no-description")) } }