spec/mongoid/contextual/atomic_spec.rb in mongoid-7.3.5 vs spec/mongoid/contextual/atomic_spec.rb in mongoid-7.4.0
- old
+ new
@@ -1,24 +1,23 @@
# frozen_string_literal: true
-# encoding: utf-8
require "spec_helper"
describe Mongoid::Contextual::Atomic do
describe "#add_to_set" do
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ])
+ Band.create!(members: [ "Dave" ])
end
let!(:new_order) do
- Band.create(members: [ "Peter" ])
+ Band.create!(members: [ "Peter" ])
end
let!(:smiths) do
- Band.create
+ Band.create!
end
context "when the criteria has no sorting" do
let(:criteria) do
@@ -103,19 +102,19 @@
end
describe "#add_each_to_set" do
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ])
+ Band.create!(members: [ "Dave" ])
end
let!(:new_order) do
- Band.create(members: [ "Peter" ])
+ Band.create!(members: [ "Peter" ])
end
let!(:smiths) do
- Band.create
+ Band.create!
end
context "when the criteria has no sorting" do
let(:criteria) do
@@ -200,11 +199,11 @@
end
describe "#bit" do
let!(:depeche_mode) do
- Band.create(likes: 60)
+ Band.create!(likes: 60)
end
let(:criteria) do
Band.all
end
@@ -248,11 +247,11 @@
context 'when the criteria has a collation' do
min_server_version '3.4'
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ], likes: 60)
+ Band.create!(members: [ "Dave" ], likes: 60)
end
let(:criteria) do
Band.where(members: [ "DAVE" ]).collation(locale: 'en_US', strength: 2)
end
@@ -272,19 +271,19 @@
end
describe "#inc" do
let!(:depeche_mode) do
- Band.create(likes: 60)
+ Band.create!(likes: 60)
end
let!(:smiths) do
- Band.create
+ Band.create!
end
let!(:beatles) do
- Band.create(years: 2)
+ Band.create!(years: 2)
end
let(:criteria) do
Band.all
end
@@ -328,11 +327,11 @@
context 'when the criteria has a collation' do
min_server_version '3.4'
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ])
+ Band.create!(members: [ "Dave" ])
end
let(:criteria) do
Band.where(members: [ "DAVE" ]).collation(locale: 'en_US', strength: 2)
end
@@ -352,15 +351,15 @@
end
describe "#pop" do
let!(:depeche_mode) do
- Band.create(members: [ "Dave", "Martin" ])
+ Band.create!(members: [ "Dave", "Martin" ])
end
let!(:smiths) do
- Band.create
+ Band.create!
end
let(:criteria) do
Band.all
end
@@ -401,11 +400,11 @@
context 'when the criteria has a collation' do
min_server_version '3.4'
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ])
+ Band.create!(members: [ "Dave" ])
end
let(:criteria) do
Band.where(members: [ "DAVE" ]).collation(locale: 'en_US', strength: 2)
end
@@ -425,15 +424,15 @@
end
describe "#pull" do
let!(:depeche_mode) do
- Band.create(members: [ "Dave", "Alan" ])
+ Band.create!(members: [ "Dave", "Alan" ])
end
let!(:smiths) do
- Band.create
+ Band.create!
end
let(:criteria) do
Band.all
end
@@ -456,11 +455,11 @@
context 'when the criteria has a collation' do
min_server_version '3.4'
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ])
+ Band.create!(members: [ "Dave" ])
end
let(:criteria) do
Band.where(members: [ "DAVE" ]).collation(locale: 'en_US', strength: 2)
end
@@ -482,15 +481,15 @@
describe "#pull_all" do
context 'when the criteria does not have a collation' do
let!(:depeche_mode) do
- Band.create(members: [ "Dave", "Alan", "Fletch" ])
+ Band.create!(members: [ "Dave", "Alan", "Fletch" ])
end
let!(:smiths) do
- Band.create
+ Band.create!
end
let(:criteria) do
Band.all
end
@@ -514,11 +513,11 @@
context 'when the criteria has a collation' do
min_server_version '3.4'
let!(:depeche_mode) do
- Band.create(members: [ "Dave", "Alan", "Fletch" ])
+ Band.create!(members: [ "Dave", "Alan", "Fletch" ])
end
let(:criteria) do
Band.all.collation(locale: 'en_US', strength: 2)
end
@@ -540,15 +539,15 @@
describe "#push" do
context 'when the criteria does not have a collation' do
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ])
+ Band.create!(members: [ "Dave" ])
end
let!(:smiths) do
- Band.create
+ Band.create!
end
let(:criteria) do
Band.all
end
@@ -572,15 +571,15 @@
context 'when the criteria has a collation' do
min_server_version '3.4'
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ])
+ Band.create!(members: [ "Dave" ])
end
let!(:smiths) do
- Band.create
+ Band.create!
end
let(:criteria) do
Band.where(members: ['DAVE']).collation(locale: 'en_US', strength: 2)
end
@@ -606,15 +605,15 @@
describe "#push_all" do
context 'when the criteria does not have a collation' do
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ])
+ Band.create!(members: [ "Dave" ])
end
let!(:smiths) do
- Band.create
+ Band.create!
end
let(:criteria) do
Band.all
end
@@ -638,15 +637,15 @@
context 'when the criteria has a collation' do
min_server_version '3.4'
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ])
+ Band.create!(members: [ "Dave" ])
end
let!(:smiths) do
- Band.create
+ Band.create!
end
let(:criteria) do
Band.where(members: ['DAVE']).collation(locale: 'en_US', strength: 2)
end
@@ -668,15 +667,15 @@
describe "#rename" do
context 'when the criteria does not have a collation' do
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ])
+ Band.create!(members: [ "Dave" ])
end
let!(:smiths) do
- Band.create
+ Band.create!
end
let(:criteria) do
Band.all
end
@@ -684,31 +683,31 @@
let(:context) do
Mongoid::Contextual::Mongo.new(criteria)
end
before do
- context.rename(members: :artists)
+ context.rename(members: :musicians)
end
it "renames existing fields" do
- expect(depeche_mode.reload.artists).to eq([ "Dave" ])
+ expect(depeche_mode.reload.musicians).to eq([ "Dave" ])
end
it "does not rename non existent fields" do
- expect(smiths.reload).to_not respond_to(:artists)
+ expect(smiths.reload).to_not respond_to(:musicians)
end
end
context 'when the criteria has a collation' do
min_server_version '3.4'
let!(:depeche_mode) do
- Band.create(members: [ "Dave" ])
+ Band.create!(members: [ "Dave" ])
end
let!(:smiths) do
- Band.create
+ Band.create!
end
let(:criteria) do
Band.where(members: ['DAVE']).collation(locale: 'en_US', strength: 2)
end
@@ -716,31 +715,31 @@
let(:context) do
Mongoid::Contextual::Mongo.new(criteria)
end
before do
- context.rename(members: :artists)
+ context.rename(members: :musicians)
end
it "renames existing fields" do
- expect(depeche_mode.reload.artists).to eq([ "Dave" ])
+ expect(depeche_mode.reload.musicians).to eq([ "Dave" ])
end
it "does not rename non existent fields" do
- expect(smiths.reload).to_not respond_to(:artists)
+ expect(smiths.reload).to_not respond_to(:musicians)
end
end
end
describe "#set" do
let!(:depeche_mode) do
- Band.create(name: "Depeche Mode")
+ Band.create!(name: "Depeche Mode")
end
let!(:smiths) do
- Band.create
+ Band.create!
end
let(:criteria) do
Band.all
end
@@ -778,15 +777,15 @@
describe "#unset" do
context "when unsetting a single field" do
let!(:depeche_mode) do
- Band.create(name: "Depeche Mode", years: 10)
+ Band.create!(name: "Depeche Mode", years: 10)
end
let!(:new_order) do
- Band.create(name: "New Order", years: 10)
+ Band.create!(name: "New Order", years: 10)
end
let(:criteria) do
Band.all
end
@@ -828,11 +827,11 @@
end
context "when unsetting multiple fields" do
let!(:new_order) do
- Band.create(name: "New Order", genres: %w[electro dub], years: 10,
+ Band.create!(name: "New Order", genres: %w[electro dub], years: 10,
likes: 200, rating: 4.3, origin: 'Space')
end
let(:criteria) do
Band.all
@@ -910,14 +909,14 @@
context 'when the criteria has a collation' do
min_server_version '3.4'
let!(:depeche_mode) do
- Band.create(name: "Depeche Mode", years: 10)
+ Band.create!(name: "Depeche Mode", years: 10)
end
let!(:new_order) do
- Band.create(name: "New Order", years: 10)
+ Band.create!(name: "New Order", years: 10)
end
let(:criteria) do
Band.where(name: 'DEPECHE MODE').collation(locale: 'en_US', strength: 2)
end