Merge remote-tracking branch 'origin/7.0.0' into 7.0.0

Conflicts:
	src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.httpbackend.js
This commit is contained in:
Shannon
2013-07-02 17:47:57 +10:00
12 changed files with 132 additions and 130 deletions

View File

@@ -1,8 +1,8 @@
angular.module('umbraco.mocks').
factory('contentMocks', ['$httpBackend', 'mocksUtills', function ($httpBackend, mocksUtills) {
'use strict';
function returnNodebyId(status, data, headers) {
angular.module('umbraco.mocks').
factory('contentMocks', ['$httpBackend', 'mocksUtills', function ($httpBackend, mocksUtills) {
'use strict';
function returnNodebyId(status, data, headers) {
var id = mocksUtills.getParameterByName(data, "id") || 1234;
var node = {
@@ -74,18 +74,19 @@ angular.module('umbraco.mocks').
]
};
return [200, node, null];
}
return {
register: function() {
$httpBackend
.whenGET(mocksUtills.urlRegex('/umbraco/UmbracoApi/Content/GetById'))
.respond(returnNodebyId);
}
};
}
return {
register: function() {
$httpBackend
.whenGET(mocksUtills.urlRegex('/umbraco/UmbracoApi/Content/GetById'))
.respond(returnNodebyId);
},
expectGetById: function() {
$httpBackend
.expectGET(mocksUtills.urlRegex('/umbraco/UmbracoApi/Content/GetById'));
}
};
}]);

View File

@@ -3,22 +3,24 @@ angular.module('umbraco.mocks').
'use strict';
function returnAllowedChildren(status, data, headers) {
var types = [
{ name: "News Article", description: "Standard news article", alias: "newsArticle", id: 1234, cssClass: "file" },
{ name: "News Area", description: "Area to hold all news articles, there should be only one", alias: "newsArea", id: 1234, cssClass: "suitcase" },
{ name: "Employee", description: "Employee profile information page", alias: "employee", id: 1234, cssClass: "user" }
];
var types = [
{ name: "News Article", description: "Standard news article", alias: "newsArticle", id: 1234, cssClass: "file" },
{ name: "News Area", description: "Area to hold all news articles, there should be only one", alias: "newsArea", id: 1234, cssClass: "suitcase" },
{ name: "Employee", description: "Employee profile information page", alias: "employee", id: 1234, cssClass: "user" }
];
return [200, types, null];
}
return {
register: function() {
$httpBackend
.whenGET(mocksUtills.urlRegex('/umbraco/Api/'))
$httpBackend
.whenGET(mocksUtills.urlRegex('/umbraco/Api/'))
.respond(returnAllowedChildren);
},
expectAllowedChildren: function(){
console.log("expecting get");
$httpBackend.expectGET(mocksUtills.urlRegex('/umbraco/Api/'));
}
};
}]);

View File

@@ -1,8 +1,10 @@
var umbracoAppDev = angular.module('umbraco.httpbackend', ['umbraco', 'ngMockE2E', 'umbraco.mocks']);
var umbracoAppDev = angular.module('umbraco.httpbackend', ['umbraco', 'ngMockE2E', 'umbraco.mocks']);
function initBackEnd($httpBackend, contentMocks, treeMocks, userMocks, contentTypeMocks, sectionMocks) {
console.log("httpBackend inited");
//Register mocked http responses
contentMocks.register();
sectionMocks.register();
@@ -10,14 +12,14 @@ function initBackEnd($httpBackend, contentMocks, treeMocks, userMocks, contentTy
userMocks.register();
contentTypeMocks.register();
$httpBackend.whenGET(/^views\//).passThrough();
$httpBackend.whenGET(/^js\//).passThrough();
$httpBackend.whenGET(/^lib\//).passThrough();
$httpBackend.whenGET(/^assets\//).passThrough();
}
umbracoAppDev.run(initBackEnd);
contentTypeMocks.register();
$httpBackend.whenGET(/^views\//).passThrough();
$httpBackend.whenGET(/^js\//).passThrough();
$httpBackend.whenGET(/^lib\//).passThrough();
$httpBackend.whenGET(/^assets\//).passThrough();
}
umbracoAppDev.run(initBackEnd);

View File

@@ -35,14 +35,10 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
var deferred = $q.defer();
//go and get the data
$http.get(getContentUrl(id)).
success(function (data, status, headers, config) {
console.log("getting by id success");
//set the first tab to active
_.each(data.tabs, function (item) {
item.active = false;
@@ -54,7 +50,6 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
deferred.resolve(data);
}).
error(function (data, status, headers, config) {
console.log("getting by id - error");
deferred.reject('Failed to retreive data for content id ' + id);
});

View File

@@ -43,23 +43,14 @@ function contentTypeResource($q, $http) {
//return all types allowed under given document
getAllowedTypes: function (contentId) {
var deferred = $q.defer();
//go and get the tree data
$http.get(getChildContentTypesUrl(contentId)).
success(function (data, status, headers, config) {
console.log("success");
$http.get(getChildContentTypesUrl(contentId))
.success(function (data, status, headers, config) {
deferred.resolve(data);
}).
error(function (data, status, headers, config) {
console.log("wrong");
deferred.reject('Failed to retreive data for content id ' + contentId);
});
return deferred.promise;
}

View File

@@ -8,8 +8,8 @@ angular.module('umbraco.services')
}
var scope = options.scope || $rootScope.$new(),
animationClass = options.animation || "slide",
modalClass = options.modalClass || "",
animationClass = options.animation || "fade",
modalClass = options.modalClass || "umb-modalcolumn",
templateUrl = options.template || "views/common/notfound.html";
var callback = options.callback;
@@ -43,7 +43,7 @@ angular.module('umbraco.services')
};
scope.hide = function() {
$modal.modal('hide');
$modal.modal('hide');
$('body').remove($modal);
};

View File

@@ -45,7 +45,7 @@ module.exports = function(karma) {
// level of logging
// possible values: karma.LOG_DISABLE || karma.LOG_ERROR || karma.LOG_WARN || karma.LOG_INFO || karma.LOG_DEBUG
// CLI --log-level debug
logLevel: karma.LOG_DEBUG,
logLevel: karma.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
// CLI --auto-watch --no-auto-watch

View File

@@ -1,44 +1,39 @@
describe('content factory tests', function () {
var $rootScope, $httpBackend, contentFactory;
var $rootScope, $httpBackend, contentFactory, mocks, $http;
beforeEach(module('umbraco.services'));
beforeEach(module('umbraco.resources'));
beforeEach(module('umbraco.httpbackend'));
beforeEach(inject(function ($injector) {
$rootScope = $injector.get('$rootScope');
$rootScope = $injector.get('$rootScope');
$httpBackend = $injector.get('$httpBackend');
mocks = $injector.get("contentMocks");
mocks.register();
contentFactory = $injector.get('contentResource');
}));
afterEach(function () {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
afterEach(function () {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
});
describe('global content factory crud', function () {
it('should return a content object, given an id', function () {
var doc = "meh";
contentFactory.getById(1234).then(function (result) {
doc = result;
});
console.log("doc:", doc);
$rootScope.$root.$digest();
//$scope.$apply();
//.then(function (doc1) {
console.log("doc:", doc);
expect(doc).toNotBe(undefined);
expect(doc.id).toBe(1234);
//});
it('should return a content object, given an id', function () {
var doc;
contentFactory.getById(1234).then(function(result){
doc = result;
});
$rootScope.$digest();
expect(doc).toNotBe(undefined);
expect(doc.id).toBe(1234);
});
it('should return a content children collection given an id', function () {
var collection = contentFactory.getChildren(1234, undefined);
expect(collection.resultSet.length).toBe(10);

View File

@@ -1,34 +1,50 @@
describe('content type factory tests', function () {
var $rootScope, contentTypeResource;
var $rootScope, $httpBackend, contentTypeResource, m;
beforeEach(module('ngMockE2E'));
beforeEach(module('umbraco.resources'));
beforeEach(module('umbraco.httpbackend'));
beforeEach(inject(function ($injector) {
$rootScope = $injector.get('$rootScope');
beforeEach(inject(function ($injector, contentTypeMocks) {
$rootScope = $injector.get('$rootScope');
$httpBackend = $injector.get('$httpBackend');
m = contentTypeMocks;
m.register();
contentTypeResource = $injector.get('contentTypeResource');
}));
describe('global content type factory crud', function () {
it('should return a content type object, given an id', function () {
var ct1 = contentTypeResource.getContentType(1234);
$rootScope.$digest();
var ct1;
contentTypeResource.getContentType(1234).then(function(result){
ct1 = result;
});
$rootScope.$digest();
$rootScope.$apply();
console.log("ct1:", ct1);
expect(ct1).toNotBe(undefined);
expect(ct1.id).toBe(1234);
});
it('should return a allowed content type collection given a document id', function(){
// var collection = contentTypeResource.getAllowedTypes(1234);
// $rootScope.$apply();
// console.log("running test", angular.toJson(collection));
// expect(collection.length).toBe(3);
m.expectAllowedChildren();
var collection;
contentTypeResource.getAllowedTypes(1234).then(function(result){
collection = result;
});
$rootScope.$digest();
$rootScope.$apply();
expect(collection.length).toBe(3);
});
});
});

View File

@@ -1,30 +1,30 @@
<!doctype html>
<html lang="en">
<head>
<base href="/belle/" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Umbraco</title>
<link rel="stylesheet" href="assets/css/umbraco.css" />
</head>
<body ng-controller="MainController" id="umbracoMainPageBody">
<div ng-hide="!authenticated" ng-cloak ng-animate="'fade'" id="Div1" class="clearfix" ng-click="closeDialogs($event)">
<umb-left-column></umb-left-column>
<section id="contentwrapper">
<div id="contentcolumn">
<div ng-view></div>
</div>
</section>
</div>
<umb-notifications></umb-notifications>
<script src="lib/yepnope/yepnope.min.js"></script>
<script src="js/loader.js"></script>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<base href="/belle/" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Umbraco</title>
<link rel="stylesheet" href="assets/css/umbraco.css" />
</head>
<body ng-controller="MainController" id="umbracoMainPageBody">
<div ng-hide="!authenticated" ng-cloak ng-animate="'fade'" id="Div1" class="clearfix" ng-click="closeDialogs($event)">
<umb-left-column></umb-left-column>
<section id="contentwrapper">
<div id="contentcolumn">
<div ng-view></div>
</div>
</section>
</div>
<umb-notifications></umb-notifications>
<script src="lib/yepnope/yepnope.min.js"></script>
<script src="js/loader.js"></script>
</body>
</html>