From 62b61ab12ae7bf07f274f28e82d3b9d0c881e06c Mon Sep 17 00:00:00 2001 From: Frank Celler Date: Thu, 25 Jul 2013 18:48:31 +0200 Subject: [PATCH] fixed tests --- js/common/tests/shell-foxx.js | 59 ++++---------------------- js/server/modules/org/arangodb/foxx.js | 6 ++- 2 files changed, 14 insertions(+), 51 deletions(-) diff --git a/js/common/tests/shell-foxx.js b/js/common/tests/shell-foxx.js index 48855f2cad..8bd19714c8 100644 --- a/js/common/tests/shell-foxx.js +++ b/js/common/tests/shell-foxx.js @@ -9,7 +9,7 @@ var jsunity = require("jsunity"), function CreateFoxxApplicationSpec () { return { testCreationWithoutParameters: function () { - var app = new FoxxApplication(), + var app = new FoxxApplication({prefix: "", foxxes: []}), routingInfo = app.routingInfo; assertEqual(routingInfo.routes.length, 0); @@ -17,7 +17,7 @@ function CreateFoxxApplicationSpec () { }, testCreationWithURLPrefix: function () { - var app = new FoxxApplication({urlPrefix: "/wiese"}), + var app = new FoxxApplication({prefix: "", foxxes: []}, {urlPrefix: "/wiese"}), routingInfo = app.routingInfo; assertEqual(routingInfo.routes.length, 0); @@ -28,7 +28,7 @@ function CreateFoxxApplicationSpec () { var app, routingInfo, templateCollection; db._drop("wiese"); - app = new FoxxApplication({templateCollection: "wiese"}); + app = new FoxxApplication({prefix: "", foxxes: []}, {templateCollection: "wiese"}); routingInfo = app.routingInfo; templateCollection = db._collection("wiese"); @@ -42,7 +42,7 @@ function CreateFoxxApplicationSpec () { db._drop("wiese"); db._create("wiese"); - app = new FoxxApplication({templateCollection: "wiese"}); + app = new FoxxApplication({prefix: "", foxxes: []}, {templateCollection: "wiese"}); routingInfo = app.routingInfo; templateCollection = db._collection("wiese"); @@ -52,25 +52,12 @@ function CreateFoxxApplicationSpec () { }, testAdditionOfBaseMiddlewareInRoutingInfo: function () { - var app = new FoxxApplication(), + var app = new FoxxApplication({prefix: "", foxxes: []}), routingInfo = app.routingInfo, hopefully_base = routingInfo.middleware[0]; assertEqual(routingInfo.middleware.length, 1); assertEqual(hopefully_base.url.match, "/*"); - }, - - testAdditionOfRepositoryInRoutingInfo: function () { - var app = new FoxxApplication(), - routingInfo = app.routingInfo; - - app.registerRepository("todos", { - model: "models/todo", - repository: "repositories/todos" - }); - - assertEqual(routingInfo.repositories.todos.model, "models/todo"); - assertEqual(routingInfo.repositories.todos.repository, "repositories/todos"); } }; } @@ -80,7 +67,7 @@ function SetRoutesFoxxApplicationSpec () { return { setUp: function () { - app = new FoxxApplication(); + app = new FoxxApplication({prefix: "", foxxes: []}); }, testSettingRoutes: function () { @@ -196,34 +183,6 @@ function SetRoutesFoxxApplicationSpec () { } assertEqual(error, "URL has to be a String"); assertEqual(routes.length, 0); - }, - - testSettingHandlers: function () { - var myFunc = function a (b, c) { return b + c;}, - myFuncString = "function a(b, c) { return b + c;}", - routes = app.routingInfo.routes, - action; - - app.get('/simple/route', myFunc); - - action = routes[0].action; - assertEqual(routes.length, 1); - assertEqual(action.callback, myFuncString); - }, - - testStartAddsRequiresAndContext: function () { - var myFunc = function () {}, - routingInfo = app.routingInfo, - context = {}; - - app.requires = { - a: 1 - }; - app.get('/simple/route', myFunc); - app.start(context); - - assertEqual(context.requires.a, 1); - assertEqual(context.routingInfo, routingInfo); } }; } @@ -233,7 +192,7 @@ function DocumentationAndConstraintsSpec () { return { setUp: function () { - app = new FoxxApplication(), + app = new FoxxApplication({prefix: "", foxxes: []}), routes = app.routingInfo.routes; }, @@ -403,7 +362,7 @@ function AddMiddlewareFoxxApplicationSpec () { return { setUp: function () { - app = new FoxxApplication(); + app = new FoxxApplication({prefix: "", foxxes: []}); }, testAddABeforeMiddlewareForAllRoutes: function () { @@ -660,7 +619,7 @@ function ViewHelperSpec () { return { setUp: function () { - app = new FoxxApplication(); + app = new FoxxApplication({prefix: "", foxxes: []}); Middleware = require('org/arangodb/foxx').BaseMiddleware; request = {}; response = {}; diff --git a/js/server/modules/org/arangodb/foxx.js b/js/server/modules/org/arangodb/foxx.js index 9dfe740b92..f03b021ef3 100644 --- a/js/server/modules/org/arangodb/foxx.js +++ b/js/server/modules/org/arangodb/foxx.js @@ -116,7 +116,11 @@ Application = function (context, options) { if (urlPrefix === "") { urlPrefix = context.prefix; } else { - urlPrefix = context.prefix + "/" + urlPrefix; + if (context.prefix === "") { + urlPrefix = urlPrefix; + } else { + urlPrefix = context.prefix + "/" + urlPrefix; + } } this.helperCollection = {};