Sha256: 8faa7c2e720aa0f46ad13c6fa333b3d599196a8fe5e1a5eb1cdd73e5303a0931

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

require_relative '../../test_helper'

module Plugins
  module Job
    # Unit Test for RocketJob::Job
    class DefaultsTest < Minitest::Test
      class ParentJob < RocketJob::Job
        self.priority    = 53
        self.description = 'Hello'

        def perform
        end
      end

      class ChildJob < ParentJob
        self.priority = 72

        def perform
        end
      end

      describe RocketJob::Plugins::Job 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 'can override defaults on initialize' do
            @job = ParentJob.new(priority: 72, description: 'More')
            assert_equal 72, @job.priority
            assert_equal 'More', @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

3 entries across 3 versions & 1 rubygems

Version Path
rocketjob-3.5.2 test/plugins/job/defaults_test.rb
rocketjob-3.5.1 test/plugins/job/defaults_test.rb
rocketjob-3.5.0 test/plugins/job/defaults_test.rb