Fixes broken unit tests
This commit is contained in:
@@ -6,13 +6,14 @@ module.exports = function (grunt) {
|
||||
|
||||
//run by the watch task
|
||||
grunt.registerTask('watch-js', ['jshint:dev','concat','copy:app','copy:mocks','copy:packages','copy:vs','karma:unit']);
|
||||
grunt.registerTask('watch-less', ['recess:build','copy:assets','copy:vs']);
|
||||
grunt.registerTask('watch-less', ['recess:build','recess:installer','copy:assets','copy:vs']);
|
||||
grunt.registerTask('watch-html', ['copy:views', 'copy:vs']);
|
||||
grunt.registerTask('watch-packages', ['copy:packages']);
|
||||
grunt.registerTask('watch-installer', ['concat:install','concat:installJs','copy:installer']);
|
||||
grunt.registerTask('watch-test', ['jshint:dev', 'karma:unit']);
|
||||
|
||||
//triggered from grunt dev or grunt
|
||||
grunt.registerTask('build', ['clean','concat','recess:min','copy']);
|
||||
grunt.registerTask('build', ['clean','concat','recess:min','recess:installer','copy']);
|
||||
|
||||
//utillity tasks
|
||||
grunt.registerTask('docs', ['ngdocs']);
|
||||
@@ -68,7 +69,7 @@ module.exports = function (grunt) {
|
||||
specs: ['test/**/*.spec.js'],
|
||||
scenarios: ['test/**/*.scenario.js'],
|
||||
samples: ['sample files/*.js'],
|
||||
html: ['src/index.html'],
|
||||
html: ['src/index.html','src/install.html'],
|
||||
|
||||
everything:['src/**/*.*', 'test/**/*.*', 'docs/**/*.*'],
|
||||
|
||||
@@ -86,6 +87,11 @@ module.exports = function (grunt) {
|
||||
assets: {
|
||||
files: [{ dest: '<%= distdir %>/assets', src : '**', expand: true, cwd: 'src/assets/' }]
|
||||
},
|
||||
|
||||
installer: {
|
||||
files: [{ dest: '<%= distdir %>/views/install', src : '*.html', expand: true, cwd: 'src/installer/steps' }]
|
||||
},
|
||||
|
||||
vendor: {
|
||||
files: [{ dest: '<%= distdir %>/lib', src : '**', expand: true, cwd: 'lib/' }]
|
||||
},
|
||||
@@ -130,8 +136,24 @@ module.exports = function (grunt) {
|
||||
process: true
|
||||
}
|
||||
},
|
||||
install: {
|
||||
src: ['src/installer/installer.html'],
|
||||
dest: '<%= distdir %>/installer.html',
|
||||
options: {
|
||||
process: true
|
||||
}
|
||||
},
|
||||
|
||||
installJs: {
|
||||
src: ['src/installer/**/*.js'],
|
||||
dest: '<%= distdir %>/js/umbraco.installer.js',
|
||||
options: {
|
||||
banner: "<%= banner %>\n(function() { \n\n angular.module('umbraco.install', []); \n",
|
||||
footer: "\n\n})();"
|
||||
}
|
||||
},
|
||||
controllers: {
|
||||
src:['src/views/**/*.controller.js'],
|
||||
src:['src/controllers/**/*.controller.js','src/views/**/*.controller.js'],
|
||||
dest: '<%= distdir %>/js/umbraco.controllers.js',
|
||||
options: {
|
||||
banner: "<%= banner %>\n(function() { \n\n",
|
||||
@@ -208,6 +230,14 @@ module.exports = function (grunt) {
|
||||
compile: true
|
||||
}
|
||||
},
|
||||
installer: {
|
||||
files: {
|
||||
'<%= distdir %>/assets/css/installer.css':
|
||||
['src/less/installer.less'] },
|
||||
options: {
|
||||
compile: true
|
||||
}
|
||||
},
|
||||
min: {
|
||||
files: {
|
||||
'<%= distdir %>/assets/css/<%= pkg.name %>.css': ['<%= src.less %>']
|
||||
@@ -220,7 +250,6 @@ module.exports = function (grunt) {
|
||||
},
|
||||
|
||||
|
||||
|
||||
watch:{
|
||||
css: {
|
||||
files: '**/*.less',
|
||||
@@ -237,6 +266,10 @@ module.exports = function (grunt) {
|
||||
files: ['test/**/*.js'],
|
||||
tasks: ['watch-test', 'timestamp'],
|
||||
},
|
||||
installer: {
|
||||
files: ['src/installer/**/*.*'],
|
||||
tasks: ['watch-installer', 'timestamp'],
|
||||
},
|
||||
html: {
|
||||
files: ['src/views/**/*.html', 'src/*.html'],
|
||||
tasks:['watch-html','timestamp']
|
||||
@@ -333,6 +366,5 @@ module.exports = function (grunt) {
|
||||
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||
|
||||
grunt.loadNpmTasks('grunt-ngdocs');
|
||||
grunt.loadNpmTasks('grunt-ngmin');
|
||||
|
||||
};
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
"karma-coffee-preprocessor": "0.0.1",
|
||||
"karma": "~0.9",
|
||||
"karma-phantomjs-launcher": "0.0.2",
|
||||
"grunt-ngdocs": "~0.1.2",
|
||||
"grunt-ngmin": "0.0.3"
|
||||
"grunt-ngdocs": "~0.1.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,10 @@ angular.module('umbraco.mocks').
|
||||
.whenGET(mocksUtils.urlRegex('/umbraco/UmbracoApi/Entity/GetByIds'))
|
||||
.respond(returnEntitybyIds);
|
||||
|
||||
$httpBackend
|
||||
.whenGET(mocksUtils.urlRegex('/umbraco/UmbracoApi/Entity/GetAncestors'))
|
||||
.respond(returnEntitybyIds);
|
||||
|
||||
$httpBackend
|
||||
.whenGET(mocksUtils.urlRegex('/umbraco/UmbracoApi/Entity/GetById?'))
|
||||
.respond(returnEntitybyId);
|
||||
|
||||
@@ -125,6 +125,39 @@ function mediaHelper(umbRequestHelper) {
|
||||
return "";
|
||||
},
|
||||
|
||||
registerFileResolver: function(propertyEditorAlias, func){
|
||||
_mediaFileResolvers[propertyEditorAlias] = func;
|
||||
},
|
||||
|
||||
resolveFile : function(mediaItem){
|
||||
var _props = [];
|
||||
|
||||
//we either have properties raw on the object, or spread out on tabs
|
||||
if(mediaItem.properties){
|
||||
_props = mediaItem.properties;
|
||||
}else if(mediaItem.tabs){
|
||||
_.each(mediaItem.tabs, function(tab){
|
||||
if(tab.properties){
|
||||
_props.concat(tab.propeties);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//we go through our file resolvers to see if any of them matches the editors
|
||||
var result = "";
|
||||
_.each(_mediaFileResolvers, function(resolver, key){
|
||||
var property = _.find(_props, function(property){ return property.editor === key; });
|
||||
|
||||
if(property){
|
||||
var file = resolver(property);
|
||||
if(file){
|
||||
result = file;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
},
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name umbraco.services.mediaHelper#scaleToMaxSize
|
||||
@@ -208,41 +241,8 @@ function mediaHelper(umbRequestHelper) {
|
||||
var lowered = imagePath.toLowerCase();
|
||||
var ext = lowered.substr(lowered.lastIndexOf(".") + 1);
|
||||
return ("," + Umbraco.Sys.ServerVariables.umbracoSettings.imageFileTypes + ",").indexOf("," + ext + ",") !== -1;
|
||||
},
|
||||
|
||||
registerFileResolver: function(propertyEditorAlias, func){
|
||||
_mediaFileResolvers[propertyEditorAlias] = func;
|
||||
},
|
||||
|
||||
resolveFile : function(mediaItem){
|
||||
var _props = [];
|
||||
|
||||
//we either have properties raw on the object, or spread out on tabs
|
||||
if(mediaItem.properties){
|
||||
_props = mediaItem.properties;
|
||||
}else if(mediaItem.tabs){
|
||||
_.each(mediaItem.tabs, function(tab){
|
||||
if(tab.properties){
|
||||
_props.concat(tab.propeties);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//we go through our file resolvers to see if any of them matches the editors
|
||||
var result = "";
|
||||
_.each(_mediaFileResolvers, function(resolver, key){
|
||||
var property = _.find(_props, function(property){ return property.editor === key; });
|
||||
|
||||
if(property){
|
||||
var file = resolver(property);
|
||||
if(file){
|
||||
result = file;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
angular.module('umbraco.services').factory('mediaHelper', mediaHelper);
|
||||
@@ -13,7 +13,11 @@
|
||||
* for the editors to check if the value has changed and to re-bind the property if that is true.
|
||||
*
|
||||
*/
|
||||
function fileUploadController($scope, $element, $compile, imageHelper, fileManager, umbRequestHelper) {
|
||||
function fileUploadController($scope, $element, $compile, imageHelper, fileManager, umbRequestHelper, mediaHelper) {
|
||||
|
||||
mediaHelper.registerFileResolver("Umbraco.UploadField", function(property){
|
||||
return property.value;
|
||||
});
|
||||
|
||||
/** Clears the file collections when content is saving (if we need to clear) or after saved */
|
||||
function clearFiles() {
|
||||
@@ -124,10 +128,4 @@ function fileUploadController($scope, $element, $compile, imageHelper, fileManag
|
||||
});
|
||||
};
|
||||
angular.module("umbraco")
|
||||
.controller('Umbraco.PropertyEditors.FileUploadController', fileUploadController)
|
||||
.run(function(mediaHelper){
|
||||
mediaHelper.registerFileResolver("Umbraco.UploadField", function(property){
|
||||
return property.value;
|
||||
});
|
||||
});
|
||||
|
||||
.controller('Umbraco.PropertyEditors.FileUploadController', fileUploadController);
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
//this controller simply tells the dialogs service to open a mediaPicker window
|
||||
//with a specified callback, this callback will receive an object with a selection on it
|
||||
angular.module('umbraco')
|
||||
.run(function(mediaHelper){
|
||||
|
||||
.controller("Umbraco.PropertyEditors.ImageCropperController",
|
||||
function($rootScope, $routeParams, $scope, $log, mediaHelper, cropperHelper, $timeout, editorState, umbRequestHelper, fileManager) {
|
||||
|
||||
var config = $scope.model.config;
|
||||
mediaHelper.registerFileResolver("Umbraco.ImageCropper", function(property){
|
||||
if(property.value.src){
|
||||
return property.value.src;
|
||||
@@ -9,12 +13,7 @@ angular.module('umbraco')
|
||||
return property.value;
|
||||
}
|
||||
});
|
||||
})
|
||||
.controller("Umbraco.PropertyEditors.ImageCropperController",
|
||||
function($rootScope, $routeParams, $scope, $log, mediaHelper, cropperHelper, $timeout, editorState, umbRequestHelper, fileManager) {
|
||||
|
||||
var config = $scope.model.config;
|
||||
|
||||
|
||||
//move previously saved value to the editor
|
||||
if($scope.model.value){
|
||||
//backwards compat with the old file upload (incase some-one swaps them..)
|
||||
|
||||
@@ -5,7 +5,7 @@ describe('edit content controller tests', function () {
|
||||
beforeEach(module('umbraco'));
|
||||
|
||||
//inject the contentMocks service
|
||||
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend, contentMocks, mocksUtils) {
|
||||
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend, contentMocks, entityMocks, mocksUtils) {
|
||||
|
||||
//for these tests we don't want any authorization to occur
|
||||
mocksUtils.disableAuth();
|
||||
@@ -16,6 +16,7 @@ describe('edit content controller tests', function () {
|
||||
//have the contentMocks register its expect urls on the httpbackend
|
||||
//see /mocks/content.mocks.js for how its setup
|
||||
contentMocks.register();
|
||||
entityMocks.register();
|
||||
|
||||
//this controller requires an angular form controller applied to it
|
||||
scope.contentForm = angularHelper.getNullForm("contentForm");
|
||||
|
||||
@@ -5,7 +5,7 @@ describe('edit media controller tests', function () {
|
||||
beforeEach(module('umbraco'));
|
||||
|
||||
//inject the contentMocks service
|
||||
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend, mediaMocks, mocksUtils) {
|
||||
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend, mediaMocks, entityMocks, mocksUtils) {
|
||||
|
||||
//for these tests we don't want any authorization to occur
|
||||
mocksUtils.disableAuth();
|
||||
@@ -16,6 +16,7 @@ describe('edit media controller tests', function () {
|
||||
//have the contentMocks register its expect urls on the httpbackend
|
||||
//see /mocks/content.mocks.js for how its setup
|
||||
mediaMocks.register();
|
||||
entityMocks.register();
|
||||
|
||||
//this controller requires an angular form controller applied to it
|
||||
scope.contentForm = angularHelper.getNullForm("contentForm");
|
||||
|
||||
Reference in New Issue
Block a user