spec/mongoid/association/accessors_spec.rb in mongoid-8.1.7 vs spec/mongoid/association/accessors_spec.rb in mongoid-9.0.0
- old
+ new
@@ -1,6 +1,7 @@
# frozen_string_literal: true
+# rubocop:todo all
require "spec_helper"
describe Mongoid::Association::Accessors do
@@ -166,36 +167,18 @@
end
end
end
context "when the association is set to nil first" do
- context "when broken_updates feature flag is not set" do
- config_override :broken_updates, false
-
- let!(:name) do
- person.build_name
- end
-
- it "returns true" do
- person.name = nil
- person.name = name
- expect(person).to have_name
- end
+ let!(:name) do
+ person.build_name
end
- context "when broken_updates feature flag is set" do
- config_override :broken_updates, true
-
- let!(:name) do
- person.build_name
- end
-
- it "returns true" do
- person.name = nil
- person.name = name
- expect(person).to have_name
- end
+ it "returns true" do
+ person.name = nil
+ person.name = name
+ expect(person).to have_name
end
end
end
context "when the association is an embeds many" do
@@ -623,11 +606,11 @@
end
it 'does not create an accessor for another field on the embedded document' do
expect do
persisted_person.passport.country
- end.to raise_error(ActiveModel::MissingAttributeError)
+ end.to raise_error(Mongoid::Errors::AttributeNotLoaded, /Attempted to access attribute 'country' on Passport which was not loaded/)
end
end
context 'when projecting association and a field in association' do
shared_examples 'is prohibited on 4.4+ server' do
@@ -653,11 +636,11 @@
end
it 'does not create an accessor for another field on the embedded document' do
expect do
persisted_person.passport.country
- end.to raise_error(ActiveModel::MissingAttributeError)
+ end.to raise_error(Mongoid::Errors::AttributeNotLoaded, /Attempted to access attribute 'country' on Passport which was not loaded/)
end
end
include_examples 'is prohibited on 4.4+ server'
end
@@ -715,11 +698,11 @@
include_examples 'allows access to field of projected association'
it 'does not create an accessor for another field on the embedded document' do
expect do
persisted_person.phone_numbers.first.landline
- end.to raise_error(ActiveModel::MissingAttributeError)
+ end.to raise_error(Mongoid::Errors::AttributeNotLoaded, /Attempted to access attribute 'landline' on Phone which was not loaded/)
end
end
context 'when projecting association and a field in association' do
@@ -744,10 +727,10 @@
include_examples 'allows access to field of projected association'
it 'does not create an accessor for another field on the embedded document' do
expect do
persisted_person.phone_numbers.first.landline
- end.to raise_error(ActiveModel::MissingAttributeError)
+ end.to raise_error(Mongoid::Errors::AttributeNotLoaded, /Attempted to access attribute 'landline' on Phone which was not loaded/)
end
end
include_examples 'is prohibited on 4.4+ server'