Sha256: e2f03290f1a423aa216e7e2c665b7aa7097c3839d75dbf42a70400381c9b19d8

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

class ActiveRecordExtensionTest < Test::Unit::TestCase

  class Blog < ActiveRecord::Base
    after_commit_backgrounded :do_something_else
    def do_something_else
    end
  end
  class User < ActiveRecord::Base
    after_commit_backgrounded :do_stuff, :backgrounded => {:priority => :high}
    def do_stuff
    end
  end

  context '.after_commit_backgrounded' do
    should 'be defined on ActiveRecord::Base' do
      assert ActiveRecord::Base.respond_to?(:after_commit_backgrounded)
    end
    context 'without options' do
      setup do
        @blog = Blog.new
        Backgrounded.handler.expects(:request).with(@blog, :do_something_else, [], {})
        @blog.save!
      end
      should 'invoke Backgrounded.handler with no options' do end # see expectations
    end
    context 'with options[:backgrounded]' do
      setup do
        @user = User.new
        Backgrounded.handler.expects(:request).with(@user, :do_stuff, [], {:priority => :high})
        @user.save!
      end
      should 'pass options[:backgrounded] to Backgrounded.handler' do end # see expectations
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
backgrounded-2.1.0 test/active_record_extension_test.rb