Skip to content

Commit d5a3784

Browse files
sypharGuillaumeGomez
authored andcommitted
fix wrong code-branch icon variant in crate-details
1 parent 83909af commit d5a3784

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

src/web/crate_details.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,44 @@ mod tests {
15831583
});
15841584
}
15851585

1586+
#[test]
1587+
fn details_with_repository_and_stats_can_render_icon() {
1588+
wrapper(|env| {
1589+
env.fake_release()
1590+
.name("library")
1591+
.version("0.1.0")
1592+
.repo("https://github.com/org/repo")
1593+
.github_stats("org/repo", 10, 10, 10)
1594+
.create()?;
1595+
1596+
let page = kuchikiki::parse_html().one(
1597+
env.frontend()
1598+
.get("/crate/library/0.1.0/")
1599+
.send()?
1600+
.error_for_status()?
1601+
.text()?,
1602+
);
1603+
1604+
let link = page
1605+
.select_first("a.pure-menu-link[href='https://github.com/org/repo']")
1606+
.unwrap();
1607+
1608+
let icon_node = link.as_node().children().nth(1).unwrap();
1609+
assert_eq!(
1610+
icon_node
1611+
.as_element()
1612+
.unwrap()
1613+
.attributes
1614+
.borrow()
1615+
.get("class")
1616+
.unwrap(),
1617+
"fa-svg"
1618+
);
1619+
1620+
Ok(())
1621+
});
1622+
}
1623+
15861624
#[test]
15871625
fn feature_flags_report_null() {
15881626
wrapper(|env| {

src/web/page/templates.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::error::Result;
22
use crate::web::rustdoc::RustdocPage;
3-
use anyhow::Context;
3+
use anyhow::{anyhow, Context};
44
use rinja::Template;
55
use std::{fmt, sync::Arc};
66
use tracing::trace;
@@ -267,8 +267,16 @@ impl IconType {
267267
IconType::Brand => font_awesome_as_a_crate::Type::Brands,
268268
};
269269

270-
let icon_file_string = font_awesome_as_a_crate::svg(type_, icon_name)
271-
.map_err(|err| rinja::Error::Custom(Box::new(err)))?;
270+
let icon_file_string = font_awesome_as_a_crate::svg(type_, icon_name).map_err(|err| {
271+
rinja::Error::Custom(
272+
anyhow!(err)
273+
.context(format!(
274+
"error trying to render icon with name \"{}\" and type \"{}\"",
275+
icon_name, type_,
276+
))
277+
.into(),
278+
)
279+
})?;
272280

273281
let mut classes = vec!["fa-svg"];
274282
if fw {

templates/crate/details.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
{# If the repo link is for github or gitlab, show some stats #}
6565
{# TODO: add support for hosts besides github and gitlab (#35) #}
6666
{%- if let Some(repository_metadata) = repository_metadata -%}
67-
{{ "code-branch"|fab(false, false, "") }}
67+
{{ "code-branch"|fas(false, false, "") }}
6868
{% if let Some(name) = repository_metadata.name %}
6969
{{name}}
7070
{% else %}

0 commit comments

Comments
 (0)