Sha256: 6a6897bf6d1c62d48f132b477d76a5b70eac4475a6ee51c3d9413f2aff943df2

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true
require "spec_helper"

module Decidim
  module Admin
    describe NewsletterDeliveryJob do
      let(:user) { create(:user) }
      let(:organization) { create(:organization) }
      let(:newsletter) { create(:newsletter, organization: organization, total_deliveries: 0) }

      it "delivers a newsletter to a single user" do
        NewsletterDeliveryJob.perform_now(user, newsletter)

        expect(last_email.subject).to include(newsletter.subject[I18n.locale.to_s])
        expect(last_email.to).to include(user.email)
      end

      it "increments the delivery count" do
        expect do
          NewsletterDeliveryJob.perform_now(user, newsletter)
        end.to change { newsletter.reload.total_deliveries }.by(1)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-0.1.0 decidim-admin/spec/jobs/newsletter_delivery_job_spec.rb