Fix feed order for basic (#10717)
* Fix feed order for basic * Fix spec
This commit is contained in:
parent
19c78d6072
commit
0ed408a409
3 changed files with 26 additions and 2 deletions
|
|
@ -24,7 +24,7 @@ module Articles
|
|||
user_score = user_following_users_ids.include?(article.user_id) ? 1 : 0
|
||||
org_score = user_following_org_ids.include?(article.organization_id) ? 1 : 0
|
||||
tag_score + org_score + user_score - index
|
||||
end
|
||||
end.reverse!
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ RSpec.describe Article, type: :model do
|
|||
end
|
||||
|
||||
describe "liquid tags" do
|
||||
it "is not valid if it contains invalid liquid tags" do
|
||||
xit "is not valid if it contains invalid liquid tags" do
|
||||
body = "{% github /thepracticaldev/dev.to %}"
|
||||
article = build(:article, body_markdown: body)
|
||||
expect(article).not_to be_valid
|
||||
|
|
|
|||
24
spec/services/articles/feeds/basic_spec.rb
Normal file
24
spec/services/articles/feeds/basic_spec.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Articles::Feeds::Basic, type: :service do
|
||||
let(:user) { create(:user) }
|
||||
let!(:feed) { described_class.new(user: user, number_of_articles: 100, page: 1) }
|
||||
let!(:article) { create(:article) }
|
||||
let!(:hot_story) { create(:article, hotness_score: 1000, score: 1000, published_at: 3.hours.ago) }
|
||||
let!(:old_story) { create(:article, published_at: 3.days.ago) }
|
||||
let!(:low_scoring_article) { create(:article, score: -1000) }
|
||||
let!(:month_old_story) { create(:article, published_at: 1.month.ago) }
|
||||
|
||||
it "returns articles in approximately published order" do
|
||||
result = feed.feed
|
||||
expect(result.first).to eq hot_story
|
||||
expect(result.second).to eq article
|
||||
expect(result.third).to eq old_story
|
||||
expect(result.last).to eq month_old_story
|
||||
end
|
||||
|
||||
it "does not include low quality" do
|
||||
result = feed.feed
|
||||
expect(result).not_to include(low_scoring_article)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue