FEATURE: First class messages to groups, you can select a group as a target of a message

This commit is contained in:
Sam
2015-12-02 15:49:43 +11:00
parent fbffe28772
commit 9899e8d4a5
11 changed files with 93 additions and 15 deletions

View File

@@ -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',