FEATURE: first class group mentions built in

If you allow a group to be mentioned it can be mentioned with the @ symbol.

Keep in mind as a safety mechanism max_users_notified_per_group_mention is set to 100
This commit is contained in:
Sam
2015-11-30 17:03:47 +11:00
parent 5a7831265a
commit ad3dd161e7
25 changed files with 210 additions and 94 deletions

View File

@@ -12,7 +12,7 @@ describe PostAlerter do
context "unread" do
it "does not return whispers as unread posts" do
op = Fabricate(:post)
whisper = Fabricate(:post, raw: 'this is a whisper post',
_whisper = Fabricate(:post, raw: 'this is a whisper post',
user: Fabricate(:admin),
topic: op.topic,
reply_to_post_number: op.post_number,
@@ -92,6 +92,26 @@ describe PostAlerter do
end
end
context '@group mentions' do
it 'notifies users correctly' do
group = Fabricate(:group, name: 'group', alias_level: Group::ALIAS_LEVELS[:everyone])
group.add(evil_trout)
expect {
create_post_with_alerts(raw: "Hello @group how are you?")
}.to change(evil_trout.notifications, :count).by(1)
group.update_columns(alias_level: Group::ALIAS_LEVELS[:members_mods_and_admins])
expect {
create_post_with_alerts(raw: "Hello @group you are not mentionable")
}.to change(evil_trout.notifications, :count).by(0)
end
end
context '@mentions' do
let(:user) { Fabricate(:user) }