Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change way of getting active commit and all commits #2061

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ require('app')
* latestCommit,
*/
function branchCommitSelector(
$q,
errs,
fetchCommitData,
promisify,
github
) {
Expand All @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions test/unit/directives/branchCommitSelectorDirective.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe('branchCommitSelectorDirective'.bold.underline.blue, function () {
var $scope;
var $rootScope;
var keypather;
var fetchCommitDataStub;
var $elScope;
var $controller;
var $q;
Expand Down Expand Up @@ -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))
Expand Down