mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 02:17:19 +00:00
delete_sub: Do not remove archived stream when deactivated.
Stream is simply marked as `archived: true` instead of removing the stream from `sub_store` and `stream_info`. A check in `subscribe_myself` is added before subscribing to a stream.
This commit is contained in:
@@ -579,24 +579,32 @@ test("default_stream_names", () => {
|
||||
|
||||
test("delete_sub", () => {
|
||||
const canada = {
|
||||
is_archived: false,
|
||||
stream_id: 101,
|
||||
name: "Canada",
|
||||
subscribed: true,
|
||||
};
|
||||
|
||||
stream_data.add_sub(canada);
|
||||
const num_subscribed_subs = stream_data.num_subscribed_subs();
|
||||
|
||||
assert.ok(stream_data.is_subscribed(canada.stream_id));
|
||||
assert.equal(stream_data.get_sub("Canada").stream_id, canada.stream_id);
|
||||
assert.equal(sub_store.get(canada.stream_id).name, "Canada");
|
||||
assert.equal(stream_data.is_stream_archived(canada.stream_id), false);
|
||||
|
||||
stream_data.delete_sub(canada.stream_id);
|
||||
assert.ok(!stream_data.is_subscribed(canada.stream_id));
|
||||
assert.ok(!stream_data.get_sub("Canada"));
|
||||
assert.ok(!sub_store.get(canada.stream_id));
|
||||
assert.ok(stream_data.is_stream_archived(canada.stream_id));
|
||||
assert.ok(stream_data.is_subscribed(canada.stream_id));
|
||||
assert.ok(stream_data.get_sub("Canada"));
|
||||
assert.ok(sub_store.get(canada.stream_id));
|
||||
assert.equal(stream_data.num_subscribed_subs(), num_subscribed_subs - 1);
|
||||
|
||||
blueslip.expect("warn", "Failed to archive stream 99999");
|
||||
stream_data.delete_sub(99999);
|
||||
|
||||
blueslip.expect("warn", "Can't subscribe to an archived stream.");
|
||||
stream_data.subscribe_myself(canada);
|
||||
});
|
||||
|
||||
test("notifications", ({override}) => {
|
||||
|
||||
Reference in New Issue
Block a user