Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-08 15:20:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-08 15:20:17 +0300
commit6728ed6fe203d0613ee63c89a08a70fffb93405c (patch)
tree9eddfee7a854efd47d85899c1524fd4bd10ce8e4 /spec/lib/gitlab
parent60028378dd5e5e7844810e4a2aa2934a58f738ca (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/database_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb
index b3b7c81e9e7..82b91390027 100644
--- a/spec/lib/gitlab/database_spec.rb
+++ b/spec/lib/gitlab/database_spec.rb
@@ -279,6 +279,46 @@ RSpec.describe Gitlab::Database do
end
end
+ describe '.all_uncached' do
+ let(:base_model) do
+ Class.new do
+ def self.uncached
+ @uncached = true
+
+ yield
+ end
+ end
+ end
+
+ let(:model1) { Class.new(base_model) }
+ let(:model2) { Class.new(base_model) }
+
+ before do
+ allow(described_class).to receive(:database_base_models)
+ .and_return({ model1: model1, model2: model2 }.with_indifferent_access)
+ end
+
+ it 'wraps the given block in uncached calls for each primary connection', :aggregate_failures do
+ expect(model1.instance_variable_get(:@uncached)).to be_nil
+ expect(model2.instance_variable_get(:@uncached)).to be_nil
+
+ expect(Gitlab::Database::LoadBalancing::Session.current).to receive(:use_primary).and_yield
+
+ expect(model2).to receive(:uncached).and_call_original
+ expect(model1).to receive(:uncached).and_call_original
+
+ yielded_to_block = false
+ described_class.all_uncached do
+ expect(model1.instance_variable_get(:@uncached)).to be(true)
+ expect(model2.instance_variable_get(:@uncached)).to be(true)
+
+ yielded_to_block = true
+ end
+
+ expect(yielded_to_block).to be(true)
+ end
+ end
+
describe '.read_only?' do
it 'returns false' do
expect(described_class.read_only?).to eq(false)