Fix usericons (#1408)
* Fix and refactor user icons, add Basic tests * Remove identicon_canvas, use identicon.js * Use octicon by default
This commit is contained in:
+1
-1
@@ -54,7 +54,7 @@ context "Frontend" do
|
||||
{ :name => 'user1', :email => 'user1' });
|
||||
|
||||
get page
|
||||
expected = "<h2 class=\"editable\"><a class=\"anchor\" (href|id)=\"(#)?#{text}\" (href|id)=\"(#)?#{text}\"><i class=\"fa fa-link\"></i></a>#{text}</h2>"
|
||||
expected = "<h2 class=\"editable\"><a class=\"anchor\" (href|id)=\"(#)?#{text}\" (href|id)=\"(#)?#{text}\"></a>#{text}</h2>"
|
||||
actual = nfd(last_response.body)
|
||||
|
||||
assert_match /#{expected}/, actual
|
||||
|
||||
@@ -7,19 +7,5 @@ context "Precious::Views::History" do
|
||||
@history = Precious::Views::History.new
|
||||
end
|
||||
|
||||
test "string_to_code" do
|
||||
# Result must match the following Java code.
|
||||
=begin
|
||||
public static void main(String[] args) throws Exception {
|
||||
final String s = "code@example.com";
|
||||
final byte[] b = MessageDigest.getInstance("SHA1").digest(s.toString().getBytes("UTF-8"));
|
||||
final int c = ((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16)
|
||||
| ((b[2] & 0xFF) << 8) | (b[3] & 0xFF);
|
||||
// 143327882
|
||||
System.out.println(c);
|
||||
}
|
||||
=end
|
||||
actual = @history.string_to_code 'code@example.com'
|
||||
assert_equal 143327882, actual
|
||||
end
|
||||
# No tests yet
|
||||
end
|
||||
|
||||
@@ -12,12 +12,13 @@ context "Precious::Views::LatestChanges" do
|
||||
setup do
|
||||
@path = cloned_testpath("examples/lotr.git")
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
@url = '/gollum/latest_changes'
|
||||
Precious::App.set(:gollum_path, @path)
|
||||
Precious::App.set(:wiki_options, {:pagination_count => 10})
|
||||
end
|
||||
|
||||
test "displays_latest_changes" do
|
||||
get('/gollum/latest_changes')
|
||||
get(@url)
|
||||
body = last_response.body
|
||||
|
||||
assert body.include?("Charles Pence</span>"), "/latest_changes should include Author Charles Pence"
|
||||
@@ -27,6 +28,20 @@ context "Precious::Views::LatestChanges" do
|
||||
assert body.include?('<a href="Hobbit.md/874f597a5659b4c3b153674ea04e406ff393975e">Hobbit.md</a>'), "/latest_changes should include links to modified pages in #{body}"
|
||||
end
|
||||
|
||||
test 'gravatar' do
|
||||
Precious::App.set(:wiki_options, {:user_icons => 'gravatar'})
|
||||
get @url
|
||||
assert last_response.body.include?('<img src="https://secure.gravatar.com/'), "gravatar icon missing from #{@url}"
|
||||
Precious::App.set(:wiki_options, {:user_icons => 'none'})
|
||||
end
|
||||
|
||||
test 'identicon' do
|
||||
Precious::App.set(:wiki_options, {:user_icons => 'identicon'})
|
||||
get @url
|
||||
assert last_response.body.include?('class="identicon" data-identicon="'), "identicon icon missing from #{@url}"
|
||||
Precious::App.set(:wiki_options, {:user_icons => 'none'})
|
||||
end
|
||||
|
||||
test "extract destination file name in case of path renaming" do
|
||||
view = Precious::Views::LatestChanges.new
|
||||
assert_equal "newname.md", view.extract_renamed_path_destination("oldname.md => newname.md")
|
||||
@@ -36,4 +51,4 @@ context "Precious::Views::LatestChanges" do
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user