Commit bbddd770 authored by Rémy Coutable's avatar Rémy Coutable 🔴

Merge branch 'database-config-method' into 'master'

Added Gitlab::Database.config

See merge request !10045
parents 5409a3c5 9a20ff1c
...@@ -42,7 +42,7 @@ Sidekiq.configure_server do |config| ...@@ -42,7 +42,7 @@ Sidekiq.configure_server do |config|
Gitlab::SidekiqThrottler.execute! Gitlab::SidekiqThrottler.execute!
config = ActiveRecord::Base.configurations[Rails.env] || config = Gitlab::Database.config ||
Rails.application.config.database_configuration[Rails.env] Rails.application.config.database_configuration[Rails.env]
config['pool'] = Sidekiq.options[:concurrency] config['pool'] = Sidekiq.options[:concurrency]
ActiveRecord::Base.establish_connection(config) ActiveRecord::Base.establish_connection(config)
......
...@@ -5,8 +5,12 @@ module Gitlab ...@@ -5,8 +5,12 @@ module Gitlab
# http://dev.mysql.com/doc/refman/5.7/en/integer-types.html # http://dev.mysql.com/doc/refman/5.7/en/integer-types.html
MAX_INT_VALUE = 2147483647 MAX_INT_VALUE = 2147483647
def self.config
ActiveRecord::Base.configurations[Rails.env]
end
def self.adapter_name def self.adapter_name
ActiveRecord::Base.configurations[Rails.env]['adapter'] config['adapter']
end end
def self.mysql? def self.mysql?
......
require 'spec_helper' require 'spec_helper'
class MigrationTest
include Gitlab::Database
end
describe Gitlab::Database, lib: true do describe Gitlab::Database, lib: true do
before do
stub_const('MigrationTest', Class.new { include Gitlab::Database })
end
describe '.config' do
it 'returns a Hash' do
expect(described_class.config).to be_an_instance_of(Hash)
end
end
describe '.adapter_name' do describe '.adapter_name' do
it 'returns the name of the adapter' do it 'returns the name of the adapter' do
expect(described_class.adapter_name).to be_an_instance_of(String) expect(described_class.adapter_name).to be_an_instance_of(String)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment