Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move mongo schema format related logic into mongo adapter #1385

Merged
merged 1 commit into from
Apr 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"deepcopy": "^0.6.1",
"express": "^4.13.4",
"intersect": "^1.0.1",
"lodash": "^4.8.2",
"lru-cache": "^4.0.0",
"mailgun-js": "^0.7.7",
"mime": "^1.3.4",
Expand Down
18 changes: 9 additions & 9 deletions spec/AdaptableController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MockController.prototype = Object.create(AdaptableController.prototype);
MockController.prototype.constructor = AdaptableController;

describe("AdaptableController", ()=>{

it("should use the provided adapter", (done) => {
var adapter = new FilesAdapter();
var controller = new FilesController(adapter);
Expand All @@ -22,15 +22,15 @@ describe("AdaptableController", ()=>{
expect(controller.adapter).toBe(adapter);
done();
});

it("should throw when creating a new mock controller", (done) => {
var adapter = new FilesAdapter();
expect(() => {
new MockController(adapter);
}).toThrow();
done();
});

it("should fail setting the wrong adapter to the controller", (done) => {
function WrongAdapter() {};
var adapter = new FilesAdapter();
Expand All @@ -41,7 +41,7 @@ describe("AdaptableController", ()=>{
}).toThrow();
done();
});

it("should fail to instantiate a controller with wrong adapter", (done) => {
function WrongAdapter() {};
var adapter = new WrongAdapter();
Expand All @@ -50,14 +50,14 @@ describe("AdaptableController", ()=>{
}).toThrow();
done();
});

it("should fail to instantiate a controller without an adapter", (done) => {
expect(() => {
new FilesController();
}).toThrow();
done();
});

it("should accept an object adapter", (done) => {
var adapter = {
createFile: function(config, filename, data) { },
Expand All @@ -70,18 +70,18 @@ describe("AdaptableController", ()=>{
}).not.toThrow();
done();
});

it("should accept an object adapter", (done) => {
function AGoodAdapter() {};
AGoodAdapter.prototype.createFile = function(config, filename, data) { };
AGoodAdapter.prototype.deleteFile = function(config, filename) { };
AGoodAdapter.prototype.getFileData = function(config, filename) { };
AGoodAdapter.prototype.getFileLocation = function(config, filename) { };

var adapter = new AGoodAdapter();
expect(() => {
new FilesController(adapter);
}).not.toThrow();
done();
});
});
});
55 changes: 55 additions & 0 deletions spec/MongoSchemaCollectionAdapter.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'use strict';

const MongoSchemaCollection = require('../src/Adapters/Storage/Mongo/MongoSchemaCollection').default;

describe('MongoSchemaCollection', () => {
it('can transform legacy _client_permissions keys to parse format', done => {
expect(MongoSchemaCollection._TESTmongoSchemaToParseSchema({
"_id":"_Installation",
"_client_permissions":{
"get":true,
"find":true,
"update":true,
"create":true,
"delete":true,
},
"_metadata":{
"class_permissions":{
"get":{"*":true},
"find":{"*":true},
"update":{"*":true},
"create":{"*":true},
"delete":{"*":true},
"addField":{"*":true},
}
},
"installationId":"string",
"deviceToken":"string",
"deviceType":"string",
"channels":"array",
"user":"*_User",
})).toEqual({
className: '_Installation',
fields: {
installationId: { type: 'String' },
deviceToken: { type: 'String' },
deviceType: { type: 'String' },
channels: { type: 'Array' },
user: { type: 'Pointer', targetClass: '_User' },
ACL: { type: 'ACL' },
createdAt: { type: 'Date' },
updatedAt: { type: 'Date' },
objectId: { type: 'String' },
},
classLevelPermissions: {
find: { '*': true },
get: { '*': true },
create: { '*': true },
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
}
});
done();
});
});
21 changes: 10 additions & 11 deletions spec/OAuth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,21 @@ describe('OAuth', function() {
it("should only create a single user with REST API", (done) => {
var objectId;
createOAuthUser((error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
expect(b.objectId).not.toBeNull();
expect(b.objectId).not.toBeUndefined();
objectId = b.objectId;

createOAuthUser((error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
expect(b.objectId).not.toBeNull();
expect(b.objectId).not.toBeUndefined();
objectId = b.objectId;

createOAuthUser((error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
expect(b.objectId).not.toBeNull();
expect(b.objectId).not.toBeUndefined();
expect(b.objectId).toBe(objectId);
done();
});
expect(b.objectId).toBe(objectId);
done();
});

});
});

it("unlink and link with custom provider", (done) => {
Expand Down
Loading