Sha256: 95003309463af6e8211b3a67831d40a2441203df10625dd57a6cb3ff2731eda2

Contents?: true

Size: 1.17 KB

Versions: 20

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'
require 'rollbar/plugins/delayed_job/job_data'
require 'delayed/backend/test'

# In delayed_job/lib/delayed/syck_ext.rb YAML.load_dj
# is broken cause it's defined as an instance method
# instead of module/class method. This is breaking
# the tests for ruby 1.8.7
if YAML.parser.class.name =~ /syck|yecht/i
  module YAML
    def self.load_dj(yaml)
      # See https://github.com/dtao/safe_yaml
      # When the method is there, we need to load our YAML like this...
      respond_to?(:unsafe_load) ? load(yaml, :safe => false) : load(yaml)
    end
  end
end

describe Rollbar::Delayed::JobData do
  describe '#to_hash' do
    let(:handler) { { 'foo' => 'bar' } }

    let(:attrs) do
      {
        'id' => 1,
        'priority' => 0,
        'attempts' => 1,
        'handler' => handler.to_yaml
      }
    end

    let(:job) do
      ::Delayed::Backend::Test::Job.new(attrs)
    end

    subject { described_class.new(job) }

    it 'returns the correct job data' do
      expected_result = attrs.dup
      expected_result.delete('id')
      expected_result['handler'] = handler

      result = subject.to_hash

      expect(result).to be_eql(expected_result)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rollbar-2.18.2 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.18.0 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.17.0 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.16.4 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.16.3 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.16.2 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.16.0 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.15.6 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.15.5 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.15.4 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.15.3 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.15.2 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.15.1 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.15.0 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.14.1 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.14.0 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.13.3 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.13.2 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.13.1 spec/rollbar/plugins/delayed_job/job_data_spec.rb
rollbar-2.13.0 spec/rollbar/plugins/delayed_job/job_data_spec.rb