Permalink
Browse files

Fixed Issue #429: Added params to body for PUT requests

  • Loading branch information...
1 parent 0808a9d commit 5a2e0a82e804236e4b8ea146d86a8d6f488918b6 Michael Ridgway committed Aug 29, 2012
View
@@ -9,5 +9,5 @@ node_modules
arrowreport
artifacts
flatfile
-test_descriptor-report.json
-test_descriptor-report.xml
+*_descriptor-report.json
+*_descriptor-report.xml
View
@@ -10,5 +10,5 @@ artifacts
examples
flatfile
Makefile
-test_descriptor-report.json
-test_descriptor-report.xml
+*_descriptor-report.json
+*_descriptor-report.xml
@@ -53,9 +53,29 @@ YUI.add('mojito-rest-lib', function(Y, NAME) {
Y.namespace('mojito.lib').REST = {
/**
+ * Calls IO. Provides mockability
+ * @param url
+ * @param config the IO configuration
+ * @param callback
* @private
*/
- _doRequest: function(method, url, params, config, callback) {
+ _doRequest: function (url, config) {
+ Y.io(url, config);
+ },
+
+ /**
+ * Creates the configuration to be passed to the IO request
+ *
+ * @param {String} method HTTP method
+ * @param {String} url HTTP location
+ * @param {Object} params Params that are passed in the request
+ * @param {Object} config Additional configuration
+ * @param {Object} config.headers Headers to be sent with the request
+ * @param {Number} config.timeout Timeout for the IO request
+ * @param {Function} callback The handler for the response
+ * @private
+ */
+ _makeRequest: function(method, url, params, config, callback) {
// TODO: [Issue 72] Figure out why 'params' values are attaching
// themselves to headers!
var ioConfig = {
@@ -72,7 +92,7 @@ YUI.add('mojito-rest-lib', function(Y, NAME) {
} else {
url += '&' + params;
}
- } else if ('POST' === method) {
+ } else if ('POST' === method || 'PUT' === method) {
ioConfig.data = params;
}
}
@@ -89,8 +109,7 @@ YUI.add('mojito-rest-lib', function(Y, NAME) {
callback(resp);
};
}
-
- Y.io(url, ioConfig);
+ this._doRequest(url, ioConfig);
},
@@ -104,7 +123,7 @@ YUI.add('mojito-rest-lib', function(Y, NAME) {
*/
GET: function() {
var args = ['GET'].concat(Array.prototype.slice.call(arguments));
- this._doRequest.apply(this, args);
+ this._makeRequest.apply(this, args);
},
@@ -118,7 +137,7 @@ YUI.add('mojito-rest-lib', function(Y, NAME) {
*/
POST: function() {
var args = ['POST'].concat(Array.prototype.slice.call(arguments));
- this._doRequest.apply(this, args);
+ this._makeRequest.apply(this, args);
},
@@ -132,7 +151,7 @@ YUI.add('mojito-rest-lib', function(Y, NAME) {
*/
PUT: function() {
var args = ['PUT'].concat(Array.prototype.slice.call(arguments));
- this._doRequest.apply(this, args);
+ this._makeRequest.apply(this, args);
},
@@ -146,7 +165,7 @@ YUI.add('mojito-rest-lib', function(Y, NAME) {
*/
DELETE: function() {
var args = ['DELETE'].concat(Array.prototype.slice.call(arguments));
- this._doRequest.apply(this, args);
+ this._makeRequest.apply(this, args);
},
@@ -160,7 +179,7 @@ YUI.add('mojito-rest-lib', function(Y, NAME) {
*/
HEAD: function() {
var args = ['HEAD'].concat(Array.prototype.slice.call(arguments));
- this._doRequest.apply(this, args);
+ this._makeRequest.apply(this, args);
}
};
@@ -314,12 +314,11 @@ YUI.add('RESTLib', function(Y) {
},
printPUTParams: function(actionContext){
- var project = actionContext.params.getFromUrl("project");
- var sprint = actionContext.params.getFromUrl("sprint");
+ var project = actionContext.params.getFromBody("project");
+ var sprint = actionContext.params.getFromBody("sprint");
var method = actionContext.http.getRequest().method;
- //var output = "<p id=\"output\">(METHOD: " + method + ") This is sprint " + sprint + " for the project " + project + "</p>";
- var output = "<p id=\"output\">(METHOD: " + method + ")</p>";
+ var output = "<p id=\"output\">(METHOD: " + method + ") This is sprint " + sprint + " for the project " + project + "</p>";
actionContext.http.setHeader('content-type', 'text/html');
actionContext.done(output);
},
@@ -15,7 +15,7 @@ YUI({
var that = this;
Y.one('#p_putParam').simulate('click');
that.wait(function(){
- Y.Assert.areEqual('(METHOD: PUT)', Y.one('#output').get('innerHTML'));
+ Y.Assert.areEqual('(METHOD: PUT) This is sprint 4 for the project Mojito', Y.one('#output').get('innerHTML'));
}, 2000);
}
@@ -12,7 +12,7 @@ YUI({
suite.add(new Y.Test.Case({
"test PUTWithParamsServer": function(){
Y.Assert.areEqual('200', Y.one('#status').get('innerHTML'));
- Y.Assert.areEqual('(METHOD: PUT)', Y.one('#output').get('innerHTML'));
+ Y.Assert.areEqual('(METHOD: PUT) This is sprint 4 for the project Mojito', Y.one('#output').get('innerHTML'));
}
}));
View
@@ -158,12 +158,11 @@ function deploy (cmd, callback) {
function startArrowSelenium (callback) {
console.log("---Starting Arrow Selenium---");
- var p = runCommand(cwd+"/func/applications/frameworkapp/common", "arrow_selenium", ["--open=firefox"]);
- setTimeout(function () {
+ var p = runCommand(cwd+"/func/applications/frameworkapp/common", "arrow_selenium", ["--open=firefox"], function () {
pids.push(p.pid);
pidNames[p.pid] = 'arrow_selenium';
callback(null);
- }, 10000);
+ });
}
function runFuncTests (callback) {
Oops, something went wrong.

0 comments on commit 5a2e0a8

Please sign in to comment.