diff --git a/client/directives/components/lists/branchCommitSelector/branchCommitSelectorDirective.js b/client/directives/components/lists/branchCommitSelector/branchCommitSelectorDirective.js index f2b61fd95..57567a873 100644 --- a/client/directives/components/lists/branchCommitSelector/branchCommitSelectorDirective.js +++ b/client/directives/components/lists/branchCommitSelector/branchCommitSelectorDirective.js @@ -10,7 +10,9 @@ require('app') * latestCommit, */ function branchCommitSelector( + $q, errs, + fetchCommitData, promisify, github ) { @@ -30,8 +32,14 @@ function branchCommitSelector( if (branch) { $scope.fetchingCommits = true; var acv = $scope.BCSC.data.acv; - return github.branchOrPRCommits(acv) - .then($scope.BCSC.onCommitFetch) + return $q.all({ + branchOrPRCommits: github.branchOrPRCommits(acv), + activeCommit: fetchCommitData.activeCommit(acv) + }) + .then(function(commitPromises) { + $scope.BCSC.data.commit = commitPromises.activeCommit; + return $scope.BCSC.onCommitFetch(commitPromises.branchOrPRCommits); + }) .catch(errs.handler) .finally(function () { $scope.fetchingCommits = false; diff --git a/test/unit/directives/branchCommitSelectorDirective.unit.js b/test/unit/directives/branchCommitSelectorDirective.unit.js index bb0d5ed87..4bde10db6 100644 --- a/test/unit/directives/branchCommitSelectorDirective.unit.js +++ b/test/unit/directives/branchCommitSelectorDirective.unit.js @@ -5,6 +5,7 @@ describe('branchCommitSelectorDirective'.bold.underline.blue, function () { var $scope; var $rootScope; var keypather; + var fetchCommitDataStub; var $elScope; var $controller; var $q; @@ -40,6 +41,12 @@ describe('branchCommitSelectorDirective'.bold.underline.blue, function () { link: angular.noop }; }); + $provide.factory('fetchCommitData', function ($q) { + fetchCommitDataStub = { + activeCommit: sinon.stub().returns($q.when(true)) + } + return fetchCommitDataStub; + }); $provide.factory('github', function ($q) { ctx.github = { branchOrPRCommits: sinon.stub().returns($q.when(ctx.commits))