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>2023-09-13 06:11:37 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-09-13 06:11:37 +0300
commit9d7001c66ec5cd4e3d360f91486f32a2ede294df (patch)
tree6f31cc4059c3371a83a2d6d1ce3b470a294c01c7 /gems/activerecord-gitlab
parentec808a3c7020a1f487499314fc4d9942ea188ec4 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'gems/activerecord-gitlab')
-rw-r--r--gems/activerecord-gitlab/lib/active_record/gitlab_patches/rescue_from.rb6
-rw-r--r--gems/activerecord-gitlab/spec/active_record/gitlab_patches/rescue_from_spec.rb26
2 files changed, 16 insertions, 16 deletions
diff --git a/gems/activerecord-gitlab/lib/active_record/gitlab_patches/rescue_from.rb b/gems/activerecord-gitlab/lib/active_record/gitlab_patches/rescue_from.rb
index eaa42d1523d..faabddd2686 100644
--- a/gems/activerecord-gitlab/lib/active_record/gitlab_patches/rescue_from.rb
+++ b/gems/activerecord-gitlab/lib/active_record/gitlab_patches/rescue_from.rb
@@ -3,8 +3,10 @@
module ActiveRecord
module GitlabPatches
# This adds `rescue_from` to ActiveRecord::Base.
- # Currently, only errors called from `ActiveRecord::Relation#exec_queries`
- # will be handled by `rescue_from`.
+ # Currently only the following places will be handled by `rescue_from`:
+ #
+ # - `ActiveRecord::Relation#load`, and other methods that call
+ # `ActiveRecord::Relation#exec_queries`.
#
# class ApplicationRecord < ActiveRecord::Base
# rescue_from MyException, with: :my_handler
diff --git a/gems/activerecord-gitlab/spec/active_record/gitlab_patches/rescue_from_spec.rb b/gems/activerecord-gitlab/spec/active_record/gitlab_patches/rescue_from_spec.rb
index c1537c3bd90..22729edb014 100644
--- a/gems/activerecord-gitlab/spec/active_record/gitlab_patches/rescue_from_spec.rb
+++ b/gems/activerecord-gitlab/spec/active_record/gitlab_patches/rescue_from_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-RSpec.describe ActiveRecord::GitlabPatches::RescueFrom, :without_sqlite3 do
+RSpec.describe ActiveRecord::GitlabPatches::RescueFrom do
let(:model_with_rescue_from) do
- Class.new(ActiveRecord::Base) do
- rescue_from ActiveRecord::ConnectionNotEstablished, with: :handle_exception
+ Class.new(Project) do
+ rescue_from ActiveRecord::StatementInvalid, with: :handle_exception
class << self
def handle_exception(exception); end
@@ -12,20 +12,18 @@ RSpec.describe ActiveRecord::GitlabPatches::RescueFrom, :without_sqlite3 do
end
let(:model_without_rescue_from) do
- Class.new(ActiveRecord::Base)
+ Class.new(Project)
end
- it 'triggers rescue_from' do
- stub_const('ModelWithRescueFrom', model_with_rescue_from)
+ context 'for errors from ActiveRelation.load' do
+ it 'triggers rescue_from' do
+ expect(model_with_rescue_from).to receive(:handle_exception)
- expect(model_with_rescue_from).to receive(:handle_exception)
-
- expect { model_with_rescue_from.all.load }.not_to raise_error
- end
-
- it 'does not trigger rescue_from' do
- stub_const('ModelWithoutRescueFrom', model_without_rescue_from)
+ expect { model_with_rescue_from.where('BADQUERY').load }.not_to raise_error
+ end
- expect { model_without_rescue_from.all.load }.to raise_error(ActiveRecord::ConnectionNotEstablished)
+ it 'does not trigger rescue_from' do
+ expect { model_without_rescue_from.where('BADQUERY').load }.to raise_error(ActiveRecord::StatementInvalid)
+ end
end
end