mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
ddp-rate-limiter: simplify createTestUser; call Accounts.createUser directly and remove conditional logout/doCreate
This commit is contained in:
@@ -343,24 +343,21 @@ testAsyncMulti('ddp rate limiter - test removing rule with rateLimited ' +
|
||||
function createTestUser(test, expect) {
|
||||
const username = Random.id();
|
||||
const email = `${Random.id()}-intercept@example.com`;
|
||||
const password = 'password';
|
||||
const ret = { username, email, password }
|
||||
const password = 'password';
|
||||
|
||||
const doCreate = () => {
|
||||
Accounts.createUser(ret);
|
||||
};
|
||||
|
||||
if (Meteor.userId()) {
|
||||
Meteor.logout(expect((error) => {
|
||||
Accounts.createUser(
|
||||
{
|
||||
username,
|
||||
email,
|
||||
password,
|
||||
},
|
||||
expect((error) => {
|
||||
test.equal(error, undefined);
|
||||
test.equal(Meteor.user(), null);
|
||||
doCreate();
|
||||
}));
|
||||
} else {
|
||||
doCreate();
|
||||
}
|
||||
test.notEqual(Meteor.userId(), null);
|
||||
}),
|
||||
);
|
||||
|
||||
return ret;
|
||||
return { username, email, password };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -169,7 +169,7 @@ Tinytest.addAsync('livedata server - async publish cursor', function(
|
||||
});
|
||||
clientConn.subscribe('asyncPublishCursor', async () => {
|
||||
const actual = await remoteCollection.find().fetch();
|
||||
test.equal(actual[0]?.name, 'async');
|
||||
test.equal(actual[0].name, 'async');
|
||||
onComplete();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -104,7 +104,6 @@ export default class LocalCollection {
|
||||
options.limit = 1;
|
||||
return (await this.find(selector, options).fetchAsync())[0];
|
||||
}
|
||||
|
||||
prepareInsert(doc) {
|
||||
assertHasValidFieldNames(doc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user