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.
169 lines
5.4 KiB
169 lines
5.4 KiB
9 years ago
|
// -- copyright
|
||
11 years ago
|
// OpenProject is a project management system.
|
||
10 years ago
|
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
11 years ago
|
//
|
||
|
// 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.
|
||
9 years ago
|
// ++
|
||
11 years ago
|
|
||
11 years ago
|
describe('columnContextMenu', function() {
|
||
10 years ago
|
var container, contextMenu, $rootScope, scope, stateParams, ngContextMenu;
|
||
10 years ago
|
stateParams = {};
|
||
11 years ago
|
|
||
9 years ago
|
beforeEach(angular.mock.module('ng-context-menu',
|
||
11 years ago
|
'openproject.workPackages',
|
||
11 years ago
|
'openproject.workPackages.controllers',
|
||
11 years ago
|
'openproject.models',
|
||
11 years ago
|
'openproject.api',
|
||
10 years ago
|
'openproject.layout',
|
||
10 years ago
|
'openproject.services',
|
||
10 years ago
|
'openproject.templates'));
|
||
11 years ago
|
|
||
9 years ago
|
beforeEach(angular.mock.module('openproject.templates', function($provide) {
|
||
10 years ago
|
var configurationService = {};
|
||
10 years ago
|
|
||
|
configurationService.isTimezoneSet = sinon.stub().returns(false);
|
||
9 years ago
|
configurationService.accessibilityModeEnabled = sinon.stub().returns(false);
|
||
10 years ago
|
|
||
10 years ago
|
$provide.constant('$stateParams', stateParams);
|
||
10 years ago
|
$provide.constant('ConfigurationService', configurationService);
|
||
|
}));
|
||
|
|
||
11 years ago
|
beforeEach(function() {
|
||
|
var html = '<div></div>';
|
||
|
container = angular.element(html);
|
||
|
});
|
||
11 years ago
|
|
||
11 years ago
|
beforeEach(inject(function(_$rootScope_, _ngContextMenu_, $templateCache) {
|
||
|
$rootScope = _$rootScope_;
|
||
|
ngContextMenu = _ngContextMenu_;
|
||
11 years ago
|
|
||
9 years ago
|
var template = $templateCache.get(
|
||
|
'/components/context-menus/column-context-menu/column-context-menu.template.html');
|
||
|
|
||
11 years ago
|
$templateCache.put('column_context_menu.html', [200, template, {}]);
|
||
11 years ago
|
|
||
11 years ago
|
contextMenu = ngContextMenu({
|
||
|
controller: 'ColumnContextMenuController',
|
||
|
controllerAs: 'contextMenu',
|
||
|
container: container,
|
||
|
templateUrl: 'column_context_menu.html'
|
||
11 years ago
|
});
|
||
|
|
||
11 years ago
|
contextMenu.open({x: 0, y: 0});
|
||
|
}));
|
||
11 years ago
|
|
||
|
describe('when the context menu handler of a column is clicked', function() {
|
||
9 years ago
|
var QueryService;
|
||
11 years ago
|
var column = { name: 'status', title: 'Status' },
|
||
11 years ago
|
anotherColumn = { name: 'subject', title: 'Subject' },
|
||
11 years ago
|
columns = [column, anotherColumn],
|
||
|
query = Factory.build('Query', { columns: columns });
|
||
11 years ago
|
|
||
11 years ago
|
beforeEach(inject(function(_QueryService_) {
|
||
|
QueryService = _QueryService_;
|
||
|
sinon.stub(QueryService, 'getQuery').returns(query);
|
||
|
}));
|
||
|
afterEach(inject(function() {
|
||
|
QueryService.getQuery.restore();
|
||
|
}));
|
||
|
|
||
11 years ago
|
beforeEach(function() {
|
||
11 years ago
|
$rootScope.column = column;
|
||
|
$rootScope.columns = columns;
|
||
|
$rootScope.$digest();
|
||
11 years ago
|
|
||
11 years ago
|
scope = container.children().scope();
|
||
11 years ago
|
});
|
||
|
|
||
|
it('fetches the column from the context handle context', function() {
|
||
11 years ago
|
expect($rootScope.column).to.have.property('name').and.contain(column.name);
|
||
11 years ago
|
});
|
||
11 years ago
|
|
||
|
describe('and the group by option is clicked', function() {
|
||
|
beforeEach(function() {
|
||
11 years ago
|
scope.groupBy(column.name);
|
||
11 years ago
|
});
|
||
|
|
||
|
it('changes the query group by', function() {
|
||
|
expect(query.groupBy).to.equal(column.name);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe('and "move column right" is clicked', function() {
|
||
|
beforeEach(function() {
|
||
11 years ago
|
scope.moveRight(column.name);
|
||
11 years ago
|
});
|
||
|
|
||
|
it('moves the column right', function() {
|
||
|
expect(columns[1]).to.equal(column);
|
||
|
});
|
||
|
});
|
||
11 years ago
|
|
||
|
describe('and "Sort ascending" is clicked', function() {
|
||
|
var Sortation;
|
||
|
|
||
|
beforeEach(inject(function(_Sortation_) {
|
||
|
Sortation = _Sortation_;
|
||
|
query.sortation = new Sortation();
|
||
11 years ago
|
scope.sortAscending(column.name);
|
||
11 years ago
|
}));
|
||
|
|
||
|
it('updates the query sortation', function() {
|
||
|
expect(query.sortation.getPrimarySortationCriterion()).to.deep.equal({ field: column.name, direction: 'asc' });
|
||
|
});
|
||
|
});
|
||
11 years ago
|
|
||
|
describe('and "Hide column" is clicked', function() {
|
||
|
beforeEach(function() {
|
||
11 years ago
|
scope.hideColumn(column.name);
|
||
11 years ago
|
});
|
||
|
|
||
|
it('removes the column from the query columns', function() {
|
||
|
expect(query.columns).to.not.include(column);
|
||
|
});
|
||
|
});
|
||
11 years ago
|
|
||
|
describe('and "Insert columns" is clicked', function() {
|
||
|
var activateFn, columnsModal;
|
||
|
|
||
|
beforeEach(inject(function(_columnsModal_) {
|
||
|
columnsModal = _columnsModal_;
|
||
|
activateFn = sinon.stub(columnsModal, 'activate');
|
||
|
}));
|
||
|
afterEach(inject(function() {
|
||
|
columnsModal.activate.restore();
|
||
|
}));
|
||
|
|
||
|
beforeEach(function() {
|
||
|
scope.insertColumns();
|
||
|
});
|
||
|
|
||
|
it('opens the columns dialog', function() {
|
||
|
expect(activateFn).to.have.been.called;
|
||
|
});
|
||
|
});
|
||
|
|
||
11 years ago
|
});
|
||
|
});
|