# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause this
# file to always be loaded, without a need to explicitly require it in any files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, make a
# separate helper file that requires this one and then use it only in the specs
# that actually need it.
#
# The `.rspec` file also contains a few flags that are not defaults but that
# users commonly want.
#

require 'delayed_job_active_record'
require 'active_job'
require 'delayed_cron_job'

Delayed::Worker.destroy_failed_jobs = true
Delayed::Worker.logger = Logger.new('/tmp/dj.log')
ENV['RAILS_ENV'] = 'test'

Time.zone = EtOrbi.get_tzone(:local)

ActiveJob::Base.queue_adapter = :delayed_job

ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => 'file::memory:?cache=shared'
ActiveRecord::Base.logger = Delayed::Worker.logger
ActiveRecord::Migration.verbose = false

ActiveRecord::Schema.define do
  create_table :delayed_jobs, :force => true do |t|
    t.integer  :priority, :default => 0
    t.integer  :attempts, :default => 0
    t.text     :handler
    t.text     :last_error
    t.datetime :run_at
    t.datetime :locked_at
    t.datetime :failed_at
    t.string   :locked_by
    t.string   :queue
    t.string   :cron
    t.timestamps null: false
  end

  add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
end


# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|

end
