Skip to content
Merged
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
3 changes: 2 additions & 1 deletion client/controllers/controllerInstances.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ function ControllerInstances(
currentOrg,
errs,
fetchInstancesByPod,
fetchRepoBranches,
keypather,
loading,
ModalService,
Expand DownExpand Up@@ -210,7 +211,7 @@ function ControllerInstances(
this.getAllBranches = function (instance) {
return promisify(currentOrg.github, 'fetchRepo')(instance.getRepoName())
.then(function (repo) {
return promisify(repo, 'fetchBranches')();
return fetchRepoBranches(repo);
});
};

Expand Down
19 changes: 9 additions & 10 deletions test/unit/controllers/controllerInstances.unit.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ var $controller,
mockOrg,
currentOrg;
var isRunnabotPartOfOrgStub;
var fetchRepoBranchesStub;
var apiMocks = require('../apiMocks/index');
var mockFetch = new (require('../fixtures/mockFetch'))();
var runnable = window.runnable;
Expand DownExpand Up@@ -110,7 +111,12 @@ describe('ControllerInstances'.bold.underline.blue, function () {
isRunnabotPartOfOrgStub = sinon.stub().returns($q.when());
return isRunnabotPartOfOrgStub;
});

$provide.factory('fetchRepoBranches', function($q) {
fetchRepoBranchesStub = sinon.stub().returns($q.when({
models: apiMocks.branches.bitcoinRepoBranches
}));
return fetchRepoBranchesStub;
});
$provide.factory('setLastOrg', function ($q) {
return sinon.stub().returns($q.when());
});
Expand DownExpand Up@@ -345,18 +351,11 @@ describe('ControllerInstances'.bold.underline.blue, function () {

it('should fetch branches for an instance when popInstanceOpen is called', function () {
setup('myOrg');

var repo = {
fetchBranches: sinon.stub().returns($q.when({
models: apiMocks.branches.bitcoinRepoBranches
}))
};

mockOrg.github.fetchRepo.returns($q.when(repo));
mockOrg.github.fetchRepo.returns($q.when(true));
CIS.popInstanceOpen(masterInstance);
$rootScope.$digest();
sinon.assert.calledOnce(mockOrg.github.fetchRepo);
sinon.assert.calledOnce(repo.fetchBranches);
sinon.assert.calledOnce(fetchRepoBranchesStub);
expect(CIS.instanceBranches).to.deep.equal(apiMocks.branches.bitcoinRepoBranches);
expect(CIS.totalInstanceBranches).to.equal(apiMocks.branches.bitcoinRepoBranches.length);
});
Expand Down