diff --git a/src/test/fakes.rs b/src/test/fakes.rs index dafae007c..14d6350e4 100644 --- a/src/test/fakes.rs +++ b/src/test/fakes.rs @@ -210,12 +210,8 @@ impl<'a> FakeRelease<'a> { self } - pub(crate) fn features(mut self, opt_features: Option>>) -> Self { - if let Some(features) = opt_features { - self.package.features = features; - } else { - self.package.features = HashMap::new(); - } + pub(crate) fn features(mut self, features: HashMap>) -> Self { + self.package.features = features; self } diff --git a/src/web/crate_details.rs b/src/web/crate_details.rs index 6d874443b..7b326882d 100644 --- a/src/web/crate_details.rs +++ b/src/web/crate_details.rs @@ -751,8 +751,7 @@ mod tests { env.fake_release() .name("library") .version("0.1.0") - .binary(false) - .features(None) + .features(HashMap::new()) .create()?; let page = kuchiki::parse_html().one( @@ -776,8 +775,7 @@ mod tests { env.fake_release() .name("library") .version("0.1.0") - .binary(false) - .features(Some(features)) + .features(features) .create()?; let page = kuchiki::parse_html().one( @@ -801,8 +799,7 @@ mod tests { env.fake_release() .name("library") .version("0.1.0") - .binary(false) - .features(Some(features)) + .features(features) .create()?; let page = kuchiki::parse_html().one( @@ -819,4 +816,29 @@ mod tests { Ok(()) }); } + + #[test] + fn feature_flags_report_null() { + wrapper(|env| { + env.fake_release() + .name("library") + .version("0.1.0") + .features(HashMap::new()) + .create()?; + + env.db().conn().query( + "releases SET features = NULL WHERE release_id = $1", + &[&"0.1.0"], + ); + + let page = kuchiki::parse_html().one( + env.frontend() + .get("/crate/library/0.1.0/features") + .send()? + .text()?, + ); + assert!(page.select_first(r#"p[data-id="null-features"]"#).is_ok()); + Ok(()) + }); + } } diff --git a/templates/crate/features.html b/templates/crate/features.html index 3dc5319c8..c390f5f5a 100644 --- a/templates/crate/features.html +++ b/templates/crate/features.html @@ -34,9 +34,13 @@ {%- endfor -%} + {%- elif metadata.features is defined -%} +
  • + This release does not have any feature flags. +
  • {%- else -%}
  • - Feature flags are not available for this version. + Feature flags data are not available for this release.
  • {%- endif -%} @@ -52,7 +56,7 @@

    {{ metadata.name }}

    {%- else -%} 0 {%- endif -%} - of them being enabled by default.

    + of them enabled by default.

    {%- for feature in metadata.features -%}

    {{ feature.name }}

    {%- endfor -%} + {%- elif metadata.features is defined -%} +

    This release does not have any feature flags.

    {%- else -%} -

    Feature flags are not available for this release.

    +

    Feature flags data are not available for this release.

    {%- endif -%}