mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: First class messages to groups, you can select a group as a target of a message
This commit is contained in:
@@ -583,6 +583,40 @@ describe PostsController do
|
||||
expect(parsed['cooked']).to be_present
|
||||
end
|
||||
|
||||
it "can send a message to a group" do
|
||||
|
||||
group = Group.create(name: 'test_group', alias_level: Group::ALIAS_LEVELS[:nobody])
|
||||
user1 = Fabricate(:user)
|
||||
group.add(user1)
|
||||
|
||||
xhr :post, :create, {
|
||||
raw: 'I can haz a test',
|
||||
title: 'I loves my test',
|
||||
target_usernames: group.name,
|
||||
archetype: Archetype.private_message
|
||||
}
|
||||
|
||||
expect(response).not_to be_success
|
||||
|
||||
# allow pm to this group
|
||||
group.update_columns(alias_level: Group::ALIAS_LEVELS[:everyone])
|
||||
|
||||
xhr :post, :create, {
|
||||
raw: 'I can haz a test',
|
||||
title: 'I loves my test',
|
||||
target_usernames: group.name,
|
||||
archetype: Archetype.private_message
|
||||
}
|
||||
|
||||
expect(response).to be_success
|
||||
|
||||
parsed = ::JSON.parse(response.body)
|
||||
post = Post.find(parsed['id'])
|
||||
|
||||
expect(post.topic.topic_allowed_users.length).to eq(1)
|
||||
expect(post.topic.topic_allowed_groups.length).to eq(1)
|
||||
end
|
||||
|
||||
it "returns the nested post with a param" do
|
||||
xhr :post, :create, {raw: 'this is the test content',
|
||||
title: 'this is the test title for the topic',
|
||||
|
||||
Reference in New Issue
Block a user