From 6f97d5d625c247c43949687b916bdfaba70f1b87 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 27 Jan 2025 07:58:46 -0800 Subject: [PATCH] Add pubdate for repository rss and add some tests (#33411) Fix #33291 (cherry picked from commit dcd3014567f2b8be3fca01c20c2b3eabdc8f519e) Conflicts: tests/integration/feed_user_test.go trivial context conflict --- routers/web/feed/branch.go | 1 + routers/web/feed/file.go | 1 + tests/integration/feed_repo_test.go | 36 +++++++++++++++++++ ...pi_feed_user_test.go => feed_user_test.go} | 23 ++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 tests/integration/feed_repo_test.go rename tests/integration/{api_feed_user_test.go => feed_user_test.go} (87%) diff --git a/routers/web/feed/branch.go b/routers/web/feed/branch.go index 80ce2ad198..a8a001e0cd 100644 --- a/routers/web/feed/branch.go +++ b/routers/web/feed/branch.go @@ -43,6 +43,7 @@ func ShowBranchFeed(ctx *context.Context, repo *repo.Repository, formatType stri }, Description: commit.Message(), Content: commit.Message(), + Created: commit.Committer.When, }) } diff --git a/routers/web/feed/file.go b/routers/web/feed/file.go index 1ab768ff27..48f87c7c62 100644 --- a/routers/web/feed/file.go +++ b/routers/web/feed/file.go @@ -55,6 +55,7 @@ func ShowFileFeed(ctx *context.Context, repo *repo.Repository, formatType string }, Description: commit.Message(), Content: commit.Message(), + Created: commit.Committer.When, }) } diff --git a/tests/integration/feed_repo_test.go b/tests/integration/feed_repo_test.go new file mode 100644 index 0000000000..f1f56c4f63 --- /dev/null +++ b/tests/integration/feed_repo_test.go @@ -0,0 +1,36 @@ +// Copyright 2025 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package integration + +import ( + "encoding/xml" + "net/http" + "testing" + + "code.gitea.io/gitea/tests" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestFeedRepo(t *testing.T) { + t.Run("RSS", func(t *testing.T) { + defer tests.PrepareTestEnv(t)() + + req := NewRequest(t, "GET", "/user2/repo1.rss") + resp := MakeRequest(t, req, http.StatusOK) + + data := resp.Body.String() + assert.Contains(t, data, `