Sha256: 8cc1de8e6e20d4b16856dbae907a799080cc4665cacfa79392406d90156333d2

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class ThrottledJobTest < Test::Unit::TestCase

  context "Resque::ThrottledJob" do
    should "instantiate a new Resque::ThrottledJob" do
      assert Resque::ThrottledJob.new
    end

    context "settings (private methods)" do

      context "#can_run_every" do
        should "return the number of seconds in which to throttle these jobs" do
          assert_equal 3600, OneHourThrottledJob.can_run_every
        end

        should "default to 30 minutes (1800 seconds) if not provided" do
          assert_equal 1800, DefaultThrottledJob.can_run_every
        end
      end

      context "#identifier" do
        should "return an additional key identifier used in storing the key in the redis SET" do
          assert_equal "my_identifier", IdetifierThrottledJob.identifier
        end

        should "return nil if not defined" do
          assert_nil DefaultThrottledJob.identifier
        end
      end

      context "#disabled" do
        should "not be disabled by default" do
          assert !DefaultThrottledJob.disabled
        end

        should "be able to be overriden" do
          assert DisabledThrottledJob.disabled
        end
      end
    end

    context "#key" do
      should "consist of the class name and the identifier" do
        assert_equal "IdetifierThrottledJob:my_identifier", IdetifierThrottledJob.key
      end

      should "consist of just the class name if the identifier is not provided" do
        assert_equal "DefaultThrottledJob", DefaultThrottledJob.key
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
resque-throttle-0.2.6 test/resque/throttled_job_test.rb