Fix the build.

This commit is contained in:
Guo Xiang Tan 2017-10-11 17:45:19 +08:00
parent 36f8697a59
commit 9dcb11f553
4 changed files with 22 additions and 4 deletions

View File

@ -126,7 +126,7 @@ module Jobs
begin
exception = {}
RailsMultisite::ConnectionManagement.with_connection(db: db) do
RailsMultisite::ConnectionManagement.with_connection(db) do
begin
I18n.locale = SiteSetting.default_locale || "en"
I18n.ensure_all_loaded!

View File

@ -65,7 +65,7 @@ module Scheduler
db, job, desc = @queue.deq(non_block)
db ||= RailsMultisite::ConnectionManagement::DEFAULT
RailsMultisite::ConnectionManagement.with_connection(db: db) do
RailsMultisite::ConnectionManagement.with_connection(db) do
begin
job.call
rescue => ex

View File

@ -77,7 +77,7 @@ module Scheduler
@mutex.synchronize { info.write! }
if @manager.enable_stats
RailsMultisite::ConnectionManagement.with_connection(db: "default") do
RailsMultisite::ConnectionManagement.with_connection("default") do
stat = SchedulerStat.create!(
name: klass.to_s,
hostname: hostname,
@ -102,7 +102,7 @@ module Scheduler
info.prev_result = failed ? "FAILED" : "OK"
info.current_owner = nil
if stat
RailsMultisite::ConnectionManagement.with_connection(db: "default") do
RailsMultisite::ConnectionManagement.with_connection("default") do
stat.update!(
duration_ms: duration,
live_slots_finish: GC.stat[:heap_live_slots],

View File

@ -1,6 +1,24 @@
require 'rails_helper'
RSpec.describe "Running Sidekiq Jobs in Multisite" do
let(:conn) { RailsMultisite::ConnectionManagement }
before do
conn.config_filename = "spec/fixtures/multisite/two_dbs.yml"
conn.load_settings!
conn.remove_class_variable(:@@current_db)
end
after do
conn.clear_settings!
[:@@db_spec_cache, :@@host_spec_cache, :@@default_spec].each do |class_variable|
conn.remove_class_variable(class_variable)
end
conn.set_current_db
end
it 'should revert back to the default connection' do
expect(RailsMultisite::ConnectionManagement.current_db)
.to eq('default')