Sha256: 0f88324ad597978637fb3eab4fd19b2e5dc490d4d76a52cdc404b78cc049b2bd

Contents?: true

Size: 1.04 KB

Versions: 9

Compression:

Stored size: 1.04 KB

Contents

require 'test_helper'
require 'mocha'
require 'mocha/mini_test'

module Dripper
  class RunTwiceTest < ActiveSupport::TestCase

    def setup
      Dripper.config model: :users do
        dripper mailer: :user_mailer do
          dripper action: :welcome
          dripper action: :newsletter, scope: -> {has_username}
        end
      end

      # create the mailer
      User.create!(email: "foo@bar.com", username: "foo")
      User.create!(email: "foo2@bar.com")
      User.create!(email: "foo3@bar.com")
      # run it once
      Dripper.execute
    end


    def teardown
      Dripper.registry.clear
    end

    test "2nd Run" do

      # make sure it never runs again for the same users
      msg = mock()
      msg.stubs(:deliver_now)

      # expect that welcome was called 2x, newsletter called once
      UserMailer.stubs(:welcome)
        .with(instance_of(User))
        .returns(msg)
        .never

      UserMailer.stubs(:newsletter)
        .with(instance_of(User))
        .returns(msg)
        .never

      Dripper.execute

    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dripper_mail-0.0.22 test/models/dripper/run_twice_test.rb
dripper_mail-0.0.21 test/models/dripper/run_twice_test.rb
dripper_mail-0.0.20 test/models/dripper/run_twice_test.rb
dripper_mail-0.0.19 test/models/dripper/run_twice_test.rb
dripper_mail-0.0.18 test/models/dripper/run_twice_test.rb
dripper_mail-0.0.17 test/models/dripper/run_twice_test.rb
dripper_mail-0.0.16 test/models/dripper/run_twice_test.rb
dripper_mail-0.0.10 test/models/dripper/run_twice_test.rb
dripper_mail-0.0.8 test/models/dripper/run_twice_test.rb