Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Trollé committed Dec 1, 2017
2 parents deaeefa + 069a49c commit c434dc3
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/src/components/MissionTypePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
data() {
return {
displayedMissionType: ['Delivery', 'Consulting'],
displayedMissionType: ['Delivery', 'Consulting', 'Training'],
options: ['Delivery', 'Consulting', 'Training'],
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Unit | Component | MissionTypePicker.vue', () => {

describe('$data', () => {
it('should have displayedMissionType property set by default to delivery and consulting', () => {
expect(component.$data.displayedMissionType).to.deep.equal(['Delivery', 'Consulting']);
expect(component.$data.displayedMissionType).to.deep.equal(['Delivery', 'Consulting', 'Training']);
});
});

Expand Down
11 changes: 8 additions & 3 deletions server/src/domain/services/job-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,21 @@ function _isKindOfProjectWantedOnJobBoard(project) {
return project.kind === 'cost_reimbursable' || project.kind === 'fixed_price';
}

function _filterProjectByStatusAndKind(projects) {
function _isOcacProject(project) {
return project.customer.name === 'OCTO Academy';
}

function _filterProjectsWantedOnJobBoard(projects) {
return projects
.filter(project => _isStatusWantedOnJobBoard(project))
.filter(project => _isKindOfProjectWantedOnJobBoard(project));
.filter(project => _isKindOfProjectWantedOnJobBoard(project))
.filter(project => !_isOcacProject(project));
}

async function _fetchAndCacheJobs() {
const accessToken = await octopodClient.getAccessToken();
const projects = await octopodClient.fetchProjectsToBeStaffed(accessToken);
const filterProjects = _filterProjectByStatusAndKind(projects);
const filterProjects = _filterProjectsWantedOnJobBoard(projects);
const activities = await octopodClient.fetchActivitiesToBeStaffed(accessToken, filterProjects);
const jobs = await jobsSerializer.serialize(projects, activities);
cache.set(CACHE_KEY, jobs);
Expand Down
27 changes: 25 additions & 2 deletions server/test/unit/domain/services/job-service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('Unit | Service | job-service', () => {
expect(octopodClient.fetchProjectsToBeStaffed).to.have.been.calledWith(stubbedAccessToken);
}));

it('should call Octopod to fetch activities to be staffed with filtered projects - only proposal sent and mission accepted and signed', () => {
it('should call Octopod to fetch activities to be staffed with filtered projects - only proposal sent and mission accepted and signed', (done) => {
// given
octopodClient.fetchProjectsToBeStaffed.restore();

Expand All @@ -117,10 +117,11 @@ describe('Unit | Service | job-service', () => {
promise.then(() => {
// then
expect(octopodClient.fetchActivitiesToBeStaffed).to.have.been.calledWith(stubbedAccessToken, expectedProjectsFromOctopod);
done();
});
});

it('should call Octopod to fetch activities to be staffed with filtered project - only "Regie (cost_reimbursable) and Forfait (fixed price)"', () => {
it('should call Octopod to fetch activities to be staffed with filtered project - only "Regie (cost_reimbursable) and Forfait (fixed price)"', (done) => {
// given
octopodClient.fetchProjectsToBeStaffed.restore();
const projectsFromOctopod = [
Expand All @@ -136,10 +137,32 @@ describe('Unit | Service | job-service', () => {
];
sinon.stub(octopodClient, 'fetchProjectsToBeStaffed').resolves(projectsFromOctopod);

// when
promise.then(() => {
// then
expect(octopodClient.fetchActivitiesToBeStaffed).to.have.been.calledWithExactly(stubbedAccessToken, expectedProjectsFromOctopod);
done();
});
});

it('should call Octopod to fetch activities to be staffed with filtered project - without mission from customer : "OCTO Academy"', (done) => {
// given
octopodClient.fetchProjectsToBeStaffed.restore();
const projectsFromOctopod = [
projectFromOctopod('mission_signed', 'fixed_price', 'OCTO Academy'),
projectFromOctopod('mission_signed', 'fixed_price', 'Airbus Défense'),
];

const expectedProjectsFromOctopod = [
projectFromOctopod('mission_signed', 'fixed_price', 'Airbus Défense'),
];
sinon.stub(octopodClient, 'fetchProjectsToBeStaffed').resolves(projectsFromOctopod);

// when
promise.then(() => {
// then
expect(octopodClient.fetchActivitiesToBeStaffed).to.have.been.calledWith(stubbedAccessToken, expectedProjectsFromOctopod);
done();
});
});

Expand Down
6 changes: 4 additions & 2 deletions server/test/unit/fixtures/projectFromOctopod.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = (status = 'proposal_sent', kind = 'fixed_price') => (
module.exports = (status = 'proposal_sent',
kind = 'fixed_price',
customerName = 'Airbus Defense') => (
{
id: 2146905983,
url: 'https://octopod.octo.com/api/v0/projects/2146905983',
Expand All @@ -8,7 +10,7 @@ module.exports = (status = 'proposal_sent', kind = 'fixed_price') => (
status,
customer: {
id: 2504,
name: 'Airbus Defense & Space (via Accenture)',
name: customerName,
customer_group: null,
},
customer_contract_reference: null,
Expand Down
1 change: 1 addition & 0 deletions tools/release/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ git push origin master

echo "Go back to branch dev"
git checkout dev
git pull

exit 0

0 comments on commit c434dc3

Please sign in to comment.