mirror of https://github.com/zulip/zulip.git
people.js: Create new add_cross_realm_user function.
The people.js tests were using _add_user function to add cross realm bots. The problem is that _add_user function doesn't properly simulates the adding process as it doesn't add the user in cross_realm_dict as well. To solve this and eliminate the need of calling people.initialize(), which means the params obj needs to be defined, we extracted the whole logic of adding a cross realm user into a separete function, add_cross_realm_user.
This commit is contained in:
parent
368e9572cc
commit
c90c8c0b19
|
@ -265,7 +265,7 @@ run_test('basics', () => {
|
|||
|
||||
// Add our cross-realm bot. It won't add to our human
|
||||
// count, and it has no owner.
|
||||
people._add_user(welcome_bot);
|
||||
people.add_cross_realm_user(welcome_bot);
|
||||
assert.equal(people.get_bot_owner_user(welcome_bot), undefined);
|
||||
assert.equal(people.get_active_human_count(), 1);
|
||||
assert.equal(
|
||||
|
|
|
@ -1048,6 +1048,13 @@ exports.add = function (person) {
|
|||
exports._add_user(person);
|
||||
};
|
||||
|
||||
exports.add_cross_realm_user = function (person) {
|
||||
if (!people_dict.has(person.email)) {
|
||||
exports._add_user(person);
|
||||
}
|
||||
cross_realm_dict.set(person.user_id, person);
|
||||
};
|
||||
|
||||
exports.deactivate = function (person) {
|
||||
// We don't fully remove a person from all of our data
|
||||
// structures, because deactivated users can be part
|
||||
|
@ -1242,10 +1249,7 @@ exports.initialize = function (my_user_id, params) {
|
|||
}
|
||||
|
||||
for (const person of params.cross_realm_bots) {
|
||||
if (!people_dict.has(person.email)) {
|
||||
exports._add_user(person);
|
||||
}
|
||||
cross_realm_dict.set(person.user_id, person);
|
||||
exports.add_cross_realm_user(person);
|
||||
}
|
||||
|
||||
exports.initialize_current_user(my_user_id);
|
||||
|
|
Loading…
Reference in New Issue