From e65aedf41216ad3e4633e6f2d8945a1ad48ff16b Mon Sep 17 00:00:00 2001 From: Anton Savitskiy Date: Fri, 3 May 2024 17:29:59 +0200 Subject: [PATCH] possible CI fix --- .../referenced/belongs_to/proxy_spec.rb | 75 ++++++++++--------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb b/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb index dab566c26..f72eb7b1d 100644 --- a/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +++ b/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb @@ -3,14 +3,17 @@ require 'spec_helper' require_relative '../belongs_to_models' +class PersonAutoSave < Person +end + describe Mongoid::Association::Referenced::BelongsTo::Proxy do before(:all) do - Person.reset_callbacks(:validate) + PersonAutoSave.reset_callbacks(:validate) end let(:person) do - Person.create! + PersonAutoSave.create! end describe '#=' do @@ -62,7 +65,7 @@ context 'when referencing a document from an embedded document' do let(:person) do - Person.create! + PersonAutoSave.create! end let(:address) do @@ -97,7 +100,7 @@ context 'when the child is a new record' do let(:person) do - Person.new + PersonAutoSave.new end let(:game) do @@ -149,7 +152,7 @@ context 'when the child is not a new record' do let(:person) do - Person.new + PersonAutoSave.new end let(:game) do @@ -287,15 +290,15 @@ context 'when the child has persistence options set' do before do - Person.collection.client['other-posts'].delete_many - Person.collection.client['other-people'].delete_many + PersonAutoSave.collection.client['other-posts'].delete_many + PersonAutoSave.collection.client['other-people'].delete_many end let(:person) do - Person.new + PersonAutoSave.new end let(:other_people_count) do - Person.with(collection: 'other-people', &:count) + PersonAutoSave.with(collection: 'other-people', &:count) end let(:other_posts_count) do Post.with(collection: 'other-posts', &:count) @@ -324,7 +327,7 @@ context 'when the child is a new record' do let(:person) do - Person.new + PersonAutoSave.new end let(:post) do @@ -351,7 +354,7 @@ context 'when the child is not a new record' do let(:person) do - Person.new + PersonAutoSave.new end let(:post) do @@ -484,7 +487,7 @@ end let(:person) do - Person.create! + PersonAutoSave.create! end context 'when relation is has_one' do @@ -498,14 +501,14 @@ before do Account.belongs_to :person, dependent: :destroy - Person.has_one :account + PersonAutoSave.has_one :account person.account = account person.save! end after :all do Account.belongs_to :person, dependent: :nullify - Person.has_one :account, validate: false + PersonAutoSave.has_one :account, validate: false end context 'when parent exists' do @@ -549,14 +552,14 @@ before do Drug.belongs_to :person, dependent: :destroy - Person.has_many :drugs + PersonAutoSave.has_many :drugs person.drugs = [drug] person.save! end after :all do Drug.belongs_to :person, dependent: :nullify - Person.has_many :drugs, validate: false + PersonAutoSave.has_many :drugs, validate: false end context 'when parent exists' do @@ -590,7 +593,7 @@ end let(:person) do - Person.create! + PersonAutoSave.create! end context 'when relation is has_one' do @@ -604,14 +607,14 @@ before do Account.belongs_to :person, dependent: :delete_all - Person.has_one :account + PersonAutoSave.has_one :account person.account = account person.save! end after :all do Account.belongs_to :person, dependent: :nullify - Person.has_one :account, validate: false + PersonAutoSave.has_one :account, validate: false end context 'when parent is persisted' do @@ -644,14 +647,14 @@ before do Drug.belongs_to :person, dependent: :delete_all - Person.has_many :drugs + PersonAutoSave.has_many :drugs person.drugs = [drug] person.save! end after :all do Drug.belongs_to :person, dependent: :nullify - Person.has_many :drugs, validate: false + PersonAutoSave.has_many :drugs, validate: false end context 'when parent exists' do @@ -685,7 +688,7 @@ end let(:person) do - Person.create! + PersonAutoSave.create! end context 'when relation is has_one' do @@ -699,7 +702,7 @@ before do Account.belongs_to :person, dependent: :nullify - Person.has_one :account + PersonAutoSave.has_one :account person.account = account person.save! end @@ -738,7 +741,7 @@ before do Drug.belongs_to :person, dependent: :nullify - Person.has_many :drugs + PersonAutoSave.has_many :drugs person.drugs = [drug] person.save! end @@ -798,7 +801,7 @@ context 'when the parent is a new record' do let(:person) do - Person.new + PersonAutoSave.new end let(:game) do @@ -826,7 +829,7 @@ context 'when the parent is not a new record' do let(:person) do - Person.create! + PersonAutoSave.create! end let(:game) do @@ -926,7 +929,7 @@ context 'when the parent is a new record' do let(:person) do - Person.new + PersonAutoSave.new end let(:post) do @@ -954,7 +957,7 @@ context 'when the parent is not a new record' do let(:person) do - Person.new + PersonAutoSave.new end let(:post) do @@ -1044,7 +1047,7 @@ describe '#respond_to?' do let(:person) do - Person.new + PersonAutoSave.new end let(:game) do @@ -1159,7 +1162,7 @@ class C context 'when replacing the relation with another' do let!(:person) do - Person.create! + PersonAutoSave.create! end let!(:post) do @@ -1245,11 +1248,11 @@ class C context 'when reloading the relation' do let!(:person_one) do - Person.create! + PersonAutoSave.create! end let!(:person_two) do - Person.create!(title: 'Sir') + PersonAutoSave.create!(title: 'Sir') end let!(:game) do @@ -1264,7 +1267,7 @@ class C context 'when the relation references the same document' do before do - Person.collection.find({ _id: person_one.id }) + PersonAutoSave.collection.find({ _id: person_one.id }) .update_one({ '$set' => { title: 'Madam' } }) end @@ -1328,11 +1331,11 @@ class C context 'when the relation exists' do let!(:person_one) do - Person.create! + PersonAutoSave.create! end let!(:person_two) do - Person.create! + PersonAutoSave.create! end let!(:game) do @@ -1351,7 +1354,7 @@ class C describe '#method_missing' do let!(:person) do - Person.create! + PersonAutoSave.create! end let!(:game) do