Merge pull request #2751 from consul/home-recommendations
Deal gracefully with recommendations of hidden proposals
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
Reference in New Issue
Block a user