2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 21:27:38 -05:00
|
|
|
RSpec.describe TopicTrackingState do
|
2021-12-22 11:09:43 -06:00
|
|
|
fab!(:user) { Fabricate(:user) }
|
2022-06-29 19:18:12 -05:00
|
|
|
fab!(:whisperers_group) { Fabricate(:group) }
|
2013-05-21 01:39:51 -05:00
|
|
|
|
|
|
|
let(:post) do
|
2013-07-22 00:06:53 -05:00
|
|
|
create_post
|
2013-05-21 01:39:51 -05:00
|
|
|
end
|
|
|
|
|
2018-03-05 02:18:23 -06:00
|
|
|
let(:topic) { post.topic }
|
2019-05-06 22:12:20 -05:00
|
|
|
fab!(:private_message_post) { Fabricate(:private_message_post) }
|
2018-03-06 00:38:43 -06:00
|
|
|
let(:private_message_topic) { private_message_post.topic }
|
2018-03-05 02:18:23 -06:00
|
|
|
|
|
|
|
describe '#publish_latest' do
|
|
|
|
it 'can correctly publish latest' do
|
|
|
|
message = MessageBus.track_publish("/latest") do
|
|
|
|
described_class.publish_latest(topic)
|
|
|
|
end.first
|
|
|
|
|
|
|
|
data = message.data
|
|
|
|
|
|
|
|
expect(data["topic_id"]).to eq(topic.id)
|
|
|
|
expect(data["message_type"]).to eq(described_class::LATEST_MESSAGE_TYPE)
|
|
|
|
expect(data["payload"]["archetype"]).to eq(Archetype.default)
|
|
|
|
end
|
|
|
|
|
2022-06-29 19:18:12 -05:00
|
|
|
it "publishes whisper post to staff users and members of whisperers group" do
|
|
|
|
whisperers_group = Fabricate(:group)
|
|
|
|
Fabricate(:user, groups: [whisperers_group])
|
|
|
|
Fabricate(:topic_user_watching, topic: topic, user: user)
|
|
|
|
SiteSetting.enable_whispers = true
|
|
|
|
SiteSetting.whispers_allowed_groups = "#{whisperers_group.id}"
|
|
|
|
post.update!(post_type: Post.types[:whisper])
|
|
|
|
|
|
|
|
message = MessageBus.track_publish("/latest") do
|
|
|
|
TopicTrackingState.publish_latest(post.topic, true)
|
|
|
|
end.first
|
|
|
|
|
|
|
|
expect(message.group_ids).to contain_exactly(whisperers_group.id, Group::AUTO_GROUPS[:staff])
|
|
|
|
end
|
|
|
|
|
2018-03-05 02:18:23 -06:00
|
|
|
describe 'private message' do
|
|
|
|
it 'should not publish any message' do
|
|
|
|
messages = MessageBus.track_publish do
|
2018-03-06 00:38:43 -06:00
|
|
|
described_class.publish_latest(private_message_topic)
|
2018-03-05 02:18:23 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(messages).to eq([])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-07 22:55:12 -05:00
|
|
|
describe '.publish_read' do
|
|
|
|
it 'correctly publish read' do
|
|
|
|
message = MessageBus.track_publish(described_class.unread_channel_key(post.user.id)) do
|
|
|
|
TopicTrackingState.publish_read(post.topic_id, 1, post.user)
|
|
|
|
end.first
|
|
|
|
|
|
|
|
data = message.data
|
|
|
|
|
|
|
|
expect(message.user_ids).to contain_exactly(post.user_id)
|
|
|
|
expect(message.group_ids).to eq(nil)
|
|
|
|
expect(data["topic_id"]).to eq(post.topic_id)
|
|
|
|
expect(data["message_type"]).to eq(described_class::READ_MESSAGE_TYPE)
|
|
|
|
expect(data["payload"]["last_read_post_number"]).to eq(1)
|
|
|
|
expect(data["payload"]["highest_post_number"]).to eq(1)
|
|
|
|
expect(data["payload"]["notification_level"]).to eq(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'correctly publish read for staff' do
|
2022-06-29 19:18:12 -05:00
|
|
|
SiteSetting.enable_whispers = true
|
2021-09-07 22:55:12 -05:00
|
|
|
create_post(
|
|
|
|
raw: "this is a test post",
|
|
|
|
topic: post.topic,
|
|
|
|
post_type: Post.types[:whisper],
|
|
|
|
user: Fabricate(:admin)
|
|
|
|
)
|
|
|
|
|
|
|
|
post.user.grant_admin!
|
|
|
|
|
|
|
|
message = MessageBus.track_publish(described_class.unread_channel_key(post.user.id)) do
|
|
|
|
TopicTrackingState.publish_read(post.topic_id, 1, post.user)
|
|
|
|
end.first
|
|
|
|
|
|
|
|
data = message.data
|
|
|
|
|
|
|
|
expect(data["payload"]["highest_post_number"]).to eq(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-05 02:18:23 -06:00
|
|
|
describe '#publish_unread' do
|
FIX: Issues with incorrect unread and private message topic tracking state (#16474)
This commit fixes two issues at play. The first was introduced
in f6c852b (or maybe not introduced
but rather revealed). When a user posted a new message in a topic,
they received the unread topic tracking state MessageBus message,
and the Unread (X) indicator was incremented by one, because with the
aforementioned perf commit we "guess" the correct last read post
for the user, because we no longer calculate individual users' read
status there. This meant that every time a user posted in a topic
they tracked, the unread indicator was incremented. To get around
this, we can just exclude the user who created the post from the
target users of the unread state message.
The second issue was related to the private message topic tracking
state, and was somewhat similar. Whenever a user created a new private
message, the New (X) indicator was incremented, and could not be
cleared until the page was refreshed. To solve this, we just don't
update the topic state for the user when the new_topic tracking state
message comes through if the user who created the topic is the
same as the current user.
cf. https://meta.discourse.org/t/bottom-of-topic-shows-there-is-1-unread-remaining-when-there-are-actually-0-unread-topics-remaining/220817
2022-04-18 20:37:01 -05:00
|
|
|
let(:other_user) { Fabricate(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Fabricate(:topic_user_watching, topic: topic, user: other_user)
|
|
|
|
end
|
|
|
|
|
2018-03-05 02:18:23 -06:00
|
|
|
it "can correctly publish unread" do
|
2022-02-22 09:27:46 -06:00
|
|
|
message = MessageBus.track_publish("/unread") do
|
2018-03-05 02:18:23 -06:00
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end.first
|
|
|
|
|
|
|
|
data = message.data
|
|
|
|
|
FIX: Issues with incorrect unread and private message topic tracking state (#16474)
This commit fixes two issues at play. The first was introduced
in f6c852b (or maybe not introduced
but rather revealed). When a user posted a new message in a topic,
they received the unread topic tracking state MessageBus message,
and the Unread (X) indicator was incremented by one, because with the
aforementioned perf commit we "guess" the correct last read post
for the user, because we no longer calculate individual users' read
status there. This meant that every time a user posted in a topic
they tracked, the unread indicator was incremented. To get around
this, we can just exclude the user who created the post from the
target users of the unread state message.
The second issue was related to the private message topic tracking
state, and was somewhat similar. Whenever a user created a new private
message, the New (X) indicator was incremented, and could not be
cleared until the page was refreshed. To solve this, we just don't
update the topic state for the user when the new_topic tracking state
message comes through if the user who created the topic is the
same as the current user.
cf. https://meta.discourse.org/t/bottom-of-topic-shows-there-is-1-unread-remaining-when-there-are-actually-0-unread-topics-remaining/220817
2022-04-18 20:37:01 -05:00
|
|
|
expect(message.user_ids).to contain_exactly(other_user.id)
|
2021-08-10 22:01:13 -05:00
|
|
|
expect(message.group_ids).to eq(nil)
|
2018-03-05 02:18:23 -06:00
|
|
|
expect(data["topic_id"]).to eq(topic.id)
|
|
|
|
expect(data["message_type"]).to eq(described_class::UNREAD_MESSAGE_TYPE)
|
|
|
|
expect(data["payload"]["archetype"]).to eq(Archetype.default)
|
|
|
|
end
|
|
|
|
|
FIX: Issues with incorrect unread and private message topic tracking state (#16474)
This commit fixes two issues at play. The first was introduced
in f6c852b (or maybe not introduced
but rather revealed). When a user posted a new message in a topic,
they received the unread topic tracking state MessageBus message,
and the Unread (X) indicator was incremented by one, because with the
aforementioned perf commit we "guess" the correct last read post
for the user, because we no longer calculate individual users' read
status there. This meant that every time a user posted in a topic
they tracked, the unread indicator was incremented. To get around
this, we can just exclude the user who created the post from the
target users of the unread state message.
The second issue was related to the private message topic tracking
state, and was somewhat similar. Whenever a user created a new private
message, the New (X) indicator was incremented, and could not be
cleared until the page was refreshed. To solve this, we just don't
update the topic state for the user when the new_topic tracking state
message comes through if the user who created the topic is the
same as the current user.
cf. https://meta.discourse.org/t/bottom-of-topic-shows-there-is-1-unread-remaining-when-there-are-actually-0-unread-topics-remaining/220817
2022-04-18 20:37:01 -05:00
|
|
|
it "does not publish unread to the user who created the post" do
|
|
|
|
message = MessageBus.track_publish("/unread") do
|
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end.first
|
|
|
|
|
|
|
|
data = message.data
|
|
|
|
|
|
|
|
expect(message.user_ids).not_to include(post.user_id)
|
|
|
|
expect(data["topic_id"]).to eq(topic.id)
|
|
|
|
expect(data["message_type"]).to eq(described_class::UNREAD_MESSAGE_TYPE)
|
|
|
|
expect(data["payload"]["archetype"]).to eq(Archetype.default)
|
|
|
|
end
|
|
|
|
|
2021-10-10 21:20:55 -05:00
|
|
|
it "is not erroring when user_stat is missing" do
|
|
|
|
post.user.user_stat.destroy!
|
2022-02-22 09:27:46 -06:00
|
|
|
message = MessageBus.track_publish("/unread") do
|
2021-10-10 21:20:55 -05:00
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end.first
|
|
|
|
|
|
|
|
data = message.data
|
|
|
|
|
FIX: Issues with incorrect unread and private message topic tracking state (#16474)
This commit fixes two issues at play. The first was introduced
in f6c852b (or maybe not introduced
but rather revealed). When a user posted a new message in a topic,
they received the unread topic tracking state MessageBus message,
and the Unread (X) indicator was incremented by one, because with the
aforementioned perf commit we "guess" the correct last read post
for the user, because we no longer calculate individual users' read
status there. This meant that every time a user posted in a topic
they tracked, the unread indicator was incremented. To get around
this, we can just exclude the user who created the post from the
target users of the unread state message.
The second issue was related to the private message topic tracking
state, and was somewhat similar. Whenever a user created a new private
message, the New (X) indicator was incremented, and could not be
cleared until the page was refreshed. To solve this, we just don't
update the topic state for the user when the new_topic tracking state
message comes through if the user who created the topic is the
same as the current user.
cf. https://meta.discourse.org/t/bottom-of-topic-shows-there-is-1-unread-remaining-when-there-are-actually-0-unread-topics-remaining/220817
2022-04-18 20:37:01 -05:00
|
|
|
expect(message.user_ids).to contain_exactly(other_user.id)
|
2021-10-10 21:20:55 -05:00
|
|
|
end
|
|
|
|
|
2022-06-29 19:18:12 -05:00
|
|
|
it "publishes whisper post to staff users and members of whisperers group" do
|
|
|
|
whisperers_group = Fabricate(:group)
|
|
|
|
Fabricate(:topic_user_watching, topic: topic, user: user)
|
|
|
|
SiteSetting.enable_whispers = true
|
|
|
|
SiteSetting.whispers_allowed_groups = "#{whisperers_group.id}"
|
|
|
|
post.update!(post_type: Post.types[:whisper])
|
|
|
|
|
|
|
|
messages = MessageBus.track_publish("/unread") do
|
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(messages).to eq([])
|
|
|
|
|
|
|
|
user.groups << whisperers_group
|
|
|
|
other_user.grant_admin!
|
|
|
|
|
|
|
|
message = MessageBus.track_publish("/unread") do
|
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end.first
|
|
|
|
|
|
|
|
expect(message.user_ids).to contain_exactly(user.id, other_user.id)
|
|
|
|
expect(message.group_ids).to eq(nil)
|
|
|
|
end
|
|
|
|
|
2021-08-10 22:01:13 -05:00
|
|
|
it "does not publish whisper post to non-staff users" do
|
2022-06-29 19:18:12 -05:00
|
|
|
SiteSetting.enable_whispers = true
|
2021-08-10 22:01:13 -05:00
|
|
|
post.update!(post_type: Post.types[:whisper])
|
|
|
|
|
2022-02-22 09:27:46 -06:00
|
|
|
messages = MessageBus.track_publish("/unread") do
|
2021-08-10 22:01:13 -05:00
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(messages).to eq([])
|
|
|
|
|
FIX: Issues with incorrect unread and private message topic tracking state (#16474)
This commit fixes two issues at play. The first was introduced
in f6c852b (or maybe not introduced
but rather revealed). When a user posted a new message in a topic,
they received the unread topic tracking state MessageBus message,
and the Unread (X) indicator was incremented by one, because with the
aforementioned perf commit we "guess" the correct last read post
for the user, because we no longer calculate individual users' read
status there. This meant that every time a user posted in a topic
they tracked, the unread indicator was incremented. To get around
this, we can just exclude the user who created the post from the
target users of the unread state message.
The second issue was related to the private message topic tracking
state, and was somewhat similar. Whenever a user created a new private
message, the New (X) indicator was incremented, and could not be
cleared until the page was refreshed. To solve this, we just don't
update the topic state for the user when the new_topic tracking state
message comes through if the user who created the topic is the
same as the current user.
cf. https://meta.discourse.org/t/bottom-of-topic-shows-there-is-1-unread-remaining-when-there-are-actually-0-unread-topics-remaining/220817
2022-04-18 20:37:01 -05:00
|
|
|
other_user.grant_admin!
|
2021-08-10 22:01:13 -05:00
|
|
|
|
2022-02-22 09:27:46 -06:00
|
|
|
message = MessageBus.track_publish("/unread") do
|
2021-08-10 22:01:13 -05:00
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end.first
|
|
|
|
|
FIX: Issues with incorrect unread and private message topic tracking state (#16474)
This commit fixes two issues at play. The first was introduced
in f6c852b (or maybe not introduced
but rather revealed). When a user posted a new message in a topic,
they received the unread topic tracking state MessageBus message,
and the Unread (X) indicator was incremented by one, because with the
aforementioned perf commit we "guess" the correct last read post
for the user, because we no longer calculate individual users' read
status there. This meant that every time a user posted in a topic
they tracked, the unread indicator was incremented. To get around
this, we can just exclude the user who created the post from the
target users of the unread state message.
The second issue was related to the private message topic tracking
state, and was somewhat similar. Whenever a user created a new private
message, the New (X) indicator was incremented, and could not be
cleared until the page was refreshed. To solve this, we just don't
update the topic state for the user when the new_topic tracking state
message comes through if the user who created the topic is the
same as the current user.
cf. https://meta.discourse.org/t/bottom-of-topic-shows-there-is-1-unread-remaining-when-there-are-actually-0-unread-topics-remaining/220817
2022-04-18 20:37:01 -05:00
|
|
|
expect(message.user_ids).to contain_exactly(other_user.id)
|
2021-08-10 22:01:13 -05:00
|
|
|
expect(message.group_ids).to eq(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "correctly publishes unread for a post in a restricted category" do
|
|
|
|
group = Fabricate(:group)
|
|
|
|
category = Fabricate(:private_category, group: group)
|
|
|
|
|
|
|
|
post.topic.update!(category: category)
|
|
|
|
|
2022-02-22 09:27:46 -06:00
|
|
|
messages = MessageBus.track_publish("/unread") do
|
2021-08-10 22:01:13 -05:00
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(messages).to eq([])
|
|
|
|
|
FIX: Issues with incorrect unread and private message topic tracking state (#16474)
This commit fixes two issues at play. The first was introduced
in f6c852b (or maybe not introduced
but rather revealed). When a user posted a new message in a topic,
they received the unread topic tracking state MessageBus message,
and the Unread (X) indicator was incremented by one, because with the
aforementioned perf commit we "guess" the correct last read post
for the user, because we no longer calculate individual users' read
status there. This meant that every time a user posted in a topic
they tracked, the unread indicator was incremented. To get around
this, we can just exclude the user who created the post from the
target users of the unread state message.
The second issue was related to the private message topic tracking
state, and was somewhat similar. Whenever a user created a new private
message, the New (X) indicator was incremented, and could not be
cleared until the page was refreshed. To solve this, we just don't
update the topic state for the user when the new_topic tracking state
message comes through if the user who created the topic is the
same as the current user.
cf. https://meta.discourse.org/t/bottom-of-topic-shows-there-is-1-unread-remaining-when-there-are-actually-0-unread-topics-remaining/220817
2022-04-18 20:37:01 -05:00
|
|
|
group.add(other_user)
|
2021-08-10 22:01:13 -05:00
|
|
|
|
2022-02-22 09:27:46 -06:00
|
|
|
message = MessageBus.track_publish("/unread") do
|
2021-08-10 22:01:13 -05:00
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end.first
|
|
|
|
|
FIX: Issues with incorrect unread and private message topic tracking state (#16474)
This commit fixes two issues at play. The first was introduced
in f6c852b (or maybe not introduced
but rather revealed). When a user posted a new message in a topic,
they received the unread topic tracking state MessageBus message,
and the Unread (X) indicator was incremented by one, because with the
aforementioned perf commit we "guess" the correct last read post
for the user, because we no longer calculate individual users' read
status there. This meant that every time a user posted in a topic
they tracked, the unread indicator was incremented. To get around
this, we can just exclude the user who created the post from the
target users of the unread state message.
The second issue was related to the private message topic tracking
state, and was somewhat similar. Whenever a user created a new private
message, the New (X) indicator was incremented, and could not be
cleared until the page was refreshed. To solve this, we just don't
update the topic state for the user when the new_topic tracking state
message comes through if the user who created the topic is the
same as the current user.
cf. https://meta.discourse.org/t/bottom-of-topic-shows-there-is-1-unread-remaining-when-there-are-actually-0-unread-topics-remaining/220817
2022-04-18 20:37:01 -05:00
|
|
|
expect(message.user_ids).to contain_exactly(other_user.id)
|
2021-08-10 22:01:13 -05:00
|
|
|
expect(message.group_ids).to eq(nil)
|
|
|
|
end
|
|
|
|
|
2018-03-05 02:18:23 -06:00
|
|
|
describe 'for a private message' do
|
|
|
|
before do
|
|
|
|
TopicUser.change(
|
2018-03-06 00:38:43 -06:00
|
|
|
private_message_topic.allowed_users.first.id,
|
|
|
|
private_message_topic.id,
|
2018-03-05 02:18:23 -06:00
|
|
|
notification_level: TopicUser.notification_levels[:tracking]
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not publish any message' do
|
|
|
|
messages = MessageBus.track_publish do
|
|
|
|
TopicTrackingState.publish_unread(private_message_post)
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(messages).to eq([])
|
|
|
|
end
|
|
|
|
end
|
2013-05-29 03:11:04 -05:00
|
|
|
end
|
|
|
|
|
2020-04-22 23:57:35 -05:00
|
|
|
describe '#publish_muted' do
|
|
|
|
let(:user) do
|
|
|
|
Fabricate(:user, last_seen_at: Date.today)
|
|
|
|
end
|
|
|
|
let(:post) do
|
|
|
|
create_post(user: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'can correctly publish muted' do
|
2020-04-30 17:33:57 -05:00
|
|
|
TopicUser.find_by(topic: topic, user: post.user).update(notification_level: 0)
|
2020-04-22 23:57:35 -05:00
|
|
|
messages = MessageBus.track_publish("/latest") do
|
2020-04-30 17:33:57 -05:00
|
|
|
TopicTrackingState.publish_muted(topic)
|
2020-04-22 23:57:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
muted_message = messages.find { |message| message.data["message_type"] == "muted" }
|
|
|
|
|
|
|
|
expect(muted_message.data["topic_id"]).to eq(topic.id)
|
|
|
|
expect(muted_message.data["message_type"]).to eq(described_class::MUTED_MESSAGE_TYPE)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not publish any message when notification level is not muted' do
|
|
|
|
messages = MessageBus.track_publish("/latest") do
|
2020-04-30 17:33:57 -05:00
|
|
|
TopicTrackingState.publish_muted(topic)
|
2020-04-22 23:57:35 -05:00
|
|
|
end
|
|
|
|
muted_messages = messages.select { |message| message.data["message_type"] == "muted" }
|
|
|
|
|
|
|
|
expect(muted_messages).to eq([])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not publish any message when the user was not seen in the last 7 days' do
|
2020-04-30 17:33:57 -05:00
|
|
|
TopicUser.find_by(topic: topic, user: post.user).update(notification_level: 0)
|
2020-04-22 23:57:35 -05:00
|
|
|
post.user.update(last_seen_at: 8.days.ago)
|
|
|
|
messages = MessageBus.track_publish("/latest") do
|
2020-04-30 17:33:57 -05:00
|
|
|
TopicTrackingState.publish_muted(topic)
|
2020-04-22 23:57:35 -05:00
|
|
|
end
|
|
|
|
muted_messages = messages.select { |message| message.data["message_type"] == "muted" }
|
|
|
|
expect(muted_messages).to eq([])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-12-09 23:49:05 -06:00
|
|
|
describe '#publish_unmuted' do
|
|
|
|
let(:user) do
|
|
|
|
Fabricate(:user, last_seen_at: Date.today)
|
|
|
|
end
|
|
|
|
let(:second_user) do
|
|
|
|
Fabricate(:user, last_seen_at: Date.today)
|
|
|
|
end
|
|
|
|
let(:third_user) do
|
|
|
|
Fabricate(:user, last_seen_at: Date.today)
|
|
|
|
end
|
|
|
|
let(:post) do
|
|
|
|
create_post(user: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'can correctly publish unmuted' do
|
|
|
|
Fabricate(:topic_tag, topic: topic)
|
|
|
|
SiteSetting.mute_all_categories_by_default = true
|
|
|
|
TopicUser.find_by(topic: topic, user: post.user).update(notification_level: 1)
|
|
|
|
CategoryUser.create!(category: topic.category, user: second_user, notification_level: 1)
|
|
|
|
TagUser.create!(tag: topic.tags.first, user: third_user, notification_level: 1)
|
|
|
|
TagUser.create!(tag: topic.tags.first, user: Fabricate(:user), notification_level: 0)
|
|
|
|
messages = MessageBus.track_publish("/latest") do
|
|
|
|
TopicTrackingState.publish_unmuted(topic)
|
|
|
|
end
|
|
|
|
|
|
|
|
unmuted_message = messages.find { |message| message.data["message_type"] == "unmuted" }
|
|
|
|
expect(unmuted_message.user_ids.sort).to eq([user.id, second_user.id, third_user.id].sort)
|
|
|
|
expect(unmuted_message.data["topic_id"]).to eq(topic.id)
|
|
|
|
expect(unmuted_message.data["message_type"]).to eq(described_class::UNMUTED_MESSAGE_TYPE)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not publish any message when notification level is not muted' do
|
|
|
|
SiteSetting.mute_all_categories_by_default = true
|
|
|
|
TopicUser.find_by(topic: topic, user: post.user).update(notification_level: 0)
|
|
|
|
messages = MessageBus.track_publish("/latest") do
|
|
|
|
TopicTrackingState.publish_unmuted(topic)
|
|
|
|
end
|
|
|
|
unmuted_messages = messages.select { |message| message.data["message_type"] == "unmuted" }
|
|
|
|
|
|
|
|
expect(unmuted_messages).to eq([])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not publish any message when the user was not seen in the last 7 days' do
|
|
|
|
TopicUser.find_by(topic: topic, user: post.user).update(notification_level: 1)
|
|
|
|
post.user.update(last_seen_at: 8.days.ago)
|
|
|
|
messages = MessageBus.track_publish("/latest") do
|
|
|
|
TopicTrackingState.publish_unmuted(topic)
|
|
|
|
end
|
|
|
|
unmuted_messages = messages.select { |message| message.data["message_type"] == "unmuted" }
|
|
|
|
expect(unmuted_messages).to eq([])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-27 07:09:00 -05:00
|
|
|
describe '#publish_read_private_message' do
|
|
|
|
fab!(:group) { Fabricate(:group) }
|
2020-08-12 00:56:06 -05:00
|
|
|
let(:read_topic_key) { "/private-messages/unread-indicator/#{group_message.id}" }
|
|
|
|
let(:read_post_key) { "/topic/#{group_message.id}" }
|
|
|
|
let(:group_message) { Fabricate(:private_message_topic,
|
2019-08-27 07:09:00 -05:00
|
|
|
allowed_groups: [group],
|
|
|
|
topic_allowed_users: [Fabricate.build(:topic_allowed_user, user: user)],
|
|
|
|
)
|
2020-08-12 00:56:06 -05:00
|
|
|
}
|
|
|
|
let!(:post) {
|
2022-11-21 16:48:27 -06:00
|
|
|
Fabricate(:post, topic: group_message)
|
|
|
|
}
|
|
|
|
|
|
|
|
let!(:post_2) {
|
|
|
|
Fabricate(:post, topic: group_message)
|
2020-08-12 00:56:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
before do
|
|
|
|
group.add(user)
|
2022-11-21 16:48:27 -06:00
|
|
|
group_message.update!(highest_post_number: post_2.post_number)
|
2019-08-27 07:09:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not trigger a read count update if no allowed groups have the option enabled' do
|
|
|
|
messages = MessageBus.track_publish(read_post_key) do
|
2022-11-21 16:48:27 -06:00
|
|
|
TopicTrackingState.publish_read_indicator_on_read(group_message.id, post_2.post_number, user.id)
|
2019-08-27 07:09:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(messages).to be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the read indicator is enabled' do
|
|
|
|
before { group.update!(publish_read_state: true) }
|
|
|
|
|
2019-08-29 10:03:43 -05:00
|
|
|
it 'publishes a message to hide the unread indicator' do
|
2019-08-27 07:09:00 -05:00
|
|
|
message = MessageBus.track_publish(read_topic_key) do
|
2022-11-21 16:48:27 -06:00
|
|
|
TopicTrackingState.publish_read_indicator_on_read(group_message.id, post_2.post_number, user.id)
|
2019-08-27 07:09:00 -05:00
|
|
|
end.first
|
|
|
|
|
2020-08-12 00:56:06 -05:00
|
|
|
expect(message.data['topic_id']).to eq group_message.id
|
2019-08-29 10:03:43 -05:00
|
|
|
expect(message.data['show_indicator']).to eq false
|
2019-08-27 07:09:00 -05:00
|
|
|
end
|
|
|
|
|
2019-08-29 10:03:43 -05:00
|
|
|
it 'publishes a message to show the unread indicator when a non-member creates a new post' do
|
2020-08-12 00:56:06 -05:00
|
|
|
allowed_user = Fabricate(:topic_allowed_user, topic: group_message)
|
2019-08-29 10:03:43 -05:00
|
|
|
message = MessageBus.track_publish(read_topic_key) do
|
2022-11-21 16:48:27 -06:00
|
|
|
TopicTrackingState.publish_read_indicator_on_write(group_message.id, post_2.post_number, allowed_user.id)
|
2019-08-29 10:03:43 -05:00
|
|
|
end.first
|
|
|
|
|
2020-08-12 00:56:06 -05:00
|
|
|
expect(message.data['topic_id']).to eq group_message.id
|
2019-08-29 10:03:43 -05:00
|
|
|
expect(message.data['show_indicator']).to eq true
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not publish the unread indicator if the message is not the last one' do
|
2019-08-27 07:09:00 -05:00
|
|
|
messages = MessageBus.track_publish(read_topic_key) do
|
2022-11-21 16:48:27 -06:00
|
|
|
TopicTrackingState.publish_read_indicator_on_read(group_message.id, post.post_number, user.id)
|
2019-08-27 07:09:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(messages).to be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not publish the read indicator if the user is not a group member' do
|
2020-08-12 00:56:06 -05:00
|
|
|
allowed_user = Fabricate(:topic_allowed_user, topic: group_message)
|
2019-08-27 07:09:00 -05:00
|
|
|
messages = MessageBus.track_publish(read_topic_key) do
|
2022-11-21 16:48:27 -06:00
|
|
|
TopicTrackingState.publish_read_indicator_on_read(group_message.id, post_2.post_number, allowed_user.user_id)
|
2019-08-27 07:09:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(messages).to be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'publish a read count update to every client' do
|
|
|
|
message = MessageBus.track_publish(read_post_key) do
|
2022-11-21 16:48:27 -06:00
|
|
|
TopicTrackingState.publish_read_indicator_on_read(group_message.id, post_2.post_number, user.id)
|
2019-08-27 07:09:00 -05:00
|
|
|
end.first
|
|
|
|
|
|
|
|
expect(message.data[:type]).to eq :read
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-16 23:03:08 -05:00
|
|
|
it "correctly handles muted categories" do
|
|
|
|
post
|
|
|
|
|
2016-12-02 00:03:31 -06:00
|
|
|
report = TopicTrackingState.report(user)
|
2015-04-16 23:03:08 -05:00
|
|
|
expect(report.length).to eq(1)
|
|
|
|
|
|
|
|
CategoryUser.create!(user_id: user.id,
|
|
|
|
notification_level: CategoryUser.notification_levels[:muted],
|
|
|
|
category_id: post.topic.category_id
|
|
|
|
)
|
|
|
|
|
|
|
|
create_post(topic_id: post.topic_id)
|
|
|
|
|
2016-12-02 00:03:31 -06:00
|
|
|
report = TopicTrackingState.report(user)
|
2015-04-16 23:03:08 -05:00
|
|
|
expect(report.length).to eq(0)
|
|
|
|
|
|
|
|
TopicUser.create!(user_id: user.id, topic_id: post.topic_id, last_read_post_number: 1, notification_level: 3)
|
|
|
|
|
FIX: New/unread count after dismissing new topics in a regular category (#8659)
6e1fe22 introduced the possiblity for category_users to have a NULL notification_level, so that we can store `last_seen_at` dates without locking the notification level. At the time, this did not affect the topic-tracking-state query. However, the query changes in f434de2 introduced a slight change in behavior.
Previously, a subquery would look for a category_user with notification_level=mute. f434de2 refactored this to remove the subquery, and inverted some of the logic to suit.
The new query checked for `notification_level <> :muted`. If `notification_level` is NULL, this comparison will return NULL. In this scenario, notification_level=NULL means that we should fall back to the default tracking level (regular), and so we want the expression to resolve as true, not false. There was already a check for the existence of the category_users row, but it did not check for the existence of a NOT NULL notification_level.
This commit amends the expression so that the notification_level will only be compared if it is non-null.
2020-01-06 10:15:24 -06:00
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
end
|
|
|
|
|
2022-03-01 22:02:09 -06:00
|
|
|
it "correctly handles indirectly muted categories" do
|
|
|
|
parent_category = Fabricate(:category)
|
|
|
|
sub_category = Fabricate(:category, parent_category_id: parent_category.id)
|
|
|
|
create_post(category: sub_category)
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
|
|
|
|
CategoryUser.create!(
|
|
|
|
user_id: user.id,
|
|
|
|
notification_level: CategoryUser.notification_levels[:muted],
|
|
|
|
category_id: parent_category.id
|
|
|
|
)
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(0)
|
|
|
|
|
|
|
|
CategoryUser.create!(
|
|
|
|
user_id: user.id,
|
|
|
|
notification_level: CategoryUser.notification_levels[:regular],
|
|
|
|
category_id: sub_category.id
|
|
|
|
)
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
end
|
|
|
|
|
2020-01-06 12:22:42 -06:00
|
|
|
it "works when categories are default muted" do
|
|
|
|
SiteSetting.mute_all_categories_by_default = true
|
|
|
|
|
|
|
|
post
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(0)
|
|
|
|
|
|
|
|
CategoryUser.create!(user_id: user.id,
|
|
|
|
notification_level: CategoryUser.notification_levels[:regular],
|
|
|
|
category_id: post.topic.category_id
|
|
|
|
)
|
|
|
|
|
|
|
|
create_post(topic_id: post.topic_id)
|
|
|
|
|
2016-12-02 00:03:31 -06:00
|
|
|
report = TopicTrackingState.report(user)
|
2015-07-21 06:53:54 -05:00
|
|
|
expect(report.length).to eq(1)
|
2015-04-16 23:03:08 -05:00
|
|
|
end
|
|
|
|
|
2022-07-27 11:14:14 -05:00
|
|
|
describe 'muted tags' do
|
2019-12-09 16:50:05 -06:00
|
|
|
it "remove_muted_tags_from_latest is set to always" do
|
|
|
|
SiteSetting.remove_muted_tags_from_latest = 'always'
|
|
|
|
tag1 = Fabricate(:tag)
|
|
|
|
tag2 = Fabricate(:tag)
|
|
|
|
Fabricate(:topic_tag, tag: tag1, topic: topic)
|
|
|
|
Fabricate(:topic_tag, tag: tag2, topic: topic)
|
|
|
|
post
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
|
|
|
|
TagUser.create!(user_id: user.id,
|
|
|
|
notification_level: TagUser.notification_levels[:muted],
|
|
|
|
tag_id: tag1.id
|
|
|
|
)
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(0)
|
2020-05-28 21:59:34 -05:00
|
|
|
|
|
|
|
TopicTag.where(topic_id: topic.id).delete_all
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
2019-12-09 16:50:05 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
it "remove_muted_tags_from_latest is set to only_muted" do
|
|
|
|
SiteSetting.remove_muted_tags_from_latest = 'only_muted'
|
|
|
|
tag1 = Fabricate(:tag)
|
|
|
|
tag2 = Fabricate(:tag)
|
|
|
|
Fabricate(:topic_tag, tag: tag1, topic: topic)
|
|
|
|
Fabricate(:topic_tag, tag: tag2, topic: topic)
|
|
|
|
post
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
|
|
|
|
TagUser.create!(user_id: user.id,
|
|
|
|
notification_level: TagUser.notification_levels[:muted],
|
|
|
|
tag_id: tag1.id
|
|
|
|
)
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
|
|
|
|
TagUser.create!(user_id: user.id,
|
|
|
|
notification_level: TagUser.notification_levels[:muted],
|
|
|
|
tag_id: tag2.id
|
|
|
|
)
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(0)
|
2020-05-28 21:59:34 -05:00
|
|
|
|
|
|
|
TopicTag.where(topic_id: topic.id).delete_all
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
2019-12-09 16:50:05 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
it "remove_muted_tags_from_latest is set to never" do
|
|
|
|
SiteSetting.remove_muted_tags_from_latest = 'never'
|
|
|
|
tag1 = Fabricate(:tag)
|
|
|
|
Fabricate(:topic_tag, tag: tag1, topic: topic)
|
|
|
|
post
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
|
|
|
|
TagUser.create!(user_id: user.id,
|
|
|
|
notification_level: TagUser.notification_levels[:muted],
|
|
|
|
tag_id: tag1.id
|
|
|
|
)
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-03 18:27:34 -06:00
|
|
|
it "correctly handles dismissed topics" do
|
2020-03-10 16:13:17 -05:00
|
|
|
freeze_time 1.minute.ago
|
2021-12-22 11:09:43 -06:00
|
|
|
user.update!(created_at: Time.now)
|
2019-11-13 23:11:34 -06:00
|
|
|
post
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
|
2021-02-03 18:27:34 -06:00
|
|
|
DismissedTopicUser.create!(user_id: user.id, topic_id: post.topic_id, created_at: Time.zone.now)
|
2019-11-13 23:11:34 -06:00
|
|
|
CategoryUser.create!(user_id: user.id,
|
|
|
|
notification_level: CategoryUser.notification_levels[:regular],
|
|
|
|
category_id: post.topic.category_id,
|
|
|
|
last_seen_at: post.topic.created_at
|
|
|
|
)
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(0)
|
|
|
|
end
|
|
|
|
|
2015-09-06 20:57:50 -05:00
|
|
|
it "correctly handles capping" do
|
|
|
|
post1 = create_post
|
|
|
|
Fabricate(:post, topic: post1.topic)
|
|
|
|
|
|
|
|
post2 = create_post
|
|
|
|
Fabricate(:post, topic: post2.topic)
|
|
|
|
|
|
|
|
post3 = create_post
|
|
|
|
Fabricate(:post, topic: post3.topic)
|
|
|
|
|
|
|
|
tracking = {
|
|
|
|
notification_level: TopicUser.notification_levels[:tracking],
|
|
|
|
last_read_post_number: 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
TopicUser.change(user.id, post1.topic_id, tracking)
|
|
|
|
TopicUser.change(user.id, post2.topic_id, tracking)
|
|
|
|
TopicUser.change(user.id, post3.topic_id, tracking)
|
|
|
|
|
2016-12-02 00:03:31 -06:00
|
|
|
report = TopicTrackingState.report(user)
|
2015-09-06 20:57:50 -05:00
|
|
|
expect(report.length).to eq(3)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2022-07-27 11:14:14 -05:00
|
|
|
describe "tag support" do
|
2022-06-13 01:54:01 -05:00
|
|
|
before do
|
2020-05-28 21:57:46 -05:00
|
|
|
SiteSetting.tagging_enabled = true
|
|
|
|
|
|
|
|
post.topic.notifier.watch_topic!(post.topic.user_id)
|
|
|
|
|
|
|
|
DiscourseTagging.tag_topic_by_names(
|
|
|
|
post.topic,
|
|
|
|
Guardian.new(Discourse.system_user),
|
|
|
|
['bananas', 'apples']
|
|
|
|
)
|
2022-06-13 01:54:01 -05:00
|
|
|
end
|
2020-05-28 21:57:46 -05:00
|
|
|
|
2022-12-07 19:44:29 -06:00
|
|
|
it "includes tags when SiteSetting.navigation_menu is not legacy" do
|
2022-06-13 01:54:01 -05:00
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
row = report[0]
|
|
|
|
expect(row.respond_to?(:tags)).to eq(false)
|
|
|
|
|
2022-12-07 19:44:29 -06:00
|
|
|
SiteSetting.navigation_menu = "sidebar"
|
2020-05-28 21:57:46 -05:00
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
row = report[0]
|
|
|
|
expect(row.tags).to contain_exactly("apples", "bananas")
|
2022-06-13 01:54:01 -05:00
|
|
|
end
|
2020-05-28 21:57:46 -05:00
|
|
|
|
2022-06-13 01:54:01 -05:00
|
|
|
it "includes tags when TopicTrackingState.include_tags_in_report option is enabled" do
|
2020-05-28 21:57:46 -05:00
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
row = report[0]
|
|
|
|
expect(row.respond_to? :tags).to eq(false)
|
2022-06-13 01:54:01 -05:00
|
|
|
|
|
|
|
TopicTrackingState.include_tags_in_report = true
|
|
|
|
|
|
|
|
report = TopicTrackingState.report(user)
|
|
|
|
expect(report.length).to eq(1)
|
|
|
|
row = report[0]
|
|
|
|
expect(row.tags).to contain_exactly("apples", "bananas")
|
|
|
|
ensure
|
|
|
|
TopicTrackingState.include_tags_in_report = false
|
2020-05-28 21:57:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-05-23 00:21:07 -05:00
|
|
|
it "correctly gets the tracking state" do
|
2016-12-02 00:03:31 -06:00
|
|
|
report = TopicTrackingState.report(user)
|
2014-12-31 08:55:03 -06:00
|
|
|
expect(report.length).to eq(0)
|
2013-05-21 01:39:51 -05:00
|
|
|
|
2013-07-21 20:40:39 -05:00
|
|
|
post.topic.notifier.watch_topic!(post.topic.user_id)
|
2013-05-21 01:39:51 -05:00
|
|
|
|
2016-12-02 00:03:31 -06:00
|
|
|
report = TopicTrackingState.report(user)
|
2013-05-23 00:21:07 -05:00
|
|
|
|
2014-12-31 08:55:03 -06:00
|
|
|
expect(report.length).to eq(1)
|
2013-05-23 00:21:07 -05:00
|
|
|
row = report[0]
|
|
|
|
|
2014-12-31 08:55:03 -06:00
|
|
|
expect(row.topic_id).to eq(post.topic_id)
|
|
|
|
expect(row.highest_post_number).to eq(1)
|
|
|
|
expect(row.last_read_post_number).to eq(nil)
|
|
|
|
expect(row.user_id).to eq(user.id)
|
2013-05-23 00:21:07 -05:00
|
|
|
|
|
|
|
# lets not leak out random users
|
2016-12-02 00:03:31 -06:00
|
|
|
expect(TopicTrackingState.report(post.user)).to be_empty
|
2013-05-23 00:21:07 -05:00
|
|
|
|
|
|
|
# lets not return anything if we scope on non-existing topic
|
2016-12-02 00:03:31 -06:00
|
|
|
expect(TopicTrackingState.report(user, post.topic_id + 1)).to be_empty
|
2013-05-23 00:21:07 -05:00
|
|
|
|
|
|
|
# when we reply the poster should have an unread row
|
2013-07-22 00:06:53 -05:00
|
|
|
create_post(user: user, topic: post.topic)
|
2013-05-21 01:39:51 -05:00
|
|
|
|
2016-12-02 00:03:31 -06:00
|
|
|
report = TopicTrackingState.report(user)
|
2015-07-21 06:48:07 -05:00
|
|
|
expect(report.length).to eq(0)
|
|
|
|
|
2016-12-02 00:03:31 -06:00
|
|
|
report = TopicTrackingState.report(post.user)
|
2014-12-31 08:55:03 -06:00
|
|
|
expect(report.length).to eq(1)
|
2013-05-21 01:39:51 -05:00
|
|
|
|
2013-05-23 00:21:07 -05:00
|
|
|
row = report[0]
|
2013-05-21 01:39:51 -05:00
|
|
|
|
2014-12-31 08:55:03 -06:00
|
|
|
expect(row.topic_id).to eq(post.topic_id)
|
|
|
|
expect(row.highest_post_number).to eq(2)
|
|
|
|
expect(row.last_read_post_number).to eq(1)
|
|
|
|
expect(row.user_id).to eq(post.user_id)
|
2013-05-21 01:39:51 -05:00
|
|
|
|
2013-05-23 22:32:41 -05:00
|
|
|
# when we have no permission to see a category, don't show its stats
|
2013-07-13 20:24:16 -05:00
|
|
|
category = Fabricate(:category, read_restricted: true)
|
2013-05-23 22:32:41 -05:00
|
|
|
|
|
|
|
post.topic.category_id = category.id
|
|
|
|
post.topic.save
|
|
|
|
|
2016-12-02 00:03:31 -06:00
|
|
|
expect(TopicTrackingState.report(post.user)).to be_empty
|
|
|
|
expect(TopicTrackingState.report(user)).to be_empty
|
2013-05-21 01:39:51 -05:00
|
|
|
end
|
2021-08-11 21:31:50 -05:00
|
|
|
|
|
|
|
describe ".report" do
|
|
|
|
it "correctly reports topics with staff posts" do
|
2022-06-29 19:18:12 -05:00
|
|
|
SiteSetting.enable_whispers = true
|
2021-08-11 21:31:50 -05:00
|
|
|
create_post(
|
|
|
|
raw: "this is a test post",
|
|
|
|
topic: topic,
|
|
|
|
user: post.user
|
|
|
|
)
|
|
|
|
|
|
|
|
create_post(
|
|
|
|
raw: "this is a test post",
|
|
|
|
topic: topic,
|
|
|
|
post_type: Post.types[:whisper],
|
|
|
|
user: user
|
|
|
|
)
|
|
|
|
|
|
|
|
post.user.grant_admin!
|
|
|
|
|
|
|
|
state = TopicTrackingState.report(post.user)
|
|
|
|
|
|
|
|
expect(state.map(&:topic_id)).to contain_exactly(topic.id)
|
|
|
|
end
|
|
|
|
end
|
2013-05-21 01:39:51 -05:00
|
|
|
end
|