示例#1
0
 it('verify simple context', function() {
     var tenant = new Tenant('cam', 'Cambridge', 'oae.google.ca');
     var user = new User(tenant, 'u:cam:physx', 'physx', 'public', 'Bert', 'Pareyn', 'PhysX');
     var ctx = new Context(tenant, user);
     assert.equal(ctx.tenant().alias, 'cam');
     assert.equal(ctx.user().id, 'u:cam:physx');
 });
示例#2
0
      _.each(folders, folder => {
        const invitationHash = _.findWhere(invitationHashes, { resourceId: folder.groupId });
        const inviterUser = inviterUsersById[invitationHash.inviterUserId];

        const invitationCtx = Context.fromUser(inviterUser);
        const invitation = Invitation.fromHash(invitationHash, folder, inviterUser);
        const memberChangeInfo = memberChangeInfosByResourceId[folder.groupId];

        return FoldersAPI.emitter.emit(
          FoldersConstants.events.UPDATED_FOLDER_MEMBERS,
          invitationCtx,
          folder,
          memberChangeInfo,
          { invitation }
        );
      });
示例#3
0
      _.each(contentItems, contentItem => {
        const invitationHash = _.findWhere(invitationHashes, { resourceId: contentItem.id });
        const inviterUser = inviterUsersById[invitationHash.inviterUserId];

        const invitationCtx = Context.fromUser(inviterUser);
        const invitation = Invitation.fromHash(invitationHash, contentItem, inviterUser);
        const memberChangeInfo = memberChangeInfosByResourceId[contentItem.id];

        return ContentAPI.emitter.emit(
          ContentConstants.events.UPDATED_CONTENT_MEMBERS,
          invitationCtx,
          contentItem,
          memberChangeInfo,
          { invitation }
        );
      });
示例#4
0
 it('verify simple context', function(callback) {
     var user = new User(global.oaeTests.tenants.cam.alias, 'u:camtest:physx', 'physx', 'public', 'Bert', 'Pareyn', 'PhysX');
     var imposter = new User(global.oaeTests.tenants.cam.alias, 'u:camtest:simong', 'simong', 'private', 'Simon', 'Gaeremynck', 'simong');
     var ctx = new Context(global.oaeTests.tenants.cam, user, 'twitter', null, imposter);
     assert.deepEqual(ctx.tenant(), global.oaeTests.tenants.cam);
     assert.deepEqual(ctx.user(), user);
     assert.strictEqual(ctx.authenticationStrategy(), 'twitter');
     assert.strictEqual(ctx.locale(), null);
     assert.deepEqual(ctx.imposter(), imposter);
     return callback();
 });
示例#5
0
 it('verify simple context', callback => {
   const user = new User(global.oaeTests.tenants.cam.alias, 'u:camtest:physx', 'physx', '*****@*****.**');
   const imposter = new User(global.oaeTests.tenants.cam.alias, 'u:camtest:simong', 'simong', '*****@*****.**');
   const ctx = new Context(global.oaeTests.tenants.cam, user, 'twitter', null, imposter);
   assert.deepStrictEqual(ctx.tenant(), global.oaeTests.tenants.cam);
   assert.deepStrictEqual(ctx.user(), user);
   assert.strictEqual(ctx.authenticationStrategy(), 'twitter');
   assert.strictEqual(ctx.locale(), null);
   assert.deepStrictEqual(ctx.imposter(), imposter);
   return callback();
 });
示例#6
0
    it('verify the locale setter can handle defaulted locales', function(callback) {
        var user = new User(global.oaeTests.tenants.cam.alias, 'u:camtest:physx', 'physx', 'public', 'Bert', 'Pareyn', 'PhysX');
        var ctx = new Context(global.oaeTests.tenants.cam, user, 'twitter', 'en_UK');
        assert.deepEqual(ctx.tenant(), global.oaeTests.tenants.cam);
        assert.deepEqual(ctx.user(), user);

        // Check that if no locale is passed in, the default constructor value is used
        assert.strictEqual(ctx.locale(), 'en_UK');

        // Check that if a "defaulted" locale is passed in, the default constructor value is used
        var defaultedLocale = new Locale('en_US');
        defaultedLocale.defaulted = true;
        assert.strictEqual(ctx.locale(defaultedLocale), 'en_UK');

        // Sanity-check that proper locale values aren't defaulted
        assert.strictEqual(ctx.locale(new Locale('be_BE')), 'be_BE');
        return callback();
    });
示例#7
0
  it('verify the locale setter can handle defaulted locales', callback => {
    const user = new User(global.oaeTests.tenants.cam.alias, 'u:camtest:physx', 'physx', '*****@*****.**');
    const ctx = new Context(global.oaeTests.tenants.cam, user, 'twitter', 'en_UK');
    assert.deepStrictEqual(ctx.tenant(), global.oaeTests.tenants.cam);
    assert.deepStrictEqual(ctx.user(), user);

    // Check that if no locale is passed in, the default constructor value is used
    assert.strictEqual(ctx.locale(), 'en_UK');

    // Check that if a "defaulted" locale is passed in, the default constructor value is used
    const defaultedLocale = new Locale('en_US');
    defaultedLocale.defaulted = true;
    assert.strictEqual(ctx.locale(defaultedLocale), 'en_UK');

    // Sanity-check that proper locale values aren't defaulted
    assert.strictEqual(ctx.locale(new Locale('be_BE')), 'be_BE');
    return callback();
  });
示例#8
0
 it('verify simple context', function() {
     var user = new User(global.oaeTests.tenants.cam.alias, 'u:camtest:physx', 'physx', 'public', 'Bert', 'Pareyn', 'PhysX');
     var ctx = new Context(global.oaeTests.tenants.cam, user);
     assert.equal(ctx.tenant().alias, 'camtest');
     assert.equal(ctx.user().id, 'u:camtest:physx');
 });