diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-03-16 12:39:04 +0000 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-03-16 12:39:04 +0000 |
commit | fd4bb1e3142bb1e9309f7b0c93cd8e8002ef8192 (patch) | |
tree | 9e314bfda26ad165fb363a3735bf9dfec8b1cf71 /spec | |
parent | bfaf3d695553531a5b88747aa320371ba22ce641 (diff) | |
parent | 272783be20927148d86b05a7e22f88b291c6dd93 (diff) | |
download | gitlab-ce-fd4bb1e3142bb1e9309f7b0c93cd8e8002ef8192.tar.gz |
Merge branch 'sh-cache-table-exists' into 'master'
Cache table_exists?('application_settings') to reduce repeated schema reloads
Closes #43355
See merge request gitlab-org/gitlab-ce!17781
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 689bbbfaa8d..1fe1d3926ad 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -298,6 +298,18 @@ describe Gitlab::Database do end end + describe '.cached_table_exists?' do + it 'only retrieves data once per table' do + expect(ActiveRecord::Base.connection).to receive(:table_exists?).with(:projects).once.and_call_original + expect(ActiveRecord::Base.connection).to receive(:table_exists?).with(:bogus_table_name).once.and_call_original + + 2.times do + expect(described_class.cached_table_exists?(:projects)).to be_truthy + expect(described_class.cached_table_exists?(:bogus_table_name)).to be_falsey + end + end + end + describe '#true_value' do it 'returns correct value for PostgreSQL' do expect(described_class).to receive(:postgresql?).and_return(true) |