repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/foreign_key_spec.rb | spec/integration/associations/foreign_key_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
require_relative './foreign_key_spec_models'
describe 'Association foreign key configuration' do
describe 'has_many/belongs_to' do
it 'creates child' do
company = ForeignKeySpec::Company.create!(c: 'test')
email = ForeignKeySpec:... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/embedded_spec.rb | spec/integration/associations/embedded_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
require_relative '../../mongoid/association/embedded/embeds_many_models'
require_relative '../../mongoid/association/embedded/embeds_one_models'
describe 'embedded associations' do
context 'without default order' do
let(:congress) do
E... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/nested_attributes_assignment_spec.rb | spec/integration/associations/nested_attributes_assignment_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'nested attributes assignment' do
context 'when creating parent document' do
context 'when setting deeply nested attributes' do
context 'embeds_many' do
let(:truck) { Truck.new }
it 'persists all documents' do... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/foreign_key_spec_models.rb | spec/integration/associations/foreign_key_spec_models.rb | # frozen_string_literal: true
# rubocop:todo all
module ForeignKeySpec
class Company
include Mongoid::Document
field :c, type: String
has_many :emails, class_name: 'ForeignKeySpec::Email',
foreign_key: 'c_ref', primary_key: 'c'
has_one :founder, class_name: 'ForeignKeySpec::Founder',
for... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/has_and_belongs_to_many_spec.rb | spec/integration/associations/has_and_belongs_to_many_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
module HabtmSpec
class Page
include Mongoid::Document
embeds_many :blocks, class_name: 'HabtmSpec::Block'
end
class Block
include Mongoid::Document
embedded_in :page, class_name: 'HabtmSpec::Page'
end
class ImageBlock <... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/has_one_spec.rb | spec/integration/associations/has_one_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
require 'mongoid/association/referenced/has_one_models'
describe 'has_one associations' do
context 'destroying parent in transaction with dependent child' do
require_transaction_support
let(:college) { HomCollege.create! }
let(:addr... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/belongs_to_spec.rb | spec/integration/associations/belongs_to_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
require 'support/feature_sandbox'
require_relative '../../mongoid/association/referenced/has_one_models'
def quarantine(context, polymorphic:, dept_aliases:, team_aliases:)
state = {}
context.before(:context) do
state[:quarantine] = Feat... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/embeds_one_spec.rb | spec/integration/associations/embeds_one_spec.rb | # frozen_string_literal: true
require 'spec_helper'
describe 'embeds_one associations' do
context 'when re-associating the same object' do
context 'with dependent: destroy' do
let(:canvas) do
Canvas.create!(palette: Palette.new)
end
let!(:palette) { canvas.palette }
it 'does no... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/scope_option_spec.rb | spec/integration/associations/scope_option_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
require_relative '../../mongoid/association/referenced/has_and_belongs_to_many_models'
require_relative '../../mongoid/association/referenced/has_many_models'
require_relative '../../mongoid/association/referenced/has_one_models'
describe 'associa... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/embeds_many_spec.rb | spec/integration/associations/embeds_many_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
module EmbedsManySpec
class Post
include Mongoid::Document
field :title, type: String
embeds_many :comments, class_name: 'EmbedsManySpec::Comment', as: :container
accepts_nested_attributes_for :comments
end
class Comment
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/rails/mongoid_spec.rb | spec/rails/mongoid_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require "support/feature_sandbox"
describe "Rails::Mongoid" do
let(:model_root) do
File.absolute_path(
File.join(
File.dirname(__FILE__),
"../support/models/sandbox"
))
end
around :each do |example|
Featu... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/rails/controller_extension/controller_runtime_spec.rb | spec/rails/controller_extension/controller_runtime_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require "mongoid/railties/controller_runtime"
describe "Mongoid::Railties::ControllerRuntime" do
CONTROLLER_RUNTIME = Mongoid::Railties::ControllerRuntime
COLLECTOR = CONTROLLER_RUNTIME::Collector
def set_metric(value)
Mongoid::Threaded... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/monkey_patches_spec.rb | spec/mongoid/monkey_patches_spec.rb | # frozen_string_literal: true
require 'spec_helper'
# @note This test ensures that we do not inadvertently introduce new monkey patches
# to Mongoid. Existing monkey patch methods which are marked with +Mongoid.deprecated+
# are excluded from this test.
RSpec.describe('Do not add monkey patches') do
classes = [
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/persistence_context_spec.rb | spec/mongoid/persistence_context_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::PersistenceContext do
let(:persistence_context) do
described_class.new(object, options)
end
let(:object) do
Band
end
describe '.set' do
let(:options) do
{ collection: :other }
end
context ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/clients_spec.rb | spec/mongoid/clients_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Clients do
describe "#collection" do
shared_examples_for "an overridden collection at the class level" do
it "returns the collection for the model" do
expect(instance_collection).to be_a(Mongo::Collection)
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/composable_spec.rb | spec/mongoid/composable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Composable do
describe ".prohibited_methods" do
let(:methods) do
described_class.prohibited_methods
end
Mongoid::Composable::MODULES.each do |mod|
context "when checking in #{mod}" do
mod.in... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/shardable_models.rb | spec/mongoid/shardable_models.rb | # rubocop:todo all
class SmMovie
include Mongoid::Document
field :year, type: Integer
index year: 1
shard_key :year
end
class SmTrailer
include Mongoid::Document
index year: 1
shard_key 'year'
end
class SmActor
include Mongoid::Document
# This is not a usable shard configuration for the server.
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association_spec.rb | spec/mongoid/association_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Association do
before(:all) do
Person.field(
:_id,
type: BSON::ObjectId,
pre_processed: true,
default: ->{ BSON::ObjectId.new },
overwrite: true
)
end
context "when class_name referen... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/findable_spec.rb | spec/mongoid/findable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Findable do
describe ".distinct" do
before do
Band.create!(name: "Tool")
Band.create!(name: "Photek")
end
it "returns the distinct values for the field" do
expect(Band.distinct(:name).sort).to e... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/traversable_spec.rb | spec/mongoid/traversable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Traversable do
describe "#_children" do
let(:person) do
Person.new(title: "King")
end
context "with one level of embedding" do
let(:name) do
Name.new(first_name: "Titus")
end
let... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | true |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/document_query_spec.rb | spec/mongoid/document_query_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Document do
context 'when projecting with #only' do
before do
Person.create!(username: 'Dev', title: 'CEO')
end
let(:person) { Person.where(username: 'Dev').only(:_id, :username).first }
it 'populates s... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/stateful_spec.rb | spec/mongoid/stateful_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Stateful do
describe "#new_record?" do
context "when calling new on the document" do
let(:person) do
Person.new("_id" => BSON::ObjectId.new)
end
it "returns true" do
expect(person).to b... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/document_fields_spec.rb | spec/mongoid/document_fields_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Document do
describe 'BSON::Binary field' do
context 'when assigned a BSON::Binary instance' do
let(:data) do
BSON::Binary.new("hello world")
end
let(:registry) do
Registry.new(data: data... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/loadable_spec.rb | spec/mongoid/loadable_spec.rb | # frozen_string_literal: true
require 'spec_helper'
describe Mongoid::Loadable do
let(:lib_dir) { Pathname.new('../../lib').realpath(__dir__) }
shared_context 'with ignore_patterns' do
around do |example|
saved = Mongoid.ignore_patterns
Mongoid.ignore_patterns = ignore_patterns
example.run
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/inspectable_spec.rb | spec/mongoid/inspectable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Inspectable do
describe "#inspect" do
context "when not allowing dynamic fields" do
let(:person) do
Person.new(title: "CEO")
end
let(:inspected) do
person.inspect
end
it "i... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/fields_spec.rb | spec/mongoid/fields_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Fields do
describe "#\{field}_translations" do
let(:product) do
Product.new
end
context "when the field is localized" do
context "when translations exist" do
with_default_i18n_configs
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | true |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/document_spec.rb | spec/mongoid/document_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Document do
let(:klass) do
Person
end
let(:person) do
Person.new
end
it "defines a _destroy method" do
expect(Person.new).to respond_to(:_destroy)
end
describe "#_destroy" do
it "default to fals... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/touchable_spec.rb | spec/mongoid/touchable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './touchable_spec_models'
describe Mongoid::Touchable do
describe "#touch" do
context "when the document has no associations" do
let(:updatable) do
Updatable.create!
end
it "responds to #touch" d... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | true |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/touchable_spec_models.rb | spec/mongoid/touchable_spec_models.rb | # frozen_string_literal: true
# rubocop:todo all
module TouchableSpec
module Embedded
class Building
include Mongoid::Document
include Mongoid::Timestamps
field :title, type: String
embeds_many :entrances, class_name: "TouchableSpec::Embedded::Entrance"
embeds_many :floors, class_... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/factory_spec.rb | spec/mongoid/factory_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Factory do
describe ".build" do
context "when the type attribute is present" do
let(:attributes) do
{ "_type" => "Person", "title" => "Sir" }
end
context "when the type is a class" do
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/document_persistence_context_spec.rb | spec/mongoid/document_persistence_context_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Document do
let(:klass) do
Person
end
let(:person) do
Person.new
end
describe '.client_name' do
it 'returns client name' do
Person.client_name.should == :default
end
end
describe '.database... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/criteria_spec.rb | spec/mongoid/criteria_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Criteria do
describe "#==" do
let(:criteria) do
Band.where(name: "Depeche Mode")
end
context "when the other is a criteria" do
context "when the criteria are the same" do
let(:other) do
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | true |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/criteria_projection_spec.rb | spec/mongoid/criteria_projection_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Criteria do
describe "#only" do
let!(:band) do
Band.create!(name: "Depeche Mode", likes: 3, views: 10)
end
context "when not using inheritance" do
context "when passing splat args" do
let(:c... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/copyable_spec.rb | spec/mongoid/copyable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './copyable_spec_models'
describe Mongoid::Copyable do
[ :clone, :dup ].each do |method|
describe "##{method}" do
let(:person) do
Person.new(
title: "Sir",
version: 4,
created_... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/timestamps_spec_models.rb | spec/mongoid/timestamps_spec_models.rb | # frozen_string_literal: true
# rubocop:todo all
module TimestampsSpec
module Touch
class User
include Mongoid::Document
include Mongoid::Timestamps
has_and_belongs_to_many :addresses, class_name: "TimestampsSpec::Touch::Address"
has_many :accounts, class_name: "TimestampsSpec::Touch::Ac... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/scopable_spec.rb | spec/mongoid/scopable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
# Retrieve the singleton class for the given class.
def singleton_class_for(klass)
class <<klass; self; end
end
# Helper method for removing a declared scope
def remove_scope(klass, scope)
if klass._declared_scopes[scope]
singleton_class_... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/atomic_spec.rb | spec/mongoid/atomic_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Atomic do
describe "#add_atomic_pull" do
let!(:person) do
Person.create!
end
let(:address) do
person.addresses.create!
end
let(:location) do
address.locations.create!
end
befor... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/collection_configurable_spec.rb | spec/mongoid/collection_configurable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::CollectionConfigurable do
before(:all) do
class CollectionConfigurableValidOptions
include Mongoid::Document
store_in collection_options: {
capped: true,
size: 2560
}
end
class C... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/indexable_spec.rb | spec/mongoid/indexable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Indexable do
after do
Person.collection.drop
end
describe ".included" do
let(:klass) do
Class.new do
include Mongoid::Indexable
end
end
it "adds an index_specifications accessor" do
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/reloadable_spec.rb | spec/mongoid/reloadable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Reloadable do
describe "#reload" do
context 'when persistence options are set' do
let(:person) do
Person.with(collection: 'other') do |person_class|
person_class.create!
end
end
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/shardable_spec.rb | spec/mongoid/shardable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './shardable_models'
describe Mongoid::Shardable do
describe ".included" do
let(:klass) do
Class.new do
include Mongoid::Shardable
end
end
it "adds an shard_key_fields accessor" do
expect... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/loggable_spec.rb | spec/mongoid/loggable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Loggable do
describe "#logger=" do
let(:logger) do
Logger.new($stdout).tap do |log|
log.level = Logger::INFO
end
end
before do
Mongoid.logger = logger
end
it "sets the logger" d... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/positional_spec.rb | spec/mongoid/positional_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Positional do
describe "#positionally" do
let(:positionable) do
Class.new do
include Mongoid::Positional
end.new
end
let(:updates) do
{
"$set" => {
"field" => "value",
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/validatable_spec.rb | spec/mongoid/validatable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Validatable do
let(:account) do
Account.new(name: "Testing a really long name.")
end
describe "#read_attribute_for_validation" do
let(:person) do
Person.new(title: "Mr")
end
let!(:address) do
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/interceptable_spec_models.rb | spec/mongoid/interceptable_spec_models.rb | # rubocop:todo all
module InterceptableSpec
class CallbackRegistry
def initialize(only: [])
@calls = []
@only = only
end
def record_call(cls, cb)
return unless @only.empty? || @only.any? { |pat| pat == cb }
@calls << [cls, cb]
end
attr_reader :calls
end
module Callba... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/warnings_spec.rb | spec/mongoid/warnings_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Warnings do
describe ".warn_*" do
context "when calling a warn_* method" do
let(:id) { :geo_haystack_deprecated }
let(:message) do
'The geoHaystack type is deprecated.'
end
before do
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/loading_spec.rb | spec/mongoid/loading_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "ostruct"
require "spec_helper"
require "support/feature_sandbox"
describe Mongoid::Loadable do
let(:model_root) do
File.absolute_path(
File.join(
File.dirname(__FILE__),
"../support/models/sandbox"
))
end
let(:app_models_... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/changeable_spec.rb | spec/mongoid/changeable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Changeable do
describe "#attribute_change" do
context "when the attribute has changed from the persisted value" do
context "when using the setter" do
let(:person) do
Person.new(title: "Grand Poob... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | true |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/equality_spec.rb | spec/mongoid/equality_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Equality do
let(:klass) do
Person
end
let(:person) do
Person.new
end
describe "#==" do
context "when comparable is not a document" do
let(:other) do
"Document"
end
it "returns... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/cacheable_spec.rb | spec/mongoid/cacheable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Cacheable do
describe ".included" do
let(:klass) do
Class.new do
include Mongoid::Cacheable
end
end
it "adds an cache_timestamp_format accessor" do
expect(klass).to respond_to(:cache_tim... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/selectable_spec.rb | spec/mongoid/selectable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Selectable do
describe "#atomic_selector" do
context "when the document is a root document" do
context "when the document has a shard key" do
let(:profile) do
Profile.create!(name: "google")
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/atomic_update_preparer_spec.rb | spec/mongoid/atomic_update_preparer_spec.rb | # frozen_string_literal: true
require 'spec_helper'
describe Mongoid::AtomicUpdatePreparer do
describe '#prepare' do
let(:prepared) { described_class.prepare(hash, Band) }
context 'when the hash already contains $set' do
context 'when the $set is first' do
let(:hash) do
{ '$set' => ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/threaded_spec.rb | spec/mongoid/threaded_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Threaded do
let(:object) do
double
end
describe "#begin" do
before do
described_class.begin_execution("load")
end
after do
described_class.stack("load").clear
end
it "adds a boolean ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/persistable_spec.rb | spec/mongoid/persistable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Persistable do
class PersistableSpecTestException < StandardError; end
describe "#atomically" do
let(:document) do
Band.create!(member_count: 0, likes: 60, origin: "London")
end
context "when providing a... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/interceptable_spec.rb | spec/mongoid/interceptable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './interceptable_spec_models'
describe Mongoid::Interceptable do
before do
# The find and initialize callbacks I added were causing failures
# because they were causing updates when we were asserting no updates
# ha... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | true |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/serializable_spec.rb | spec/mongoid/serializable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Serializable do
describe "#field_names" do
let(:guitar) do
Guitar.new
end
it "does not duplicate fields" do
expect(guitar.send(:field_names, {})).to eq(guitar.fields.except("_type").keys.sort)
end... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/attributes_spec.rb | spec/mongoid/attributes_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './attributes/nested_spec_models'
describe Mongoid::Attributes do
describe "\#{attribute}" do
context "when setting the value in the getter" do
let(:account) do
Account.new
end
it "does not caus... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | true |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/copyable_spec_models.rb | spec/mongoid/copyable_spec_models.rb | # frozen_string_literal: true
# rubocop:todo all
module CopyableSpec
class A
include Mongoid::Document
embeds_many :locations
embeds_many :influencers
end
class Location
include Mongoid::Document
embeds_many :buildings
end
class Building
include Mongoid::Document
end
class In... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/search_indexable_spec.rb | spec/mongoid/search_indexable_spec.rb | # frozen_string_literal: true
require 'spec_helper'
class SearchIndexHelper
attr_reader :model
def initialize(model)
@model = model
model.collection.drop
model.collection.create
end
def collection
model.collection
end
# Wait for all of the indexes with the given names to be ready; then ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/config_spec.rb | spec/mongoid/config_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require "support/feature_sandbox"
describe Mongoid::Config do
after do
Mongoid.configure do |config|
config.load_configuration(CONFIG)
end
end
describe "#configured?" do
after do
described_class.connect_to(database... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/model_resolver_spec.rb | spec/mongoid/model_resolver_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'support/feature_sandbox'
MONGOID_MODEL_RESOLVER_KEY__ = :__separate_instance_spec_key
Mongoid::ModelResolver.register_resolver Mongoid::ModelResolver.new, MONGOID_MODEL_RESOLVER_KEY__
def quarantine(context, &block)
state = {}
context.before(:context)... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/timestamps_spec.rb | spec/mongoid/timestamps_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './timestamps_spec_models'
describe Mongoid::Timestamps do
describe ".included" do
let(:document) do
Dokument.new
end
let(:fields) do
Dokument.fields
end
let(:time_zone) { "Pacific Time (US & ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/mongoizable_spec.rb | spec/mongoid/mongoizable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
# This file is for testing the functionality of uncastable values for all
# mongoizable classes.
describe "mongoize/demongoize/evolve methods" do
shared_examples "handles unmongoizable values" do
context "when passing an invalid value" do
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/matcher/extract_attribute_spec.rb | spec/mongoid/matcher/extract_attribute_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Matcher.extract_attribute' do
Dir[File.join(File.dirname(__FILE__), 'extract_attribute_data', '*.yml')].sort.each do |path|
context File.basename(path) do
specs = YAML.safe_load(File.read(path), aliases: true)
specs.ea... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/tasks/database_spec.rb | spec/mongoid/tasks/database_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Tasks::Database do
before(:all) do
module DatabaseSpec
class Measurement
include Mongoid::Document
field :timestamp, type: Time
field :temperature, type: Integer
embeds_many :comment... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/tasks/encryption_spec.rb | spec/mongoid/tasks/encryption_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe "Mongoid::Tasks::Encryption" do
require_enterprise
require_libmongocrypt
include_context 'with encryption'
restore_config_clients
describe ".create_data_key" do
let(:config) do
{
default: { hosts: SpecConfig.i... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/tasks/database_rake_spec.rb | spec/mongoid/tasks/database_rake_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "rake"
require "spec_helper"
require "support/feature_sandbox"
shared_context "rake task" do
min_server_version '4.4'
let(:task_name) { self.class.top_level_description }
let(:task) { Rake.application[task_name] }
let(:task_file) { "mongoid/tasks/databa... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/validatable/numericality_spec.rb | spec/mongoid/validatable/numericality_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe ActiveModel::Validations::NumericalityValidator do
describe "#validate_each" do
before(:all) do
class TestModel
include Mongoid::Document
field :amount, type: BigDecimal
validates_numericality_of :amo... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/validatable/length_spec.rb | spec/mongoid/validatable/length_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Validatable::LengthValidator do
describe "#validate_each" do
let(:product) do
Product.new
end
context "when the field is not localized" do
let(:validator) do
described_class.new(attributes: [... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/validatable/presence_spec.rb | spec/mongoid/validatable/presence_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative '../association/referenced/has_one_models'
describe Mongoid::Validatable::PresenceValidator do
describe "#validate_each" do
let(:product) do
Product.new
end
let(:validator) do
described_class.new(attri... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/validatable/uniqueness_spec.rb | spec/mongoid/validatable/uniqueness_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Validatable::UniquenessValidator do
describe "#valid?" do
context "when the document is a root document" do
context "when setting the read preference to non-primary" do
before do
Dictionary.valid... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | true |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/validatable/format_spec.rb | spec/mongoid/validatable/format_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Validatable::FormatValidator do
describe "#validate_each" do
let(:product) do
Product.new
end
context "when the field is not localized" do
let(:validator) do
described_class.new(attributes: [... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/validatable/associated_spec.rb | spec/mongoid/validatable/associated_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Validatable::AssociatedValidator do
describe "#valid?" do
context "when validating associated on both sides" do
context "when the documents are valid" do
let(:user) do
User.new(name: "test")
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/relations/proxy_spec.rb | spec/mongoid/relations/proxy_spec.rb | # frozen_string_literal: true
# rubocop:todo all
# require "spec_helper"
#
# describe Mongoid::Relations::Proxy do
#
# describe '#with' do
#
# let(:circus) do
# Circus.new
# end
#
# let(:animal) do
# Animal.new
# end
#
# before do
# circus.animals << animal
# circus.save!
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/counter_cache_spec.rb | spec/mongoid/association/counter_cache_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Association::Referenced::CounterCache do
describe "#reset_counters" do
context "when counter is reset" do
let(:person) do
Person.create! do |person|
person[:drugs_count] = 3
end
end
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/syncable_spec.rb | spec/mongoid/association/syncable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe "Syncable Association" do
config_override :raise_not_found_error, true
before(:all) do
Person._synced(Person.relations["preferences"])
Person.has_and_belongs_to_many :preferences
Preference.has_and_belongs_to_many :people... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/auto_save_spec.rb | spec/mongoid/association/auto_save_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './referenced/has_many_models'
require_relative './referenced/has_one_models'
describe Mongoid::Association::Referenced::AutoSave do
describe ".auto_save" do
before(:all) do
Person.has_many :drugs, validate: false, a... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/eager_spec.rb | spec/mongoid/association/eager_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Association::EagerLoadable do
describe ".preload" do
let(:criteria) do
Account.where(name: 'savings')
end
let(:context) do
Mongoid::Contextual::Mongo.new(criteria)
end
let(:association_host) ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/builders_spec.rb | spec/mongoid/association/builders_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Association::Builders do
describe "#build_#\{name}" do
let(:person) do
Person.new
end
context "when providing no attributes" do
context "when the relation is an embeds one" do
let(:name) do
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/macros_spec.rb | spec/mongoid/association/macros_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Association::Macros do
class TestClass
include Mongoid::Document
end
let(:klass) do
TestClass
end
before do
klass.relations.clear
klass._validators.clear
end
after do
klass.relations.clear
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/constrainable_spec.rb | spec/mongoid/association/constrainable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Association::Constrainable do
describe "#convert_to_foreign_key" do
context "when the id's class stores object ids" do
before(:all) do
Person.field(
:_id,
type: BSON::ObjectId,
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/accessors_spec.rb | spec/mongoid/association/accessors_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Association::Accessors do
describe "\#{getter}?" do
let(:person) do
Person.create!
end
context "when the association is a has one" do
context "when the association exists" do
let!(:game) do
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/polymorphic_spec.rb | spec/mongoid/association/polymorphic_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe "Polymorphic Associations" do
describe "#polymorph" do
let(:klass) do
Class.new.tap { |c| c.send(:include, Mongoid::Document) }
end
context "when the relation is polymorphic" do
context "when the relation sto... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/depending_spec.rb | spec/mongoid/association/depending_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Association::Depending do
describe '.included' do
context 'when a destroy dependent is defined' do
context 'when the model is a subclass' do
context 'when transitive dependents are defined' do
l... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/reflections_spec.rb | spec/mongoid/association/reflections_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Association::Reflections do
class TestClass
include Mongoid::Document
end
let(:klass) do
TestClass
end
before do
klass.relations.clear
end
describe ".reflect_on_association" do
before do
k... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/options_spec.rb | spec/mongoid/association/options_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Association::Options do
STORES_FOREIGN_KEY =
[
Mongoid::Association::Referenced::HasAndBelongsToMany,
Mongoid::Association::Referenced::BelongsTo
]
[
Mongoid::Association::Embedded::EmbeddedIn,
M... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | true |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/has_many_query_spec.rb | spec/mongoid/association/referenced/has_many_query_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './has_many_models'
describe Mongoid::Association::Referenced::HasMany do
context 'when projecting with #only' do
before do
school = HmmSchool.create!(district: 'foo')
HmmStudent.create!(school: school, name: 'Da... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/has_many_spec.rb | spec/mongoid/association/referenced/has_many_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './has_many_models'
describe Mongoid::Association::Referenced::HasMany do
before do
class OwnerObject; include Mongoid::Document; end
class BelongingObject; include Mongoid::Document; end
end
after do
Object.se... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/has_many_models.rb | spec/mongoid/association/referenced/has_many_models.rb | # frozen_string_literal: true
# rubocop:todo all
class HmmCompany
include Mongoid::Document
field :p, type: Integer
has_many :emails, primary_key: :p, foreign_key: :f, class_name: 'HmmEmail'
# The addresses are added with different dependency mechanisms in tests:
#has_many :addresses, class_name: 'HmmAddre... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/belongs_to_query_spec.rb | spec/mongoid/association/referenced/belongs_to_query_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './has_many_models'
describe Mongoid::Association::Referenced::BelongsTo do
context 'when projecting with #only' do
before do
school = HmmSchool.create!(district: 'foo', team: 'Bulldogs')
HmmStudent.create!(schoo... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/has_and_belongs_to_many_spec.rb | spec/mongoid/association/referenced/has_and_belongs_to_many_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative "./has_and_belongs_to_many_models"
describe Mongoid::Association::Referenced::HasAndBelongsToMany do
before do
class HasManyLeftObject; include Mongoid::Document; end
class HasManyRightObject; include Mongoid::Document;... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/belongs_to_models.rb | spec/mongoid/association/referenced/belongs_to_models.rb | # frozen_string_literal: true
# rubocop:todo all
class BTMArticle
include Mongoid::Document
has_many :comments, class_name: "BTMComment"
end
class BTMComment
include Mongoid::Document
belongs_to :article, class_name: "BTMArticle", required: false
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/has_one_spec.rb | spec/mongoid/association/referenced/has_one_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './has_one_models'
describe Mongoid::Association::Referenced::HasOne do
before do
class OwnerObject; include Mongoid::Document; end
class BelongingObject; include Mongoid::Document; end
end
after do
Object.send... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/belongs_to_spec.rb | spec/mongoid/association/referenced/belongs_to_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './has_one_models'
BELONGS_TO_RESOLVER_ID__ = :__belongs_to_resolver_id
BELONGS_TO_RESOLVER = Mongoid::ModelResolver.new
Mongoid::ModelResolver.register_resolver BELONGS_TO_RESOLVER, BELONGS_TO_RESOLVER_ID__
describe Mongoid::Ass... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | true |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/has_one_models.rb | spec/mongoid/association/referenced/has_one_models.rb | # frozen_string_literal: true
# rubocop:todo all
class HomCollege
include Mongoid::Document
has_one :accreditation, class_name: 'HomAccreditation'
# The address is added with different dependency mechanisms in tests:
#has_one :address, class_name: 'HomAddress', dependent: :destroy
field :state, type: Stri... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/has_and_belongs_to_many_models.rb | spec/mongoid/association/referenced/has_and_belongs_to_many_models.rb | # frozen_string_literal: true
# rubocop:todo all
class HabtmmCompany
include Mongoid::Document
field :c_id, type: Integer
field :e_ids, type: Array
has_and_belongs_to_many :employees, class_name: 'HabtmmEmployee',
primary_key: :e_id, foreign_key: :e_ids,
inverse_primary_key: :c_id, inverse_foreign_key... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/has_and_belongs_to_many_query_spec.rb | spec/mongoid/association/referenced/has_and_belongs_to_many_query_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './has_and_belongs_to_many_models'
describe Mongoid::Association::Referenced::HasAndBelongsToMany do
context 'when projecting with #only' do
before do
contract = HabtmmContract.create!(item: 'foo')
contract.signa... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/has_one_query_spec.rb | spec/mongoid/association/referenced/has_one_query_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative './has_one_models'
describe Mongoid::Association::Referenced::HasOne do
context 'when projecting with #only' do
before do
college = HomCollege.create!(state: 'ny')
HomAccreditation.create!(college: college, degre... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/has_and_belongs_to_many/buildable_spec.rb | spec/mongoid/association/referenced/has_and_belongs_to_many/buildable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Association::Referenced::HasAndBelongsToMany::Buildable do
let(:base) do
double
end
let(:options) do
{ }
end
describe "#build" do
let(:documents) do
association.build(base, object)
end
let... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/mongoid/association/referenced/has_and_belongs_to_many/eager_spec.rb | spec/mongoid/association/referenced/has_and_belongs_to_many/eager_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
require_relative '../has_and_belongs_to_many_models'
describe Mongoid::Association::Referenced::HasAndBelongsToMany::Eager do
describe ".keys_from_docs" do
let(:docs) do
Person.all.to_a
end
let!(:person) do
Person.crea... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.