diff options
author | Rémy Coutable <remy@rymai.me> | 2018-05-18 17:54:47 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-05-30 13:05:49 +0300 |
commit | fee3fe72904e88d6480822ef307cffeea2c34d90 (patch) | |
tree | b87c5d14584c8375bbb6e32a1dcdf49fde7c83de /spec | |
parent | 5e39c6d75d277920c02c4ad28e4f22be2aaa1458 (diff) |
Merge branch 'memoize-database-version' into 'master'
Memoize Gitlab::Database.version
See merge request gitlab-org/gitlab-ce!19021
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 1fe1d3926ad..8ac36ae8bab 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -32,6 +32,12 @@ describe Gitlab::Database do end describe '.version' do + around do |example| + described_class.instance_variable_set(:@version, nil) + example.run + described_class.instance_variable_set(:@version, nil) + end + context "on mysql" do it "extracts the version number" do allow(described_class).to receive(:database_version) @@ -49,6 +55,14 @@ describe Gitlab::Database do expect(described_class.version).to eq '9.4.4' end end + + it 'memoizes the result' do + count = ActiveRecord::QueryRecorder + .new { 2.times { described_class.version } } + .count + + expect(count).to eq(1) + end end describe '.join_lateral_supported?' do |