kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
394 lines
14 KiB
394 lines
14 KiB
11 years ago
|
//-- copyright
|
||
|
// OpenProject is a project management system.
|
||
|
// Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
|
||
|
//
|
||
|
// This program is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License version 3.
|
||
|
//
|
||
|
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
// Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
//
|
||
|
// This program is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License
|
||
|
// as published by the Free Software Foundation; either version 2
|
||
|
// of the License, or (at your option) any later version.
|
||
|
//
|
||
|
// This program is distributed in the hope that it will be useful,
|
||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
// GNU General Public License for more details.
|
||
|
//
|
||
|
// You should have received a copy of the GNU General Public License
|
||
|
// along with this program; if not, write to the Free Software
|
||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
//
|
||
|
// See doc/COPYRIGHT.rdoc for more details.
|
||
|
//++
|
||
|
|
||
11 years ago
|
/*jshint expr: true*/
|
||
11 years ago
|
|
||
11 years ago
|
describe('Project', function(){
|
||
11 years ago
|
|
||
|
var Project, PlanningElement, Timeline;
|
||
|
|
||
11 years ago
|
before(function(){
|
||
11 years ago
|
this.project = Factory.build("Project", {
|
||
11 years ago
|
timeline: Factory.build("Timeline")
|
||
11 years ago
|
});
|
||
11 years ago
|
|
||
|
this.projectEmpty = Factory.build("Project", {
|
||
11 years ago
|
timeline: Factory.build("Timeline", {}, {
|
||
|
exclude_empty: "yes"
|
||
|
})
|
||
11 years ago
|
});
|
||
|
|
||
|
});
|
||
|
|
||
11 years ago
|
beforeEach(module('openproject.timelines.models', 'openproject.uiComponents'));
|
||
11 years ago
|
beforeEach(inject(function(_Project_, _PlanningElement_, _Timeline_) {
|
||
|
Project = _Project_;
|
||
|
PlanningElement = _PlanningElement_;
|
||
|
Timeline = _Timeline_;
|
||
|
}));
|
||
|
|
||
11 years ago
|
describe('hidden', function () {
|
||
|
it('should be true for empty', function () {
|
||
|
expect(this.projectEmpty.hiddenForEmpty()).to.be.true;
|
||
|
expect(this.projectEmpty.hide()).to.be.true;
|
||
11 years ago
|
expect(this.project.hide()).to.be.false;
|
||
|
expect(this.project.hiddenForEmpty()).to.be.false;
|
||
11 years ago
|
});
|
||
|
});
|
||
11 years ago
|
|
||
|
describe('filtered', function () {
|
||
|
it('should be false by default', function () {
|
||
|
expect(this.project.filteredOut()).to.be.false;
|
||
|
});
|
||
|
it('should be filtered for type');
|
||
|
it('should be filtered for status');
|
||
|
});
|
||
|
|
||
|
describe('getPlanningElements', function () {
|
||
|
it('should be empty by default', function () {
|
||
|
expect(this.project.getPlanningElements()).to.be.empty;
|
||
|
});
|
||
11 years ago
|
it('should return list of planningElements when set', function () {
|
||
|
var pe1 = {"id": 961, "name": "B", "start_date": "2012-11-15", "due_date": "2012-11-15" };
|
||
|
var pe2 = {"id": 962, "name": "B", "start_date": "2012-11-15", "due_date": "2012-11-15" };
|
||
|
var pe3 = {"id": 963, "name": "D", "start_date": "2012-11-15", "due_date": "2012-11-15" };
|
||
|
|
||
11 years ago
|
var testProject = Factory.build("Project", {timeline: Factory.build("Timeline"),
|
||
11 years ago
|
planning_elements: [pe2, pe3, pe1]
|
||
|
});
|
||
|
|
||
|
var pes = testProject.getPlanningElements();
|
||
|
|
||
|
expect(pes).to.satisfy(objectContainsAll(pe1, pe2, pe3));
|
||
|
});
|
||
|
it('should sort without date to the beginning', function () {
|
||
|
var pe1 = {"id": 951, "name": "B", };
|
||
|
var pe2 = {"id": 952, "name": "A", "start_date": "2012-11-14", "due_date": "2012-11-18" };
|
||
|
var pe3 = {"id": 953, "name": "C", "start_date": "2012-11-13", "due_date": "2012-11-17" };
|
||
|
|
||
|
var testProject = Factory.build("Project", {timeline: Factory.build("Timeline"),
|
||
|
planning_elements: [pe2, pe3, pe1]
|
||
|
});
|
||
|
|
||
|
var pes = testProject.getPlanningElements();
|
||
|
|
||
|
expect(pes).to.satisfy(objectsortation(pe1, pe3, pe2));
|
||
|
});
|
||
|
it('should sort with only an end date as if it had a start date equal to the end date', function () {
|
||
|
var pe1 = {"id": 951, "name": "B", "due_date": "2012-11-15"};
|
||
|
var pe2 = {"id": 952, "name": "A", "start_date": "2012-11-14", "due_date": "2012-11-18" };
|
||
|
var pe3 = {"id": 953, "name": "C", "start_date": "2012-11-13", "due_date": "2012-11-17" };
|
||
|
|
||
|
var testProject = Factory.build("Project", {timeline: Factory.build("Timeline"),
|
||
|
planning_elements: [pe2, pe3, pe1]
|
||
|
});
|
||
|
|
||
|
var pes = testProject.getPlanningElements();
|
||
|
|
||
|
expect(pes).to.satisfy(objectsortation(pe3, pe2, pe1));
|
||
|
});
|
||
|
it('should sort by date per default', function () {
|
||
|
var pe1 = {"id": 961, "name": "B", "start_date": "2012-11-15", "due_date": "2012-11-15" };
|
||
|
var pe2 = {"id": 962, "name": "A", "start_date": "2012-11-14", "due_date": "2012-11-18" };
|
||
|
var pe3 = {"id": 963, "name": "C", "start_date": "2012-11-13", "due_date": "2012-11-17" };
|
||
|
|
||
|
var testProject = Factory.build("Project", {timeline: Factory.build("Timeline"),
|
||
|
planning_elements: [pe2, pe3, pe1]
|
||
|
});
|
||
|
|
||
|
var pes = testProject.getPlanningElements();
|
||
|
|
||
11 years ago
|
expect(pes).to.satisfy(objectsortation(pe3, pe2, pe1));
|
||
11 years ago
|
});
|
||
|
it('should sort pes with same start by end', function () {
|
||
|
var pe1 = {"id": 971, "name": "B", "start_date": "2012-11-13", "due_date": "2012-11-15" };
|
||
|
var pe2 = {"id": 972, "name": "A", "start_date": "2012-11-13", "due_date": "2012-11-18" };
|
||
|
var pe3 = {"id": 973, "name": "C", "start_date": "2012-11-13", "due_date": "2012-11-17" };
|
||
|
|
||
|
var testProject = Factory.build("Project", {timeline: Factory.build("Timeline"),
|
||
|
planning_elements: [pe3, pe2, pe1]
|
||
|
});
|
||
|
|
||
|
var pes = testProject.getPlanningElements();
|
||
|
|
||
|
expect(pes).to.satisfy(objectsortation(pe1, pe3, pe2));
|
||
|
});
|
||
|
it('should sort pes with same start and end by name', function () {
|
||
|
var pe1 ={"id": 981, "name": "A", "start_date": "2012-11-13", "due_date": "2012-11-15" };
|
||
|
var pe2 ={"id": 982, "name": "B", "start_date": "2012-11-13", "due_date": "2012-11-15" };
|
||
|
var pe3 ={"id": 983, "name": "C", "start_date": "2012-11-13", "due_date": "2012-11-15" };
|
||
|
|
||
|
var testProject = Factory.build("Project", {timeline: Factory.build("Timeline"),
|
||
|
planning_elements: [pe3, pe2, pe1]
|
||
|
});
|
||
|
|
||
|
var pes = testProject.getPlanningElements();
|
||
|
|
||
|
expect(pes).to.satisfy(objectsortation(pe1, pe2, pe3));
|
||
|
});
|
||
|
it('should sort pes with same start and end and name by id', function () {
|
||
|
var pe1 = {"id": 991, "name": "A", "start_date": "2012-11-13", "due_date": "2012-11-15" };
|
||
|
var pe2 = {"id": 992, "name": "A", "start_date": "2012-11-13", "due_date": "2012-11-15" };
|
||
|
var pe3 = {"id": 993, "name": "A", "start_date": "2012-11-13", "due_date": "2012-11-15" };
|
||
|
|
||
|
var testProject = Factory.build("Project", {timeline: Factory.build("Timeline"),
|
||
|
planning_elements: [pe3, pe2, pe1]
|
||
|
});
|
||
|
|
||
|
var pes = testProject.getPlanningElements();
|
||
|
|
||
|
expect(pes).to.satisfy(objectsortation(pe1, pe2, pe3));
|
||
|
});
|
||
11 years ago
|
});
|
||
11 years ago
|
|
||
|
describe('responsible', function () {
|
||
11 years ago
|
before(function () {
|
||
11 years ago
|
this.responsible = Factory.build("User", {
|
||
11 years ago
|
name: "testName"
|
||
11 years ago
|
});
|
||
11 years ago
|
|
||
|
this.projectWResponsible = Factory.build("Project", {
|
||
|
responsible: this.responsible
|
||
|
});
|
||
|
});
|
||
|
|
||
|
it('should be null by default', function () {
|
||
|
expect(this.project.getResponsible()).to.be.null;
|
||
|
});
|
||
|
|
||
|
it('should get the responsible', function () {
|
||
|
expect(this.projectWResponsible.getResponsible()).to.deep.equal(this.responsible);
|
||
|
});
|
||
|
it('should allow get of responsible name', function () {
|
||
|
expect(this.projectWResponsible.getResponsibleName()).to.equal("testName");
|
||
|
});
|
||
|
it('should return undefined if responsible or responsible name are not set', function () {
|
||
11 years ago
|
var projectWBrokenResponsible = Factory.build("Project", {
|
||
|
responsible: {}
|
||
|
});
|
||
|
|
||
11 years ago
|
expect(this.project.getResponsibleName()).to.be.undefined;
|
||
11 years ago
|
expect(projectWBrokenResponsible.getResponsibleName()).to.be.undefined;
|
||
11 years ago
|
});
|
||
11 years ago
|
});
|
||
11 years ago
|
|
||
11 years ago
|
describe('assignee', function () {
|
||
11 years ago
|
it('should always return undefined', function () {
|
||
|
//we also expect it to have no side effects at all!
|
||
|
var allProjects = Factory.all("Project");
|
||
|
var i;
|
||
|
for (i = 0; i < allProjects; i += 1) {
|
||
|
expect(allProjects.getAssignee()).to.be.undefined;
|
||
|
}
|
||
|
});
|
||
11 years ago
|
});
|
||
11 years ago
|
|
||
11 years ago
|
describe('status', function () {
|
||
11 years ago
|
it('should return null if no reporting', function () {
|
||
|
expect(this.project.getProjectStatus()).to.be.null;
|
||
|
});
|
||
11 years ago
|
it('should return reporting status');
|
||
11 years ago
|
});
|
||
11 years ago
|
|
||
11 years ago
|
describe('subElements', function () {
|
||
11 years ago
|
before(function () {
|
||
|
this.project = Factory.build("Project", { timeline: Factory.build("Timeline") }, {
|
||
|
});
|
||
|
});
|
||
11 years ago
|
it('returns pes before reporters');
|
||
|
it('returns the same pes as getPlanningElements');
|
||
|
it('filters the reporters correctly');
|
||
11 years ago
|
});
|
||
11 years ago
|
|
||
11 years ago
|
describe('Reporters', function () {
|
||
|
before(function () {
|
||
|
this.peWithoutDate = Factory.build("PlanningElement");
|
||
|
this.peWithDate1 = Factory.build("PlanningElement", {
|
||
|
"start_date": "2012-11-15",
|
||
|
"due_date": "2012-11-15"
|
||
|
});
|
||
|
|
||
|
this.peWithDate2 = Factory.build("PlanningElement", {
|
||
|
"start_date": "2012-11-18",
|
||
|
"due_date": "2012-11-18"
|
||
|
});
|
||
|
|
||
|
this.peWithDate3 = Factory.build("PlanningElement", {
|
||
|
"due_date": "2012-11-19"
|
||
|
});
|
||
|
});
|
||
11 years ago
|
it('should return reporters', function () {
|
||
|
var projects = Factory.buildList("Project", 10);
|
||
11 years ago
|
|
||
11 years ago
|
var project = Factory.build("Project", {
|
||
|
timeline: Factory.build("Timeline"),
|
||
|
reporters: projects
|
||
|
});
|
||
|
|
||
|
expect(project.getReporters()).to.satisfy(objectContainsAll(projects));
|
||
|
});
|
||
11 years ago
|
it('should sort without date to the beginning', function () {
|
||
|
var project1 = Factory.build("Project", {
|
||
|
planning_elements: [this.peWithoutDate]
|
||
|
});
|
||
|
var project2 = Factory.build("Project", {
|
||
|
planning_elements: [this.peWithDate1]
|
||
|
});
|
||
|
|
||
|
var reporterProject = Factory.build("Project", {
|
||
|
timeline: Factory.build("Timeline"),
|
||
|
reporters: [project2, project1]
|
||
|
});
|
||
|
|
||
|
expect(reporterProject.getReporters()).to.satisfy(objectsortation(project1, project2));
|
||
|
});
|
||
|
it('should sort by date', function () {
|
||
|
var project1 = Factory.build("Project", {
|
||
|
planning_elements: [this.peWithDate1, this.peWithoutDate]
|
||
|
});
|
||
|
var project2 = Factory.build("Project", {
|
||
|
planning_elements: [this.peWithDate2, this.peWithoutDate]
|
||
|
});
|
||
|
var project3 = Factory.build("Project", {
|
||
|
planning_elements: [this.peWithDate3, this.peWithoutDate]
|
||
|
});
|
||
|
|
||
|
var reporterProject = Factory.build("Project", {
|
||
|
timeline: Factory.build("Timeline"),
|
||
|
reporters: [project2, project3, project1]
|
||
|
});
|
||
|
|
||
|
expect(reporterProject.getReporters()).to.satisfy(objectsortation(project1, project2, project3));
|
||
|
});
|
||
|
it('should sort with same start and end by name', function () {
|
||
|
var project1 = Factory.build("Project", {
|
||
|
name: "A",
|
||
|
planning_elements: [this.peWithDate1, this.peWithoutDate]
|
||
|
});
|
||
|
var project2 = Factory.build("Project", {
|
||
|
name: "B",
|
||
|
planning_elements: [this.peWithDate1, this.peWithoutDate]
|
||
|
});
|
||
|
var project3 = Factory.build("Project", {
|
||
|
name: "C",
|
||
|
planning_elements: [this.peWithDate1, this.peWithoutDate]
|
||
|
});
|
||
|
|
||
|
var reporterProject = Factory.build("Project", {
|
||
|
timeline: Factory.build("Timeline"),
|
||
|
reporters: [project2, project3, project1]
|
||
|
});
|
||
|
|
||
|
expect(reporterProject.getReporters()).to.satisfy(objectsortation(project1, project2, project3));
|
||
|
});
|
||
|
it('should sort with same start and end and name by id', function () {
|
||
|
var project1 = Factory.build("Project", {
|
||
|
name: "A",
|
||
|
planning_elements: [this.peWithDate1, this.peWithoutDate]
|
||
|
});
|
||
|
var project2 = Factory.build("Project", {
|
||
|
name: "A",
|
||
|
planning_elements: [this.peWithDate1, this.peWithoutDate]
|
||
|
});
|
||
|
var project3 = Factory.build("Project", {
|
||
|
name: "A",
|
||
|
planning_elements: [this.peWithDate1, this.peWithoutDate]
|
||
|
});
|
||
|
|
||
|
var reporterProject = Factory.build("Project", {
|
||
|
timeline: Factory.build("Timeline"),
|
||
|
reporters: [project2, project3, project1]
|
||
|
});
|
||
|
|
||
|
expect(reporterProject.getReporters()).to.satisfy(objectsortation(project1, project2, project3));
|
||
|
});
|
||
11 years ago
|
|
||
|
|
||
|
describe('groups', function () {
|
||
11 years ago
|
beforeEach(function () {
|
||
|
this.project1_1 = Factory.build("Project", a().sname("F"));
|
||
|
this.project1_2 = Factory.build("Project", a().sname("G"));
|
||
|
|
||
|
this.project2_1 = Factory.build("Project", a().sname("C"));
|
||
|
this.project2_2 = Factory.build("Project", a().sname("D"));
|
||
|
|
||
|
this.project1 = Factory.build("Project", {
|
||
|
name: "A",
|
||
|
children: [this.project1_1, this.project1_2]
|
||
|
});
|
||
|
|
||
|
this.project2 = Factory.build("Project", {
|
||
|
name: "B",
|
||
|
children: [this.project2_1, this.project2_2]
|
||
|
});
|
||
|
|
||
|
this.timeline = Factory.build("Timeline", {}, {
|
||
|
grouping_one_selection: [this.project2.id, this.project1.id],
|
||
|
grouping_one_enabled: "yes"
|
||
|
});
|
||
|
|
||
|
this.reporterProject = Factory.build("Project", {
|
||
|
timeline: this.timeline,
|
||
|
reporters: [this.project1_1, this.project1_2, this.project1, this.project2_1, this.project2_2, this.project2]
|
||
|
});
|
||
|
});
|
||
|
it('should sort groups by name', function () {
|
||
|
expect(this.reporterProject.getReporters()).to.satisfy(objectsortation(this.project1_1, this.project1_2, this.project2_1, this.project2_2, this.project1, this.project2));
|
||
|
});
|
||
|
it('should sort groups by explicit order if given', function () {
|
||
|
this.timeline.options.grouping_one_sort = 1;
|
||
|
expect(this.reporterProject.getReporters()).to.satisfy(objectsortation(this.project2_1, this.project2_2, this.project1_1, this.project1_2, this.project1, this.project2));
|
||
|
});
|
||
11 years ago
|
});
|
||
11 years ago
|
});
|
||
11 years ago
|
|
||
11 years ago
|
describe('Parent', function () {
|
||
11 years ago
|
it('should return null if no parent given');
|
||
|
it('should return the correct parent');
|
||
11 years ago
|
});
|
||
11 years ago
|
|
||
11 years ago
|
describe('Url', function () {
|
||
11 years ago
|
it('should return the correct url');
|
||
11 years ago
|
});
|
||
11 years ago
|
});
|
||
|
|
||
|
describe('Helper Functions', function () {
|
||
|
describe('id in Array', function () {
|
||
|
it('should return true if element in array', function () {
|
||
|
expect(Timeline.idInArray(["5", "4"], {id: 4})).to.be.true;
|
||
|
expect(Timeline.idInArray(["5", "4"], {id: "5"})).to.be.true;
|
||
|
expect(Timeline.idInArray(["a"], {id: "a"})).to.be.true;
|
||
|
});
|
||
|
|
||
|
it('should return true if no array or empty array is passed', function () {
|
||
|
expect(Timeline.idInArray([], {id: 5})).to.be.true;
|
||
|
expect(Timeline.idInArray("", {id: 5})).to.be.true;
|
||
|
});
|
||
|
});
|
||
11 years ago
|
});
|