docbrown/spec/lib/black_box_spec.rb
Monica Mateiu 6818ef3ed0
Remove references to article.spaminess_rating (#17235)
* Remove references to article.spaminess

* Update app/models/article.rb

* Update spec/workers/comments/calculate_score_worker_spec.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* remove unnecessary BlackBox spec

* Update spec/workers/comments/calculate_score_worker_spec.rb

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>

* Remove references to calculate_spaminess

* Update app/workers/comments/calculate_score_worker.rb

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
Co-authored-by: Jamie Gaskins <jamie@forem.com>
2022-04-15 11:43:48 -04:00

31 lines
1.3 KiB
Ruby

require "rails_helper"
RSpec.describe BlackBox, type: :lib do
describe "#article_hotness_score" do
it "returns higher value for higher score" do
article = build_stubbed(:article, score: 99, published_at: Time.current)
lower_article = build_stubbed(:article, score: 70, published_at: Time.current)
score = described_class.article_hotness_score(article)
lower_score = described_class.article_hotness_score(lower_article)
expect(score).to be > lower_score
end
it "returns higher value for more recent article" do
article = build_stubbed(:article, score: 99, published_at: Time.current)
lower_article = build_stubbed(:article, score: 70, published_at: 5.days.ago)
score = described_class.article_hotness_score(article)
lower_score = described_class.article_hotness_score(lower_article)
expect(score).to be > lower_score
end
end
describe "#comment_quality_score" do
it "returns the correct score" do
comment = build_stubbed(:comment, body_markdown: "```#{'hello, world! ' * 20}```")
reactions = double
allow(comment).to receive(:reactions).and_return(reactions)
allow(reactions).to receive(:sum).with(:points).and_return(22)
expect(described_class.comment_quality_score(comment)).to eq(25)
end
end
end