Skip to content

Commit

Permalink
Merge pull request #62 from mozilla-services/upgrade-to-kinto-1.3
Browse files Browse the repository at this point in the history
Fixes #54 - Upgrade to Kinto server v1.3.
  • Loading branch information
n1k0 committed Jul 14, 2015
2 parents 98bae34 + d396bb7 commit 48731dd
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 33 deletions.
2 changes: 1 addition & 1 deletion demo/demo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function main() {
var db = new Kinto({
remote: "http://0.0.0.0:8888/v1",
remote: "https://kinto.dev.mozaws.net/v1/",
headers: {Authorization: "Basic " + btoa("user:pass")}
});
var tasks = db.collection("tasks");
Expand Down
7 changes: 2 additions & 5 deletions dist/kinto.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/kinto.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ export default class Api {
results.conflicts.push({
type: "outgoing",
local: records[index],
// TODO: Once we get record information in this response object,
// add it; for now, that's the error json body only.
// Ref https://github.com/mozilla-services/kinto/issues/122
remote: response.body
remote: response.body.details && response.body.details.existing || null
});
} else {
results.errors.push({
Expand Down
32 changes: 18 additions & 14 deletions test/api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,11 @@ describe("Api", () => {
responses: [
{ status: 412,
path: `/${SPV}/buckets/blog/collections/articles/records/1`,
body: { invalid: true }},
body: {
details: {
existing: {title: "foo"}
}
}},
]
}));

Expand All @@ -503,7 +507,7 @@ describe("Api", () => {
conflicts: [{
type: "outgoing",
local: published[0],
remote: { invalid: true }
remote: {title: "foo"}
}],
skipped: [],
errors: [],
Expand Down Expand Up @@ -545,34 +549,34 @@ describe("Api", () => {
sandbox.stub(root, "fetch")
.onFirstCall().returns(fakeServerResponse(200, {
responses: [
{status: 412, body: {data: 1}},
{status: 412, body: {data: 2}},
{status: 412, body: {data: 3}},
{status: 412, body: {details: {existing: {id: 1}}}},
{status: 412, body: {details: {existing: {id: 2}}}},
{status: 412, body: {}},
]
}))
.onSecondCall().returns(fakeServerResponse(200, {
responses: [
{status: 412, body: {data: 4}},
{status: 412, body: {details: {existing: {id: 4}}}},
]
}));
return api.batch("blog", "articles", moreOperations)
.then(res => res.conflicts)
.should.become([{
type: "outgoing",
local: {id: 1, title: "foo"},
remote: {data: 1}
local: {id: 1, title: "foo"},
remote: {id: 1}
}, {
type: "outgoing",
local: {id: 2, title: "bar"},
remote: {data: 2}
local: {id: 2, title: "bar"},
remote: {id: 2}
}, {
type: "outgoing",
local: {id: 3, title: "baz"},
remote: {data: 3}
local: {id: 3, title: "baz"},
remote: null
}, {
type: "outgoing",
local: {id: 4, title: "qux"},
remote: {data: 4}
local: {id: 4, title: "qux"},
remote: {id: 4}
}]);
});

Expand Down
8 changes: 1 addition & 7 deletions test/integration_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,7 @@ describe("Integration tests", () => {
expect(syncResult.conflicts).to.have.length.of(1);
expect(syncResult.conflicts[0].type).eql("outgoing");
expect(syncResult.conflicts[0].local.title).eql("foo");
// TODO: https://github.com/mozilla-services/kinto/issues/122
expect(cleanRecord(syncResult.conflicts[0].remote)).eql({
"code": 412,
"errno": 999,
"error": "Precondition Failed",
"message": "Failed batch subrequest",
});
expect(syncResult.conflicts[0].remote.title).eql("foo");
});

it("should not have skipped records", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/setup-kinto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fi

REPO_ROOT=`pwd`
KINTO_ROOT=/var/tmp/kinto
KINTO_RELEASE=1.2.0
KINTO_RELEASE=1.3.0

git clone https://github.com/mozilla-services/kinto.git $KINTO_ROOT
cd $KINTO_ROOT
Expand Down

0 comments on commit 48731dd

Please sign in to comment.