Sha256: 0cd8bde2c99ed71a24807fc44b4b2b3fa24b9cb1a6b554892e1db7173c652007

Contents?: true

Size: 1.28 KB

Versions: 27

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

27 entries across 27 versions & 1 rubygems

Version Path
rocketjob-3.4.3 test/plugins/job/defaults_test.rb
rocketjob-3.4.2 test/plugins/job/defaults_test.rb
rocketjob-3.4.1 test/plugins/job/defaults_test.rb
rocketjob-3.4.0 test/plugins/job/defaults_test.rb
rocketjob-3.3.4 test/plugins/job/defaults_test.rb
rocketjob-3.3.3 test/plugins/job/defaults_test.rb
rocketjob-3.3.2 test/plugins/job/defaults_test.rb
rocketjob-3.3.1 test/plugins/job/defaults_test.rb
rocketjob-3.3.0 test/plugins/job/defaults_test.rb
rocketjob-3.2.1 test/plugins/job/defaults_test.rb
rocketjob-3.2.0 test/plugins/job/defaults_test.rb
rocketjob-3.1.0 test/plugins/job/defaults_test.rb
rocketjob-3.0.5 test/plugins/job/defaults_test.rb
rocketjob-3.0.4 test/plugins/job/defaults_test.rb
rocketjob-3.0.3 test/plugins/job/defaults_test.rb
rocketjob-3.0.2 test/plugins/job/defaults_test.rb
rocketjob-3.0.1 test/plugins/job/defaults_test.rb
rocketjob-3.0.0 test/plugins/job/defaults_test.rb
rocketjob-3.0.0.rc5 test/plugins/job/defaults_test.rb
rocketjob-3.0.0.rc4 test/plugins/job/defaults_test.rb