Sha256: 3ec21fb1589187384b0374113c692c4a468b01b6d63d2c1dbab503c0610d7f05

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 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 'when using default options' do
      setup do
        @blog = Blog.new
        @blog.expects(:do_something_else)
        @blog.save
      end
      should 'execute callbacks' do end # see expectations
    end
    context 'when callback has :backgrounded options' do
      setup do
        Backgrounded.handler.expects(:options=).with(:priority => :high)
        @user = User.new
        @user.save
      end
      should 'pass configure Backgrounded.handler.options' do end # see expectations
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
backgrounded-2.0.0 test/active_record_extension_test.rb
backgrounded-2.0.0.rc2 test/active_record_extension_test.rb
backgrounded-2.0.0.rc1 test/active_record_extension_test.rb