diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-10 17:00:40 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-10 17:00:40 -0500 |
| commit | 89e05fb27e1f5d82c970e49307c7712a4c2a2eef (patch) | |
| tree | 57953492e346c3d3f0b8857eaf407b9b99f7cea7 | |
| parent | e6e86bbccd0e64193805863abd84c23e46136126 (diff) | |
fix cart set_user api
| -rw-r--r-- | StoneIsland/www/js/sdk/cart.js | 3 | ||||
| -rw-r--r-- | proxy/index.js | 11 | ||||
| -rw-r--r-- | test/test/04-cart.js | 18 |
3 files changed, 28 insertions, 4 deletions
diff --git a/StoneIsland/www/js/sdk/cart.js b/StoneIsland/www/js/sdk/cart.js index 26540f59..a532d5eb 100644 --- a/StoneIsland/www/js/sdk/cart.js +++ b/StoneIsland/www/js/sdk/cart.js @@ -27,7 +27,7 @@ sdk.cart = (function(){ cart.set_user = function(opt){ return $.ajax({ method: "PUT", - url: sdk.path("Cart.API/1.6", "user.json"), + url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/user.json"), headers: { "x-yoox-appname": auth.appname, "x-yoox-cart-token": cart.token, @@ -37,7 +37,6 @@ sdk.cart = (function(){ "UserToken": auth.access_token, }, success: function(data){ - console.log(data) opt.success(data) }, error: opt.error, diff --git a/proxy/index.js b/proxy/index.js index 09328ba5..14d5dc63 100644 --- a/proxy/index.js +++ b/proxy/index.js @@ -7,6 +7,8 @@ var url = require('url') var PORT = 9090 var cache = {} +var DEBUG = false + var server = http.createServer().listen(PORT, function(){ console.log('Proxy listening on: http://lvh.me:%s', PORT) }) @@ -49,10 +51,17 @@ server.on('request', function (req, res){ cache[req.url] += s.toString() }) } + if (DEBUG) { + server_res.on('data', function(s){ + console.log( s.toString() ) + }) + } server_res.resume() }) - // req.on('data', function(s){ console.log('>>', s.toString()) }) + if (DEBUG) { + req.on('data', function(s){ console.log('>>', s.toString()) }) + } req.on('error', function(s){ console.log('/!\\ ERROR /!\\'); console.log(s) }) req.pipe(connector) req.resume() diff --git a/test/test/04-cart.js b/test/test/04-cart.js index ba054bd4..a628eeb9 100644 --- a/test/test/04-cart.js +++ b/test/test/04-cart.js @@ -9,7 +9,12 @@ var assert = require("assert") // sdk.cart.get_status describe('cart', function(){ - + + if (! sdk.auth.access_token) { + sdk.auth.access_token = "45871479f5001afc06e628c7bb8e95ffb1f71df8" + sdk.auth.user_id = 374663521 + } + describe('#initialize()', function(){ it('initializes the cart', function(done){ promise(sdk.cart.initialize, { data: {} }).then(function(data){ @@ -22,7 +27,18 @@ describe('cart', function(){ }) describe('#set_user()', function(){ + it('sets user to cart', function(done){ + var user_creds = { + "UserId": sdk.auth.user_id, + "UserToken": sdk.auth.access_token, + } + promise(sdk.cart.set_user, { data: user_creds }).then(function(data){ + assert(data.Header.StatusCode == 200) + done() + }) + }) }) + describe('#add_item()', function(){ }) describe('#delete_item()', function(){ |
