diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js index 199976f3fa..919c4623ef 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.create.controller.js @@ -32,7 +32,7 @@ function contentCreateController($scope, $location .path("/content/content/edit/" + $scope.currentNode.id) .search("doctype", docType.alias) - .search("create", true); + .search("create", "true"); close(); } @@ -54,7 +54,9 @@ function contentCreateController($scope, function createFromBlueprint(blueprintId) { $location .path("/content/content/edit/" + $scope.currentNode.id) - .search("doctype=" + $scope.docType.alias + "&create=true&blueprintId=" + blueprintId); + .search("doctype", $scope.docType.alias) + .search("create", "true") + .search("blueprintId", blueprintId); close(); } diff --git a/src/Umbraco.Web.UI.Client/test/unit/app/content/create-content-controller.spec.js b/src/Umbraco.Web.UI.Client/test/unit/app/content/create-content-controller.spec.js index 95ec38f710..278d52c9a2 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/app/content/create-content-controller.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/app/content/create-content-controller.spec.js @@ -1,124 +1,130 @@ -(function() { +(function () { - describe("create content dialog", - function() { + describe("create content dialog", + function () { - var scope, - allowedTypes = [ - { id: 1, alias: "x" }, - { id: 2, alias: "y", blueprints: { "1": "a", "2": "b" } } - ], - location, - searcher, - controller, - rootScope, - contentTypeResource; + var scope, + allowedTypes = [ + { id: 1, alias: "x" }, + { id: 2, alias: "y", blueprints: { "1": "a", "2": "b" } } + ], + location, + searcher, + controller, + rootScope, + contentTypeResource; - beforeEach(module("umbraco")); + beforeEach(module("umbraco")); - function initialize(blueprintConfig) { - scope = rootScope.$new(); - scope.currentNode = { id: 1234 }; - var dependencies = { - $scope: scope, - contentTypeResource: contentTypeResource - }; - if (blueprintConfig) { - dependencies.blueprintConfig = blueprintConfig; - } - controller("Umbraco.Editors.Content.CreateController", - dependencies); + function initialize(blueprintConfig) { + scope = rootScope.$new(); + scope.currentNode = { id: 1234 }; + var dependencies = { + $scope: scope, + contentTypeResource: contentTypeResource + }; + if (blueprintConfig) { + dependencies.blueprintConfig = blueprintConfig; + } + controller("Umbraco.Editors.Content.CreateController", + dependencies); - scope.$digest(); + scope.$digest(); - } + } - beforeEach(inject(function($controller, $rootScope, $q, $location) { - contentTypeResource = { - getAllowedTypes: function() { - var def = $q.defer(); - def.resolve(allowedTypes); - return def.promise; - } - }; - location = $location; - controller = $controller; - rootScope = $rootScope; + beforeEach(inject(function ($controller, $rootScope, $q, $location) { + contentTypeResource = { + getAllowedTypes: function () { + var def = $q.defer(); + def.resolve(allowedTypes); + return def.promise; + } + }; + location = $location; + controller = $controller; + rootScope = $rootScope; - searcher = { search: function() {} }; - spyOn(location, "path").and.returnValue(searcher) - spyOn(searcher, "search"); + searcher = { search: function () { } }; + spyOn(location, "path").and.returnValue(searcher) + spyOn(searcher, "search").and.returnValue(searcher); - initialize(); - })); + initialize(); + })); + + it("shows available child document types for the given node", + function () { + expect(scope.selectContentType).toBe(true); + expect(scope.allowedTypes).toBe(allowedTypes); + }); + + it("creates content directly when there are no blueprints", + function () { + scope.createOrSelectBlueprintIfAny(allowedTypes[0]); + + expect(location.path).toHaveBeenCalledWith("/content/content/edit/1234"); + expect(searcher.search).toHaveBeenCalledWith('doctype', 'x'); + expect(searcher.search).toHaveBeenCalledWith('create', 'true'); + }); + + it("shows list of blueprints when there are some", + function () { + scope.createOrSelectBlueprintIfAny(allowedTypes[1]); + expect(scope.selectContentType).toBe(false); + expect(scope.selectBlueprint).toBe(true); + expect(scope.docType).toBe(allowedTypes[1]); + }); + + it("creates blueprint when selected", + function () { + scope.createOrSelectBlueprintIfAny(allowedTypes[1]); + scope.createFromBlueprint("1"); + + expect(location.path).toHaveBeenCalledWith("/content/content/edit/1234"); + expect(searcher.search).toHaveBeenCalledWith("doctype", "y"); + expect(searcher.search).toHaveBeenCalledWith("create", "true"); + expect(searcher.search).toHaveBeenCalledWith("blueprintId", "1"); + }); + + it("skips selection and creates first blueprint when configured to", + function () { + initialize({ + allowBlank: true, + skipSelect: true + }); + + scope.createOrSelectBlueprintIfAny(allowedTypes[1]); + + expect(location.path).toHaveBeenCalledWith("/content/content/edit/1234"); + expect(searcher.search).toHaveBeenCalledWith("doctype", "y"); + expect(searcher.search).toHaveBeenCalledWith("create", "true"); + expect(searcher.search).toHaveBeenCalledWith("blueprintId", "1"); + }); + + it("allows blank to be selected", + function () { + expect(scope.allowBlank).toBe(true); + }); + + it("creates blank when selected", + function () { + scope.createBlank(allowedTypes[1]); + + expect(location.path).toHaveBeenCalledWith("/content/content/edit/1234"); + expect(searcher.search).toHaveBeenCalledWith('doctype', 'y'); + expect(searcher.search).toHaveBeenCalledWith('create', 'true'); + }); + + it("hides blank when configured to", + function () { + initialize({ + allowBlank: false, + skipSelect: false + }); + + expect(scope.allowBlank).toBe(false); + }); - it("shows available child document types for the given node", - function() { - expect(scope.selectContentType).toBe(true); - expect(scope.allowedTypes).toBe(allowedTypes); }); - it("creates content directly when there are no blueprints", - function() { - scope.createOrSelectBlueprintIfAny(allowedTypes[0]); - - expect(location.path).toHaveBeenCalledWith("/content/content/edit/1234"); - expect(searcher.search).toHaveBeenCalledWith("doctype=x&create=true"); - }); - - it("shows list of blueprints when there are some", - function() { - scope.createOrSelectBlueprintIfAny(allowedTypes[1]); - expect(scope.selectContentType).toBe(false); - expect(scope.selectBlueprint).toBe(true); - expect(scope.docType).toBe(allowedTypes[1]); - }); - - it("creates blueprint when selected", - function() { - scope.createOrSelectBlueprintIfAny(allowedTypes[1]); - scope.createFromBlueprint("1"); - - expect(location.path).toHaveBeenCalledWith("/content/content/edit/1234"); - expect(searcher.search).toHaveBeenCalledWith("doctype=y&create=true&blueprintId=1"); - }); - - it("skips selection and creates first blueprint when configured to", - function() { - initialize({ - allowBlank: true, - skipSelect: true - }); - - scope.createOrSelectBlueprintIfAny(allowedTypes[1]); - - expect(location.path).toHaveBeenCalledWith("/content/content/edit/1234"); - expect(searcher.search).toHaveBeenCalledWith("doctype=y&create=true&blueprintId=1"); - }); - - it("allows blank to be selected", - function() { - expect(scope.allowBlank).toBe(true); - }); - - it("creates blank when selected", - function() { - scope.createBlank(allowedTypes[1]); - - expect(location.path).toHaveBeenCalledWith("/content/content/edit/1234"); - expect(searcher.search).toHaveBeenCalledWith("doctype=y&create=true"); - }); - - it("hides blank when configured to", - function() { - initialize({ - allowBlank: false, - skipSelect: false - }); - - expect(scope.allowBlank).toBe(false); - }); - - }); - -}()); \ No newline at end of file +}());