mirror of
https://github.com/zulip/zulip.git
synced 2026-06-12 21:00:58 +08:00
In stream settings, if user add subscriber to unsubscribed public stream from `Add` input widget it gives lots of blueslip warnings, cause user isn't subscribed to public stream. Fix this by changing condition to `sub.can_access_subscriber` from `sub.subscribed` in blueslip warning, cause user can access subscribers in such cases even if not subscribed to stream. Tweaked by tabbott to make the node tests pass.
82 lines
1.8 KiB
JavaScript
82 lines
1.8 KiB
JavaScript
set_global('$', function () {
|
|
});
|
|
set_global('blueslip', {});
|
|
global.blueslip.warn = function () {};
|
|
|
|
zrequire('util');
|
|
zrequire('stream_data');
|
|
zrequire('people');
|
|
zrequire('compose_fade');
|
|
|
|
var me = {
|
|
email: '[email protected]',
|
|
user_id: 30,
|
|
full_name: 'Me Myself',
|
|
};
|
|
|
|
var alice = {
|
|
email: '[email protected]',
|
|
user_id: 31,
|
|
full_name: 'Alice',
|
|
};
|
|
|
|
var bob = {
|
|
email: '[email protected]',
|
|
user_id: 32,
|
|
full_name: 'Bob',
|
|
};
|
|
|
|
people.add(me);
|
|
people.initialize_current_user(me.user_id);
|
|
|
|
people.add(alice);
|
|
people.add(bob);
|
|
|
|
|
|
(function test_set_focused_recipient() {
|
|
var sub = {
|
|
stream_id: 101,
|
|
name: 'social',
|
|
subscribed: true,
|
|
can_access_subscribers: true,
|
|
};
|
|
stream_data.add_sub('social', sub);
|
|
stream_data.set_subscribers(sub, [me.user_id, alice.user_id]);
|
|
|
|
global.$ = function (selector) {
|
|
switch (selector) {
|
|
case '#stream':
|
|
return {
|
|
val: function () {
|
|
return 'social';
|
|
},
|
|
};
|
|
case '#subject':
|
|
return {
|
|
val: function () {
|
|
return 'lunch';
|
|
},
|
|
};
|
|
}
|
|
};
|
|
|
|
compose_fade.set_focused_recipient('stream');
|
|
|
|
assert(compose_fade.would_receive_message('[email protected]'));
|
|
assert(compose_fade.would_receive_message('[email protected]'));
|
|
assert(!compose_fade.would_receive_message('[email protected]'));
|
|
|
|
var good_msg = {
|
|
type: 'stream',
|
|
stream_id: 101,
|
|
subject: 'lunch',
|
|
};
|
|
var bad_msg = {
|
|
type: 'stream',
|
|
stream_id: 999,
|
|
subject: 'lunch',
|
|
};
|
|
assert(!compose_fade.should_fade_message(good_msg));
|
|
assert(compose_fade.should_fade_message(bad_msg));
|
|
}());
|