Merge pull request #2751 from consul/home-recommendations

Deal gracefully with recommendations of hidden proposals
This commit is contained in:
Alberto
2018-07-10 18:44:13 +02:00
committed by GitHub
2 changed files with 11 additions and 1 deletions

View File

@@ -328,7 +328,8 @@ class User < ActiveRecord::Base
end end
def interests def interests
follows.map{|follow| follow.followable.tags.map(&:name)}.flatten.compact.uniq followables = follows.map(&:followable)
followables.compact.map { |followable| followable.tags.map(&:name) }.flatten.compact.uniq
end end
private private

View File

@@ -667,6 +667,15 @@ describe User do
expect(user.interests).to eq ["Sport"] expect(user.interests).to eq ["Sport"]
end end
it "deals gracefully with hidden proposals" do
proposal = create(:proposal, tag_list: "Sport")
create(:follow, followable: proposal, user: user)
proposal.hide
expect(user.interests).to eq []
end
it "discards followed objects duplicated tags" do it "discards followed objects duplicated tags" do
proposal1 = create(:proposal, tag_list: "Sport") proposal1 = create(:proposal, tag_list: "Sport")
proposal2 = create(:proposal, tag_list: "Sport") proposal2 = create(:proposal, tag_list: "Sport")