File tree 3 files changed +26
-0
lines changed
3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -357,6 +357,8 @@ impl Crate {
357
357
. map ( |v| v. to_string ( ) )
358
358
. unwrap_or_else ( || "0.0.0" . to_string ( ) ) ;
359
359
360
+ let max_stable_version = top_versions. highest_stable . as_ref ( ) . map ( |v| v. to_string ( ) ) ;
361
+
360
362
EncodableCrate {
361
363
id : name. clone ( ) ,
362
364
name : name. clone ( ) ,
@@ -370,6 +372,7 @@ impl Crate {
370
372
badges,
371
373
max_version,
372
374
newest_version,
375
+ max_stable_version,
373
376
documentation,
374
377
homepage,
375
378
exact_match,
Original file line number Diff line number Diff line change @@ -508,6 +508,27 @@ fn yanked_versions_are_not_considered_for_max_version() {
508
508
assert_eq ! ( json. crates[ 0 ] . max_version, "1.0.0" ) ;
509
509
}
510
510
511
+ #[ test]
512
+ fn max_stable_version ( ) {
513
+ let ( app, anon, user) = TestApp :: init ( ) . with_user ( ) ;
514
+ let user = user. as_model ( ) ;
515
+
516
+ app. db ( |conn| {
517
+ CrateBuilder :: new ( "foo" , user. id )
518
+ . description ( "foo" )
519
+ . version ( "0.3.0" )
520
+ . version ( "1.0.0" )
521
+ . version ( VersionBuilder :: new ( "1.1.0" ) . yanked ( true ) )
522
+ . version ( "2.0.0-beta.1" )
523
+ . version ( "0.3.1" )
524
+ . expect_build ( conn) ;
525
+ } ) ;
526
+
527
+ let json = anon. search ( "q=foo" ) ;
528
+ assert_eq ! ( json. meta. total, 1 ) ;
529
+ assert_eq ! ( json. crates[ 0 ] . max_stable_version, Some ( "1.0.0" . to_string( ) ) ) ;
530
+ }
531
+
511
532
/* Given two crates, one with downloads less than 90 days ago, the
512
533
other with all downloads greater than 90 days ago, check that
513
534
the order returned is by recent downloads, descending. Check
Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ pub struct EncodableCrate {
156
156
// NOTE: Used by shields.io, altering `max_version` requires a PR with shields.io
157
157
pub max_version : String ,
158
158
pub newest_version : String , // Most recently updated version, which may not be max
159
+ pub max_stable_version : Option < String > ,
159
160
pub description : Option < String > ,
160
161
pub homepage : Option < String > ,
161
162
pub documentation : Option < String > ,
@@ -510,6 +511,7 @@ mod tests {
510
511
recent_downloads : None ,
511
512
max_version : "" . to_string ( ) ,
512
513
newest_version : "" . to_string ( ) ,
514
+ max_stable_version : None ,
513
515
description : None ,
514
516
homepage : None ,
515
517
documentation : None ,
You can’t perform that action at this time.
0 commit comments