File tree 2 files changed +49
-1
lines changed
2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -430,6 +430,51 @@ def test_builds_current_is_latest_one(self):
430
430
# ``a1b2c3-9``is the latest successful build object created
431
431
assert r .json ()["builds" ]["current" ]["commit" ] == "a1b2c3-9"
432
432
433
+ def test_builds_current_is_latest_one_without_url_parameter (self ):
434
+ # Create 10 successful build objects
435
+ # The latest one (ordered by date) will be ``a1b2c3-9``
436
+ for i in range (10 ):
437
+ fixture .get (
438
+ Build ,
439
+ date = timezone .now (),
440
+ project = self .project ,
441
+ version = self .version ,
442
+ commit = f"a1b2c3-{ i } " ,
443
+ length = 60 ,
444
+ state = "finished" ,
445
+ success = True ,
446
+ )
447
+
448
+ # Latest failed build
449
+ fixture .get (
450
+ Build ,
451
+ date = timezone .now (),
452
+ project = self .project ,
453
+ version = self .version ,
454
+ commit = f"a1b2c3-failed" ,
455
+ length = 60 ,
456
+ state = "finished" ,
457
+ success = False ,
458
+ )
459
+
460
+ r = self .client .get (
461
+ reverse ("proxito_readthedocs_docs_addons" ),
462
+ {
463
+ "project-slug" : "project" ,
464
+ "version-slug" : "latest" ,
465
+ "client-version" : "0.6.0" ,
466
+ "api-version" : "0.1.0" ,
467
+ },
468
+ secure = True ,
469
+ headers = {
470
+ "host" : "project.dev.readthedocs.io" ,
471
+ },
472
+ )
473
+ assert r .status_code == 200
474
+
475
+ # ``a1b2c3-9``is the latest successful build object created
476
+ assert r .json ()["builds" ]["current" ]["commit" ] == "a1b2c3-9"
477
+
433
478
def test_project_subproject (self ):
434
479
subproject = fixture .get (
435
480
Project ,
Original file line number Diff line number Diff line change @@ -114,7 +114,10 @@ def _resolve_resources(self):
114
114
project = Project .objects .filter (slug = project_slug ).first ()
115
115
version = Version .objects .filter (slug = version_slug , project = project ).first ()
116
116
if version :
117
- build = version .builds .first ()
117
+ build = version .builds .filter (
118
+ success = True ,
119
+ state = BUILD_STATE_FINISHED ,
120
+ ).first ()
118
121
119
122
return project , version , build , filename
120
123
You can’t perform that action at this time.
0 commit comments