aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/helper.rb
blob: ca67700273d490bdf36560942890924c23fd9dfe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require File.expand_path('../../../load_paths', __FILE__)

require 'active_job'

GlobalID.app = 'aj'

@adapter  = ENV['AJADAPTER'] || 'inline'

def sidekiq?
  @adapter == 'sidekiq'
end

def rubinius?
  RUBY_ENGINE == 'rbx'
end

def ruby_193?
  RUBY_VERSION == '1.9.3' && RUBY_ENGINE != 'java'
end

#Sidekiq don't work with MRI 1.9.3
#Travis uses rbx 2.6 which don't support unicode characters in methods.
#Remove the check when Travis change to rbx 2.7+
exit  if sidekiq?  && (ruby_193? || rubinius?)

require "adapters/#{@adapter}"

require 'active_support/testing/autorun'

ActiveJob::Base.logger.level = Logger::DEBUG

module JobBuffer
  class << self
    def clear
      @buffer = []
    end

    def add(value)
      @buffer << value
    end

    def values
      @buffer
    end

    def last_value
      @buffer.last
    end
  end
end