* Rubocop enabled style/alias * Enabled Style/ArrayJoin Cop * Enabled Style/Attr * Enabled Case Equality * Enabled CharacterLiteral * Enabled ColonMethodCall Cop * Enabled CommentAnnotation cop * Enabled PreferredHashMethods Cop * Enabled DoubleNegation Cop * Enabled EachWithObject Cop * Enabled EmptyLiteral Cop * Enabled EvenOdd Cop * Enabled IfWithSemicolon Cop * Enabled Lambda and LambdaCall Cop * Enabled LineEndConcatenation Cop * Enabled ModuleFunction Cop; * Enable NegatedIf and NegatedWhile Cop * Enabled NilComparison Cop * Enabled Not Cop * Enabled NumericLiterals Cop * Enabled OneLineConditional Cop * Enabled PercentLiteralDelimiters Cop * Excluded internal/users_controller from negated_if cop * Reverted the double negation change from github_issue_tag and github_issue.rb" * Enabled PerlBackrefs Cop * Changed Regexp.last_match(1) to Regexp.last_match(0) * Enabled proc cop * Enabled RaiseArgs Cop * Reverted Regexp.last_match(0) to Regexp.last_match(1) * Enabled SelfAssignment Cop * Enabled SingleLineMethods Cop * Enabled SpecialGlobalVars Cop * Enabled VariableInterpolation Cop * Enabled WhenThen Cop * Enabled WhileUntilModifier Cop * Enabled WordArray Cop * Enabled IfUnlessModifier Cop * Enabled GuardClause Cop
34 lines
1 KiB
Ruby
34 lines
1 KiB
Ruby
require "rails_helper"
|
|
|
|
class FakeDelegator < ActionMailer::MessageDelivery
|
|
# TODO: we should replace all usage of .deliver to .deliver_now
|
|
def deliver(*args)
|
|
super
|
|
end
|
|
end
|
|
|
|
RSpec.describe EmailDigest do
|
|
let(:user) { create(:user, email_digest_periodic: true) }
|
|
let(:author) { create(:user) }
|
|
let(:mock_delegator) { instance_double("FakeDelegator") }
|
|
|
|
before do
|
|
allow(DigestMailer).to receive(:digest_email) { mock_delegator }
|
|
allow(mock_delegator).to receive(:deliver).and_return(true)
|
|
user
|
|
end
|
|
|
|
describe "::send_digest_email" do
|
|
context "when there's article to be sent" do
|
|
before { user.follow(author) }
|
|
|
|
it "send digest email when there's atleast 3 hot articles" do
|
|
create_list(:article, 3, user_id: author.id, positive_reactions_count: 20, score: 20)
|
|
described_class.send_periodic_digest_email
|
|
expect(DigestMailer).to have_received(:digest_email).with(
|
|
user, [instance_of(Article), instance_of(Article), instance_of(Article)]
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|