Sha256: 449e748fc894a098ce3e3d97c091c090674064038012b64dbba57de37bdd2838

Contents?: true

Size: 1.3 KB

Versions: 13

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

require 'action_mailer'
class MyMailer < ActionMailer::Base
  def signup(email)
    mail :to => email, :subject => "Delaying Emails"
  end
end

describe ActionMailer::Base do
  describe "delay" do
    it "should enqueue a PerformableEmail job" do
      lambda {
        job = MyMailer.delay.signup('john@example.com')
        job.payload_object.class.should   == Delayed::PerformableMailer
        job.payload_object.method_name.should  == :signup
        job.payload_object.args.should    == ['john@example.com']
      }.should change { Delayed::Job.count }.by(1)
    end
  end

  describe "delay on a mail object" do
    it "should raise an exception" do
      lambda {
        MyMailer.signup('john@example.com').delay
      }.should raise_error(RuntimeError)
    end
  end

  describe Delayed::PerformableMailer do
    describe "perform" do
      before do
        @email = mock('email', :deliver => true)
        @mailer_class = mock('MailerClass', :signup => @email)
        @mailer = Delayed::PerformableMailer.new(@mailer_class, :signup, ['john@example.com'])
      end

      it "should call the method and #deliver on the mailer" do
        @mailer_class.should_receive(:signup).with('john@example.com')
        @email.should_receive(:deliver)
        @mailer.perform
      end
    end
  end

end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
delayed_job_unique_key-0.0.4 spec/performable_mailer_spec.rb
delayed_job_unique_key-0.0.3 spec/performable_mailer_spec.rb
delayed_job_unique_key-0.0.2 spec/performable_mailer_spec.rb
delayed_job_unique_key-0.0.1 spec/performable_mailer_spec.rb
delayed_job-3.0.0.pre4 spec/performable_mailer_spec.rb
delayed_job-3.0.0.pre3 spec/performable_mailer_spec.rb
delayed_job-3.0.0.pre2 spec/performable_mailer_spec.rb
delayed_job-3.0.0.pre spec/performable_mailer_spec.rb
delayed_job_hooked-2.1.5 spec/performable_mailer_spec.rb
delayed_job-2.1.4 spec/performable_mailer_spec.rb
delayed_job-2.1.3 spec/performable_mailer_spec.rb
delayed_job-2.1.2 spec/performable_mailer_spec.rb
delayed_job-2.1.1 spec/performable_mailer_spec.rb