Merge "Default guideline to latest approved guideline"

This commit is contained in:
Jenkins 2016-07-06 19:03:15 +00:00 committed by Gerrit Code Review
commit fcac21f1bf
4 changed files with 16 additions and 8 deletions

View File

@ -4,9 +4,11 @@
<div class="row">
<div class="col-md-3">
<strong>Version:</strong>
<select ng-model="ctrl.version" ng-change="ctrl.update()" class="form-control">
<!-- Slicing the version file name here gets rid of the '.json' file extension. -->
<option ng-repeat="versionFile in ctrl.versionList" value="{{versionFile}}">{{versionFile.slice(0, -5)}}</option>
<!-- Slicing the version file name here gets rid of the '.json' file extension -->
<select ng-model="ctrl.version"
ng-change="ctrl.update()"
class="form-control"
ng-options="versionFile.slice(0,-5) for versionFile in ctrl.versionList">
</select>
</div>
<div class="col-md-4">

View File

@ -66,7 +66,9 @@
ctrl.versionsRequest =
$http.get(content_url).success(function (data) {
ctrl.versionList = data.sort().reverse();
ctrl.version = ctrl.versionList[0];
// Default to the first approved guideline which is expected
// to be at index 1.
ctrl.version = ctrl.versionList[1];
ctrl.update();
}).error(function (error) {
ctrl.showError = true;

View File

@ -90,7 +90,9 @@
$http.get(content_url).success(function (data) {
ctrl.versionList = data.sort().reverse();
if (!ctrl.version) {
ctrl.version = ctrl.versionList[0];
// Default to the first approved guideline which is
// expected to be at index 1.
ctrl.version = ctrl.versionList[1];
}
ctrl.updateGuidelines();
}).error(function (error) {

View File

@ -91,14 +91,16 @@ describe('Refstack controllers', function () {
};
$httpBackend.expectGET(fakeApiUrl +
'/guidelines').respond(['2015.03.json', '2015.04.json']);
'/guidelines').respond(['next.json', '2015.03.json',
'2015.04.json']);
// Should call request with latest version.
$httpBackend.expectGET(fakeApiUrl +
'/guidelines/2015.04.json').respond(fakeCaps);
$httpBackend.flush();
// The version list should be sorted latest first.
expect(ctrl.versionList).toEqual(['2015.04.json',
'2015.03.json']);
expect(ctrl.versionList).toEqual(['next.json',
'2015.04.json',
'2015.03.json']);
expect(ctrl.guidelines).toEqual(fakeCaps);
// The guideline status should be approved.
expect(ctrl.guidelines.status).toEqual('approved');