diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-03-16 15:39:04 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2018-03-19 20:36:49 +0300 |
commit | ae3553dbf4afd981ef6682d7deb104c7038a5a60 (patch) | |
tree | cff6d3462ee1f6e9349337caef1c77c88d0fcc3f /spec/lib | |
parent | 4cfe7682bdf50f41404d130a0e3e63389ed85809 (diff) |
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/lib')
-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) |