[deploy] Refactor:Remove unused ReadingList Labor methods (#10292)

This commit is contained in:
Molly Struve 2020-09-13 13:45:14 -05:00 committed by GitHub
parent fcc02ff913
commit 0cdbf46828
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 30 deletions

View file

@ -5,14 +5,6 @@ class ReadingList
@user = user
end
def get
Article
.joins(:reactions)
.includes(:user)
.where(reactions: reaction_criteria)
.order("reactions.created_at" => :desc)
end
def cached_ids_of_articles
Rails.cache.fetch("reading_list_ids_of_articles_#{user.id}_#{user.public_reactions_count}") do
ids_of_articles
@ -23,10 +15,6 @@ class ReadingList
Reaction.where(reaction_criteria).where.not(status: "archived").order(created_at: :desc).pluck(:reactable_id)
end
def count
get.size
end
def reaction_criteria
{ user_id: user.id, reactable_type: "Article", category: "readinglist" }
end

View file

@ -15,28 +15,10 @@ RSpec.describe ReadingList, type: :labor do
)
end
it "returns count of articles if they've been reacted to" do
create_reaction(user, article)
create_reaction(user, article2)
expect(described_class.new(user).count).to eq(2)
end
it "returns an article if it's been reacted to" do
create_reaction(user, article)
create_reaction(user, article2)
expect(described_class.new(user).get.first.id).to eq(article2.id)
end
it "returns cached ids of articles that have been reacted to" do
create_reaction(user, article)
create_reaction(user, article2)
expect(described_class.new(user).cached_ids_of_articles).to eq([article2.id, article.id])
end
it "returns an empty count if no reacted article" do
expect(described_class.new(user).count).to eq(0)
end
end