commit
9b34fb5f66
@ -0,0 +1,7 @@ |
||||
OpenProject is an open source project and we encourage you to help us out. We'd be happy if you do one of these things: |
||||
|
||||
* Create a [new work package on openproject.org](https://www.openproject.org/projects/openproject/work_packages) if you find a bug or need a feature |
||||
* Help out other people on our [forums](https://www.openproject.org/projects/openproject/boards) |
||||
* Help us [translate OpenProject to more languages](https://www.openproject.org/projects/openproject/wiki/Translations) |
||||
* Contribute code via GitHub Pull Requests, see our [contribution page](https://www.openproject.org/projects/openproject/wiki/Contribution) for more information |
||||
* See [Git Flow](https://www.openproject.org/projects/openproject/wiki/Git_Branching_Model) |
@ -0,0 +1,123 @@ |
||||
//-- 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.
|
||||
//++
|
||||
|
||||
/*jshint expr: true*/ |
||||
|
||||
describe('WorkPackagesController', function() { |
||||
var scope, ctrl, win, testWorkPackageService, testQueryService, testPaginationService; |
||||
var buildController; |
||||
|
||||
beforeEach(module('openproject.workPackages.controllers')); |
||||
beforeEach(inject(function($rootScope, $controller, $timeout) { |
||||
scope = $rootScope.$new(); |
||||
win = { |
||||
location: { pathname: "" } |
||||
}; |
||||
|
||||
var workPackageData = { |
||||
meta: { |
||||
} |
||||
}; |
||||
var columnData = { |
||||
}; |
||||
|
||||
testWorkPackageService = { |
||||
getWorkPackages: function () { |
||||
}, |
||||
getWorkPackagesByQueryId: function (params) { |
||||
return $timeout(function () { |
||||
return workPackageData; |
||||
}, 10); |
||||
}, |
||||
getWorkPackagesFromUrlQueryParams: function () { |
||||
return $timeout(function () { |
||||
return workPackageData; |
||||
}, 10); |
||||
} |
||||
}; |
||||
testQueryService = { |
||||
getQuery: function () { |
||||
return { |
||||
serialiseForAngular: function () { |
||||
} |
||||
} |
||||
}, |
||||
initQuery: function () { |
||||
}, |
||||
getAvailableColumns: function () { |
||||
return $timeout(function () { |
||||
return columnData; |
||||
}, 10); |
||||
} |
||||
}; |
||||
testPaginationService = { |
||||
setPerPageOptions: function () { |
||||
}, |
||||
setPerPage: function () { |
||||
}, |
||||
setPage: function () { |
||||
} |
||||
}; |
||||
|
||||
buildController = function() { |
||||
ctrl = $controller("WorkPackagesController", { |
||||
$scope: scope, |
||||
$window: win, |
||||
QueryService: testQueryService, |
||||
PaginationService: testPaginationService, |
||||
WorkPackageService: testWorkPackageService |
||||
}); |
||||
|
||||
$timeout.flush(); |
||||
}; |
||||
|
||||
})); |
||||
|
||||
describe('initialisation', function() { |
||||
it('should initialise', function() { |
||||
buildController(); |
||||
expect(scope.loading).to.be.false; |
||||
}); |
||||
}); |
||||
|
||||
describe('setting projectIdentifier', function() { |
||||
it('should set the projectIdentifier', function() { |
||||
win.location.pathname = '/projects/my-project/something-else'; |
||||
buildController(); |
||||
expect(scope.projectIdentifier).to.eq('my-project'); |
||||
}); |
||||
|
||||
it('should set the projectIdentifier with a custom appBasePath', function() { |
||||
win.appBasePath = '/my-instanz'; |
||||
win.location.pathname = '/my-instanz/projects/my-project/something-else'; |
||||
buildController(); |
||||
expect(scope.projectIdentifier).to.eq('my-project'); |
||||
}); |
||||
}); |
||||
|
||||
}); |
@ -0,0 +1,136 @@ |
||||
//-- 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.
|
||||
//++
|
||||
|
||||
describe('timelineColumnData Directive', function() { |
||||
var compile, element, rootScope, scope; |
||||
|
||||
beforeEach(angular.mock.module('openproject.timelines.directives')); |
||||
beforeEach(module('templates', 'openproject.uiComponents', 'openproject.helpers')); |
||||
|
||||
beforeEach(inject(function($rootScope, $compile) { |
||||
var html; |
||||
html = '<span timeline-column-data row-object="rowObject" column-name="columnName" timeline="timeline" custom-fields="timeline.custom_fields"></span>'; |
||||
|
||||
element = angular.element(html); |
||||
rootScope = $rootScope; |
||||
scope = $rootScope.$new(); |
||||
|
||||
compile = function() { |
||||
$compile(element)(scope); |
||||
scope.$digest(); |
||||
}; |
||||
})); |
||||
|
||||
describe('element', function() { |
||||
beforeEach(function() { |
||||
type = Factory.build('PlanningElementType'); |
||||
|
||||
scope.timeline = Factory.build('Timeline'); |
||||
scope.rowObject = Factory.build("PlanningElement", { |
||||
timeline: scope.timeline, |
||||
planning_element_type: type, |
||||
sheep: 10, |
||||
start_date: '2014-04-29', |
||||
due_date: '2014-04-28' |
||||
}); |
||||
}); |
||||
|
||||
describe('rendering an object field', function() { |
||||
beforeEach(function(){ |
||||
scope.columnName = 'type'; |
||||
compile(); |
||||
}); |
||||
|
||||
it('should render the object data', function() { |
||||
expect(element.find('.tl-column').text()).to.equal(type.name); |
||||
}); |
||||
}); |
||||
|
||||
describe('rendering a changed historical date', function() { |
||||
beforeEach(function() { |
||||
historicalStartDate = '2014-04-20'; |
||||
|
||||
scope.rowObject.historical_element = Factory.build("PlanningElement", { |
||||
start_date: historicalStartDate |
||||
}); |
||||
|
||||
scope.columnName = 'start_date'; |
||||
compile(); |
||||
}) |
||||
|
||||
it('should assign a change kind class to the current date', function() { |
||||
var container = element.find('.tl-column'); |
||||
expect(container.hasClass('tl-postponed')).to.be.true; |
||||
}); |
||||
|
||||
describe('the historical data container', function() { |
||||
beforeEach(function() { |
||||
historicalContainerElement = element.find('.tl-historical'); |
||||
historicalDataContainer = historicalContainerElement.find('.historical-data'); |
||||
}); |
||||
|
||||
it('should contain the historical data', function() { |
||||
expect(historicalDataContainer.text()).to.equal(historicalStartDate); |
||||
}); |
||||
|
||||
it('should contain a link with a css class indicating the change', function() { |
||||
expect(historicalContainerElement.find('a').hasClass('tl-icon-postponed')).to.be.true; |
||||
}); |
||||
}) |
||||
}); |
||||
|
||||
describe('rendering changed data which is not a date', function() { |
||||
beforeEach(function() { |
||||
historicalType = Factory.build('PlanningElementType'); |
||||
|
||||
scope.rowObject.historical_element = Factory.build("PlanningElement", { |
||||
planning_element_type: historicalType |
||||
}); |
||||
|
||||
scope.columnName = 'type'; |
||||
compile(); |
||||
}) |
||||
|
||||
describe('the historical data container', function() { |
||||
beforeEach(function() { |
||||
historicalContainerElement = element.find('.tl-historical'); |
||||
historicalDataContainer = historicalContainerElement.find('.historical-data'); |
||||
}); |
||||
|
||||
it('should contain the historical data', function() { |
||||
expect(historicalDataContainer.text()).to.equal(historicalType.name); |
||||
}); |
||||
|
||||
it('should contain a link with a css class indicating the change', function() { |
||||
expect(historicalContainerElement.find('a').hasClass('tl-icon-changed')).to.be.true; |
||||
}); |
||||
}) |
||||
|
||||
}); |
||||
}); |
||||
}); |
@ -1,18 +0,0 @@ |
||||
<span class="tl-historical" ng-show="rowObject.does_historical_differ(columnName)"> |
||||
<a href="javascript://" title="{{I18n.t('js.timelines.change')}}" |
||||
ng-class="[ |
||||
'icon', |
||||
'tl-icon-' + isDateColumn && historicalDateKind || 'tl-icon-changed' |
||||
]"> |
||||
{{rowObject.historical()[columnName] || I18n.t('js.timelines.empty')}} |
||||
</a> |
||||
<br/> |
||||
</span> |
||||
|
||||
<span ng-class="[ |
||||
'tl-column', |
||||
isDateColumn && 'tl-current', |
||||
isDateColumn && rowObject.does_historical_differ(columnName) && 'tl-' + (historicalDateKind) |
||||
]"> |
||||
{{columnData}} |
||||
</span> |
@ -0,0 +1,15 @@ |
||||
<span class="tl-historical" ng-if="historicalDataDiffers"> |
||||
<span ng-bind="historicalData" class="historical-data"></span> |
||||
<a href="javascript://" title="{{labelTimelineChanged}}" |
||||
ng-class="[ |
||||
'icon', |
||||
'tl-icon-' + (isDateColumn && historicalDateKind || 'changed') |
||||
]"></a> |
||||
<br/> |
||||
</span> |
||||
|
||||
<span ng-class="[ |
||||
'tl-column', |
||||
isDateColumn && 'tl-current', |
||||
isDateColumn && historicalDataDiffers && 'tl-' + historicalDateKind |
||||
]" ng-bind="columnData"></span> |
@ -0,0 +1,52 @@ |
||||
#-- 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. |
||||
#++ |
||||
|
||||
require File.expand_path('../../../../../spec_helper', __FILE__) |
||||
|
||||
describe 'ColumnData' do |
||||
include Api::V3::Concerns::ColumnData |
||||
|
||||
describe '#column_data_type' do |
||||
it 'should recognise custom field columns based on field format' do |
||||
field = double('field', id: 1, order_statement: '', field_format: 'user') |
||||
column = ::QueryCustomFieldColumn.new(field) |
||||
|
||||
expect(column_data_type(column)).to eq('user') |
||||
end |
||||
|
||||
it 'should recognise Currency columns based on class name' do |
||||
DodgeCoinCurrencyQueryColumn = Class.new(QueryColumn) |
||||
column = DodgeCoinCurrencyQueryColumn.new('overspend') |
||||
|
||||
expect(column_data_type(column)).to eq('currency') |
||||
end |
||||
|
||||
xit 'should test the full gamut of types' |
||||
end |
||||
|
||||
end |
Loading…
Reference in new issue