Sha256: a1e40b234f05a7a91f2b12bc8413fd876e4a0e55484b6211ac4d6d9cd7c8c4b7

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

require_relative '../../test_helper'

module Plugins
  module Job
    # Unit Test for RocketJob::Job
    class DefaultsTest < Minitest::Test

      class ParentJob < RocketJob::Job
        rocket_job do |job|
          job.priority    = 53
          job.description = 'Hello'
        end

        def perform
        end
      end

      class ChildJob < ParentJob
        rocket_job do |job|
          job.priority = 72
        end

        def perform
        end
      end

      describe RocketJob::Plugins::Job::Defaults do
        after do
          @job.destroy if @job && !@job.new_record?
        end

        describe '.rocket_job' do
          it 'sets defaults after initialize' do
            @job = ParentJob.new
            assert_equal 53, @job.priority
            assert_equal 'Hello', @job.description
          end

          it 'allows a child to override parent defaults' do
            @job = ChildJob.new
            assert_equal 72, @job.priority
          end

          it 'passes down parent defaults' do
            @job = ChildJob.new
            assert_equal 'Hello', @job.description
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rocketjob-2.1.3 test/plugins/job/defaults_test.rb
rocketjob-2.1.2 test/plugins/job/defaults_test.rb
rocketjob-2.1.1 test/plugins/job/defaults_test.rb
rocketjob-2.0.0 test/plugins/job/defaults_test.rb
rocketjob-2.0.0.rc3 test/plugins/job/defaults_test.rb
rocketjob-2.0.0.rc2 test/plugins/job/defaults_test.rb
rocketjob-2.0.0.rc1 test/plugins/job/defaults_test.rb