Refactor RSS view renderer
In issue #1815, it was reported that Gollum RSS feeds attempt to put entire commit messages into a feed item's `<title>` element. Given that commit messages can be many paragraphs long, this is not an acceptable way to render a feed item title. If a commit has many lines or paragraphs, we now put those inside the `<description>` element as of this commit. While I was editing this view, I decided it would be a good time to increase test coverage, as this view renderer was not under test at all. I also fixed a typo ("Commited" should say "Committed"). There are implicit dependencies on other gems that provide the `Gollum::Git::Commit`, `Gollum::Git::Actor`, and `Rugged::Commit` classes here, so mocking out simple versions of their interfaces seemed like the path of least resistance to setting up controllable tests. I also removed some now-duplicated assertions from `test/test_app.rb`.
This commit is contained in:
committed by
benjamin wil
parent
738d6f6ec4
commit
10ae969139
+10
-18
@@ -63,18 +63,10 @@ context "Frontend" do
|
||||
end
|
||||
|
||||
test 'rss feed' do
|
||||
channel_title = <<EOF
|
||||
<title>Gollum Wiki Latest Changes</title>
|
||||
EOF
|
||||
item = <<EOF
|
||||
<description>Commited by: <a href="mailto:dawa.ometto@phil.uu.nl">Dawa Ometto</a><br/>Commit ID: 02796b1<br/><br/>Affected files:<ul><li><a href="http://example.org/custom.css/02796b1450691f90db5d6dc6a816a4980ce80d07">custom.css</a></li><li><a href="http://example.org/custom.js/02796b1450691f90db5d6dc6a816a4980ce80d07">custom.js</a></li></ul></description>
|
||||
EOF
|
||||
get '/gollum/feed/'
|
||||
|
||||
assert last_response.ok?
|
||||
assert_equal 'application/rss+xml', last_response.headers['Content-Type']
|
||||
assert last_response.body.start_with?('<?xml')
|
||||
assert last_response.body.include?(item)
|
||||
assert last_response.body.include?(channel_title)
|
||||
end
|
||||
|
||||
test "show sidebar, header, footer when present" do
|
||||
@@ -477,7 +469,7 @@ EOF
|
||||
assert_equal 'abc', file.raw_data
|
||||
Precious::App.set(:wiki_options, {allow_uploads: false})
|
||||
end
|
||||
|
||||
|
||||
test "upload a file with mode page" do
|
||||
temp_upload_file = Tempfile.new(['upload', '.file']) << "abc\r"
|
||||
temp_upload_file.close
|
||||
@@ -491,7 +483,7 @@ EOF
|
||||
assert_equal "abc\r", file.raw_data
|
||||
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
|
||||
end
|
||||
|
||||
|
||||
test "upload a file with valid extension" do
|
||||
temp_upload_file = Tempfile.new(['upload', '.txt']) << "abc\r"
|
||||
temp_upload_file.close
|
||||
@@ -505,7 +497,7 @@ EOF
|
||||
assert_equal "abc", file.raw_data
|
||||
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
|
||||
end
|
||||
|
||||
|
||||
test 'upload a file with mode page from the edit page (drag and drop)' do
|
||||
temp_upload_file = Tempfile.new(['upload', '.file']) << "abc\r"
|
||||
temp_upload_file.close
|
||||
@@ -517,9 +509,9 @@ EOF
|
||||
# Find the file in a page-specific subdir (here: foo/Bar), based on referer
|
||||
file = @wiki.file("uploads/foo/Bar/#{::File.basename(temp_upload_file.path)}")
|
||||
assert_equal "abc\r", file.raw_data
|
||||
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
|
||||
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
|
||||
end
|
||||
|
||||
|
||||
test "upload a file with https referer" do
|
||||
temp_upload_file = Tempfile.new(['https_upload', '.file']) << 'abc'
|
||||
temp_upload_file.close
|
||||
@@ -1066,7 +1058,7 @@ context 'Frontend with base path' do
|
||||
assert last_response.ok?
|
||||
assert_equal '/wiki/gollum/history/Bilbo-Baggins.md', last_request.fullpath
|
||||
end
|
||||
|
||||
|
||||
test 'upload a file with mode page from the edit page (drag and drop)' do
|
||||
temp_upload_file = Tempfile.new(['upload', '.file']) << "abc\r"
|
||||
temp_upload_file.close
|
||||
@@ -1078,9 +1070,9 @@ context 'Frontend with base path' do
|
||||
# Find the file in a page-specific subdir (here: foo/Bar), based on referer
|
||||
file = @wiki.file("uploads/foo/Bar/#{::File.basename(temp_upload_file.path)}")
|
||||
assert_equal "abc\r", file.raw_data
|
||||
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
|
||||
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
|
||||
end
|
||||
|
||||
|
||||
def app
|
||||
Precious::MapGollum.new(@base_path)
|
||||
end
|
||||
@@ -1148,4 +1140,4 @@ context "Default keybindings" do
|
||||
def app
|
||||
Precious::App
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user