fix: filter hidden stories in active tab (#1138)
This commit is contained in:
commit
be1824fa61
|
@ -26,6 +26,7 @@ class StoryRepository
|
|||
|
||||
def active
|
||||
Story.base(@user)
|
||||
.where.not(id: Story.hidden_by(@user).pluck(:id))
|
||||
.filter_tags(@params[:exclude_tags] || [])
|
||||
.select('stories.*, (
|
||||
select max(comments.id)
|
||||
|
|
|
@ -13,6 +13,19 @@ describe StoryRepository do
|
|||
|
||||
expect(repo.active).to eq([newer_comment.story, older_comment.story])
|
||||
end
|
||||
|
||||
it "does not show hidden stories" do
|
||||
hidden_story = create(:story)
|
||||
normal_story = create(:story)
|
||||
create(:comment, story: hidden_story)
|
||||
normal_comment = create(:comment, story: normal_story)
|
||||
|
||||
HiddenStory.hide_story_for_user(hidden_story.id, hidden_story.user_id)
|
||||
hidden_story_user = User.find_by(:id => hidden_story.user_id)
|
||||
|
||||
hidden_story_user_repo = StoryRepository.new(hidden_story_user)
|
||||
expect(hidden_story_user_repo.active).to eq([normal_comment.story])
|
||||
end
|
||||
end
|
||||
|
||||
describe ".newest_by_user" do
|
||||
|
|
Loading…
Reference in New Issue