* Change from #after_save to #after_create * Update .babelrc * Update cloud_name for test * Update SlackBot's RssReader channel * Update helpful-hints.md * Create .gitdocs.json * Remove serve-docs script * Update docs/helpful-hints.md * Update approval * Revert "Change from #after_save to #after_create" This reverts commit 548ee0d2c0d56a1aa67316468f4106ac9f437662. * Create delayed_job.rb * Bump ancestry gem to 3.0.3 * Fix broken spec * Remove manual Delayed::Job config in test * Update spec_helper.rb * Fix broken specs * Mute SlackBot in test * Remove weekly-dgiest.yml * Create PodcastEpisodeDecorator
32 lines
1 KiB
Ruby
32 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)
|
|
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
|