spec/mongoid/persistable/destroyable_spec.rb in mongoid-7.3.5 vs spec/mongoid/persistable/destroyable_spec.rb in mongoid-7.4.0
- old
+ new
@@ -1,7 +1,6 @@
# frozen_string_literal: true
-# encoding: utf-8
require "spec_helper"
describe Mongoid::Persistable::Destroyable do
@@ -85,11 +84,11 @@
end
context "when the document has been saved" do
before do
- address.save
+ address.save!
address.destroy
end
let(:from_db) do
Person.find(person.id)
@@ -133,15 +132,15 @@
context "when removing deeply embedded documents" do
context "when the document has been saved" do
let(:address) do
- person.addresses.create(street: "Bond Street")
+ person.addresses.create!(street: "Bond Street")
end
let(:location) do
- address.locations.create(name: "Home")
+ address.locations.create!(name: "Home")
end
let(:from_db) do
Person.find(person.id)
end
@@ -248,22 +247,22 @@
describe "#destroy!" do
context "when no validation callback returns false" do
let(:person) do
- Person.create
+ Person.create!
end
it "returns true" do
expect(person.destroy!).to eq(true)
end
end
context "when a validation callback returns false" do
let(:album) do
- Album.create
+ Album.create!
end
before do
Album.before_destroy(:set_parent_name_fail)
end
@@ -281,11 +280,11 @@
end
describe "#destroy_all" do
let!(:person) do
- Person.create(title: "sir")
+ Person.create!(title: "sir")
end
context "when no conditions are provided" do
let!(:removed) do
@@ -302,11 +301,11 @@
end
context "when conditions are provided" do
let!(:person_two) do
- Person.create
+ Person.create!
end
context "when no conditions attribute provided" do
let!(:removed) do
@@ -324,10 +323,10 @@
end
context 'when the write concern is unacknowledged' do
before do
- Person.create(title: 'miss')
+ Person.create!(title: 'miss')
end
let!(:removed) do
Person.with(write: { w: 0 }) { |klass| klass.destroy_all(title: "sir") }
end