Skip to content

Commit

Permalink
possible CI fix
Browse files Browse the repository at this point in the history
  • Loading branch information
antonsavitskiy committed May 3, 2024
1 parent bbbd82b commit e65aedf
Showing 1 changed file with 39 additions and 36 deletions.
75 changes: 39 additions & 36 deletions spec/mongoid/association/referenced/belongs_to/proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -97,7 +100,7 @@
context 'when the child is a new record' do

let(:person) do
Person.new
PersonAutoSave.new
end

let(:game) do
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -324,7 +327,7 @@
context 'when the child is a new record' do

let(:person) do
Person.new
PersonAutoSave.new
end

let(:post) do
Expand All @@ -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
Expand Down Expand Up @@ -484,7 +487,7 @@
end

let(:person) do
Person.create!
PersonAutoSave.create!
end

context 'when relation is has_one' do
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -590,7 +593,7 @@
end

let(:person) do
Person.create!
PersonAutoSave.create!
end

context 'when relation is has_one' do
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -685,7 +688,7 @@
end

let(:person) do
Person.create!
PersonAutoSave.create!
end

context 'when relation is has_one' do
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -798,7 +801,7 @@
context 'when the parent is a new record' do

let(:person) do
Person.new
PersonAutoSave.new
end

let(:game) do
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -926,7 +929,7 @@
context 'when the parent is a new record' do

let(:person) do
Person.new
PersonAutoSave.new
end

let(:post) do
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1044,7 +1047,7 @@
describe '#respond_to?' do

let(:person) do
Person.new
PersonAutoSave.new
end

let(:game) do
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -1351,7 +1354,7 @@ class C

describe '#method_missing' do
let!(:person) do
Person.create!
PersonAutoSave.create!
end

let!(:game) do
Expand Down

0 comments on commit e65aedf

Please sign in to comment.