Merge pull request #5226 from tgxworld/allow_user_to_disable_private_messages

FEATURE: Allow users to disable new PMs.
This commit is contained in:
Guo Xiang Tan
2017-10-19 16:46:18 +08:00
committed by GitHub
23 changed files with 233 additions and 34 deletions

View File

@ -6,6 +6,7 @@ require_dependency 'post_destroyer'
describe Topic do
let(:now) { Time.zone.local(2013, 11, 20, 8, 0) }
let(:user) { Fabricate(:user) }
let(:topic) { Fabricate(:topic) }
context 'validations' do
let(:topic) { Fabricate.build(:topic) }
@ -2061,4 +2062,23 @@ describe Topic do
end
end
end
describe '#remove_allowed_user' do
let(:another_user) { Fabricate(:user) }
describe 'removing oneself' do
it 'should remove onself' do
topic.allowed_users << another_user
expect(topic.remove_allowed_user(another_user, another_user)).to eq(true)
expect(topic.allowed_users.include?(another_user)).to eq(false)
post = Post.last
expect(post.user).to eq(Discourse.system_user)
expect(post.post_type).to eq(Post.types[:small_action])
expect(post.action_code).to eq('user_left')
end
end
end
end