Merge branch 'release/4.0' into dev

Signed-off-by: Alex Coles <alex@alexbcoles.com>

Conflicts:
	frontend/tests/unit/tests/services/query-service-test.js
	frontend/tests/unit/tests/work_packages/directives/query-filters-directive-test.js
pull/2447/head
Alex Coles 10 years ago
commit a179a952ad
  1. 4
      frontend/app/services/query-service.js
  2. 42
      frontend/tests/unit/tests/services/query-service-test.js

@ -346,6 +346,10 @@ module.exports = function(Query, Sortation, $http, PathHelper, $q, AVAILABLE_WOR
return QueryService.doQuery(url, query.toUpdateParams(), 'DELETE', function(response){
QueryService.fetchAvailableGroupedQueries(query.project_id);
$rootScope.$broadcast('openproject.layout.removeMenuItem', {
itemType: QUERY_MENU_ITEM_TYPE,
objectId: query.id
});
return angular.extend(response.data, { status: { text: I18n.t('js.notice_successful_delete') }} );
});
},

@ -30,7 +30,9 @@
describe('QueryService', function() {
var QueryService, PathHelper, query, queryData, stateParams = {};
var QueryService, PathHelper, query, queryData, stateParams = {}, $rootScope,
$httpBackend;
beforeEach(module('openproject.layout',
'openproject.models',
@ -46,8 +48,11 @@ describe('QueryService', function() {
$provide.constant('ConfigurationService', configurationService);
}));
beforeEach(inject(function(_QueryService_){
beforeEach(inject(function(_QueryService_, _$rootScope_, _$httpBackend_, _PathHelper_) {
QueryService = _QueryService_;
$rootScope = _$rootScope_;
PathHelper = _PathHelper_;
$httpBackend = _$httpBackend_;
}));
describe('query setup', function () {
@ -85,6 +90,35 @@ describe('QueryService', function() {
});
describe('deleteQuery', function() {
var spy;
beforeEach(function() {
spy = sinon.spy($rootScope, '$broadcast');
queryData = { name: '_', 'project_id': 1 };
QueryService.initQuery(1, queryData);
var path = PathHelper.apiProjectQueryPath(1, 1);
$httpBackend.when('DELETE', new RegExp(path + '*')).respond(200, []);
$httpBackend.when(
'GET',
PathHelper.apiProjectCustomFieldsPath(1)
).respond(200, []);
$httpBackend.when(
'GET',
PathHelper.apiProjectGroupedQueriesPath(1)
).respond(200, []);
QueryService.deleteQuery();
$httpBackend.flush();
});
afterEach(function() {
spy.restore();
});
it('should broadcast a query deletion message', function() {
expect($rootScope.$broadcast.calledWith('openproject.layout.removeMenuItem')).to.be.true;
});
});
describe('getQueryName', function() {
var defaultTitle = 'Work Packages';
@ -122,7 +156,6 @@ describe('QueryService', function() {
describe('loadAvailableGroupedQueries', function() {
var projectIdentifier = 'test_project',
$httpBackend,
$rootScope,
path,
groupedQueries;
@ -131,10 +164,9 @@ describe('QueryService', function() {
$httpBackend.flush();
}
beforeEach(inject(function(_$httpBackend_, _PathHelper_, _$rootScope_) {
beforeEach(inject(function(_$httpBackend_, _PathHelper_) {
$httpBackend = _$httpBackend_;
PathHelper = _PathHelper_;
$rootScope = _$rootScope_;
path = PathHelper.apiProjectGroupedQueriesPath(projectIdentifier);
groupedQueries = {

Loading…
Cancel
Save