FIX: Do not suggest similar topics from secure categories you can't see.

This commit is contained in:
Robin Ward
2013-06-12 13:43:59 -04:00
parent 2c68dd1c12
commit 77b218a142
4 changed files with 40 additions and 7 deletions

View File

@ -175,6 +175,26 @@ describe Topic do
Topic.similar_to("has evil trout made any topics?", "i am wondering has evil trout made any topics?").should == [topic]
end
context "secure categories" do
let(:user) { Fabricate(:user) }
let(:category) { Fabricate(:category, secure: true) }
before do
topic.category = category
topic.save
end
it "doesn't return topics from private categories" do
expect(Topic.similar_to("has evil trout made any topics?", "i am wondering has evil trout made any topics?", user)).to be_blank
end
it "should return the cat since the user can see it" do
Guardian.any_instance.expects(:secure_category_ids).returns([category.id])
expect(Topic.similar_to("has evil trout made any topics?", "i am wondering has evil trout made any topics?", user)).to include(topic)
end
end
end
end