Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions routers/web/feed/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func ShowBranchFeed(ctx *context.Context, repo *repo.Repository, formatType stri
},
Description: commit.Message(),
Content: commit.Message(),
Created: commit.Committer.When,
})
}

Expand Down
1 change: 1 addition & 0 deletions routers/web/feed/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func ShowFileFeed(ctx *context.Context, repo *repo.Repository, formatType string
},
Description: commit.Message(),
Content: commit.Message(),
Created: commit.Committer.When,
})
}

Expand Down
35 changes: 35 additions & 0 deletions tests/integration/feed_repo_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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"
)

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, `<rss version="2.0"`)

var rss RSS
err := xml.Unmarshal(resp.Body.Bytes(), &rss)
assert.NoError(t, err)
assert.Equal(t, "http://localhost:3003/user2/repo1", rss.Channel.Link)
assert.NotEmpty(t, rss.Channel.PubDate)
assert.Len(t, rss.Channel.Items, 1)
assert.EqualValues(t, "issue5", rss.Channel.Items[0].Description)
assert.NotEmpty(t, rss.Channel.Items[0].PubDate)
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package integration

import (
"encoding/xml"
"net/http"
"testing"

Expand All @@ -12,7 +13,23 @@ import (
"github.com/stretchr/testify/assert"
)

func TestFeed(t *testing.T) {
// RSS is a struct to unmarshal RSS feeds test only
type RSS struct {
Channel struct {
Title string `xml:"title"`
Link string `xml:"link"`
Description string `xml:"description"`
PubDate string `xml:"pubDate"`
Items []struct {
Title string `xml:"title"`
Link string `xml:"link"`
Description string `xml:"description"`
PubDate string `xml:"pubDate"`
} `xml:"item"`
} `xml:"channel"`
}

func TestFeedUser(t *testing.T) {
t.Run("User", func(t *testing.T) {
t.Run("Atom", func(t *testing.T) {
defer tests.PrepareTestEnv(t)()
Expand All @@ -32,6 +49,12 @@ func TestFeed(t *testing.T) {

data := resp.Body.String()
assert.Contains(t, data, `<rss version="2.0"`)

var rss RSS
err := xml.Unmarshal(resp.Body.Bytes(), &rss)
assert.NoError(t, err)
assert.Equal(t, "http://localhost:3003/user2", rss.Channel.Link)
assert.NotEmpty(t, rss.Channel.PubDate)
})
})
}
Loading