FEATURE: Notify user when mention can't see the reply they were mentioned in

FIX: Group Mention Notifications
This commit is contained in:
cpradio
2016-11-14 22:03:16 -05:00
parent 095767bdb4
commit 824c235760
7 changed files with 100 additions and 15 deletions

View File

@@ -1602,6 +1602,9 @@ describe UsersController do
let(:user) { Fabricate(:user) }
let(:group) { Fabricate(:group, name: "Discourse") }
let(:topic) { Fabricate(:topic) }
let(:allowed_user) { Fabricate(:user) }
let(:private_topic) { Fabricate(:private_message_topic, user: allowed_user) }
it "finds the user" do
xhr :get, :is_local_username, username: user.username
@@ -1632,6 +1635,38 @@ describe UsersController do
expect(json["valid"].size).to eq(0)
end
it "returns user who cannot see topic" do
Guardian.any_instance.expects(:can_see?).with(topic).returns(false)
xhr :get, :is_local_username, usernames: [user.username], topic_id: topic.id
expect(response).to be_success
json = JSON.parse(response.body)
expect(json["cannot_see"].size).to eq(1)
end
it "never returns a user who can see the topic" do
Guardian.any_instance.expects(:can_see?).with(topic).returns(true)
xhr :get, :is_local_username, usernames: [user.username], topic_id: topic.id
expect(response).to be_success
json = JSON.parse(response.body)
expect(json["cannot_see"].size).to eq(0)
end
it "returns user who cannot see a private topic" do
Guardian.any_instance.expects(:can_see?).with(private_topic).returns(false)
xhr :get, :is_local_username, usernames: [user.username], topic_id: private_topic.id
expect(response).to be_success
json = JSON.parse(response.body)
expect(json["cannot_see"].size).to eq(1)
end
it "never returns a user who can see the topic" do
Guardian.any_instance.expects(:can_see?).with(private_topic).returns(true)
xhr :get, :is_local_username, usernames: [allowed_user.username], topic_id: private_topic.id
expect(response).to be_success
json = JSON.parse(response.body)
expect(json["cannot_see"].size).to eq(0)
end
end
describe '.topic_tracking_state' do