Flaky Spec Fix:(Attempt)Ensure Article Suggester Count is Consistent (#10146)
This commit is contained in:
parent
5657067e55
commit
b60c6c687c
1 changed files with 8 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ RSpec.describe ArticleSuggester, type: :labor do
|
|||
it "returns proper number of articles with post with the same tags" do
|
||||
create_list(:article, 4, featured: true, tags: ["discuss"], score: 10)
|
||||
article = create(:article, featured: true, tags: ["discuss"])
|
||||
stub_estimated_article_count
|
||||
expect(described_class.new(article).articles.size).to eq(4)
|
||||
end
|
||||
|
||||
|
|
@ -11,17 +12,24 @@ RSpec.describe ArticleSuggester, type: :labor do
|
|||
create_list(:article, 2, featured: true, tags: ["discuss"], score: 10)
|
||||
create_list(:article, 2, featured: true, tags: ["javascript"])
|
||||
article = create(:article, featured: true, tags: ["discuss"])
|
||||
stub_estimated_article_count
|
||||
expect(described_class.new(article).articles.size).to eq(4)
|
||||
end
|
||||
|
||||
it "returns proper number of articles with post without tags" do
|
||||
create_list(:article, 5, tags: [], with_tags: false, featured: true)
|
||||
article = create(:article, featured: true, tag_list: "")
|
||||
stub_estimated_article_count
|
||||
expect(described_class.new(article).articles.size).to eq(4)
|
||||
end
|
||||
|
||||
it "returns the number of articles requested" do
|
||||
articles = create_list(:article, 3, featured: true)
|
||||
stub_estimated_article_count
|
||||
expect(described_class.new(articles.first).articles(max: 2).size).to eq(2)
|
||||
end
|
||||
|
||||
def stub_estimated_article_count
|
||||
allow(described_class).to receive(:articles_count).and_return(Article.published.count)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue