|
2 | 2 |
|
3 | 3 | var GameScore = AV.Object.extend("GameScore"); |
4 | 4 | describe("ObjectACL", function () { |
5 | | - describe("*", function () { |
6 | | - it("set * acl", function () { |
7 | | - var gameScore = new GameScore(); |
8 | | - gameScore.set("score", 2); |
9 | | - gameScore.set("playerName", "sdf"); |
10 | | - gameScore.set("cheatMode", false); |
| 5 | + it("set and fetch acl", function () { |
| 6 | + var gameScore = new GameScore(); |
| 7 | + gameScore.set("score", 2); |
| 8 | + gameScore.set("playerName", "sdf"); |
| 9 | + gameScore.set("cheatMode", false); |
11 | 10 |
|
12 | | - var postACL = new AV.ACL(); |
13 | | - postACL.setPublicReadAccess(true); |
14 | | - postACL.setPublicWriteAccess(true); |
| 11 | + var postACL = new AV.ACL(); |
| 12 | + postACL.setPublicReadAccess(true); |
| 13 | + postACL.setPublicWriteAccess(true); |
15 | 14 |
|
16 | | - postACL.setReadAccess("546", true); |
17 | | - postACL.setReadAccess("56238", true); |
18 | | - postACL.setWriteAccess("5a061", true); |
19 | | - postACL.setRoleWriteAccess("r6", true); |
20 | | - gameScore.setACL(postACL); |
21 | | - return gameScore.save().then(result => { |
22 | | - result.id.should.be.ok(); |
23 | | - return gameScore.destroy(); |
| 15 | + postACL.setReadAccess("read-only", true); |
| 16 | + postACL.setWriteAccess("write-only", true); |
| 17 | + postACL.setRoleWriteAccess("write-only-role", true); |
| 18 | + gameScore.setACL(postACL); |
| 19 | + return gameScore.save().then(result => { |
| 20 | + result.id.should.be.ok(); |
| 21 | + return AV.Object.createWithoutData('GameScore', result.id).fetch({ |
| 22 | + includeACL: true, |
24 | 23 | }); |
25 | | - }); |
| 24 | + }).then(fetchedGameScore => { |
| 25 | + const acl = fetchedGameScore.getACL(); |
| 26 | + acl.should.be.instanceOf(AV.ACL); |
| 27 | + acl.getPublicReadAccess().should.eql(true); |
| 28 | + acl.getPublicWriteAccess().should.eql(true); |
| 29 | + acl.getReadAccess('read-only').should.eql(true); |
| 30 | + acl.getWriteAccess('read-only').should.eql(false); |
| 31 | + acl.getReadAccess('write-only').should.eql(false); |
| 32 | + acl.getWriteAccess('write-only').should.eql(true); |
| 33 | + acl.getRoleReadAccess('write-only-role').should.eql(false); |
| 34 | + acl.getRoleWriteAccess('write-only-role').should.eql(true); |
| 35 | + }).then( |
| 36 | + () => gameScore.destroy(), |
| 37 | + error => { |
| 38 | + gameScore.destroy(); |
| 39 | + throw error; |
| 40 | + } |
| 41 | + ); |
26 | 42 | }); |
27 | 43 | }); |
0 commit comments