3 var fixtureLoader = require('gitter-web-test-utils/lib/test-fixtures');
4 var assert = require('assert');
5 var mongoUtils = require('gitter-web-persistence-utils/lib/mongo-utils');
6 var troupeService = require('../lib/troupe-service');
8 describe('troupe-service', function() {
9 var fixture = fixtureLoader.setup({
13 users: ['user1', 'user2']
18 describe('#findByIdLeanWithMembership', function() {
19 it('should find a room which exists and the user has access', function(done) {
21 .findByIdLeanWithMembership(fixture.troupe1.id, fixture.user1.id)
22 .spread(function(room, access) {
23 assert.strictEqual(room.id, fixture.troupe1.id);
24 assert.strictEqual(access, true);
29 it('should find a room which exists and the does not have access', function(done) {
31 .findByIdLeanWithMembership(fixture.troupe2.id, fixture.user1.id)
32 .spread(function(room, access) {
34 assert.strictEqual(room.id, fixture.troupe2.id);
35 assert.strictEqual(access, false);
40 it('should not find a room which does not exist, for a user', function(done) {
42 .findByIdLeanWithMembership(mongoUtils.getNewObjectIdString(), fixture.user1.id)
43 .spread(function(room, access) {
50 it('should find a room which exists and for anon', function(done) {
52 .findByIdLeanWithMembership(fixture.troupe2.id, null)
53 .spread(function(room, access) {
60 it('should not find a room which does not exist for anon', function(done) {
62 .findByIdLeanWithMembership(mongoUtils.getNewObjectIdString(), null)
63 .spread(function(room, access) {