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/support/models/pdf_writer.rb | spec/support/models/pdf_writer.rb | # frozen_string_literal: true
# rubocop:todo all
class PdfWriter < Writer
def write; end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/server.rb | spec/support/models/server.rb | # frozen_string_literal: true
# rubocop:todo all
class Server
include Mongoid::Document
field :name, type: String
field :after, type: Mongoid::Boolean, default: false
belongs_to :node
embeds_many :filesystems, validate: false
accepts_nested_attributes_for :filesystems
validates :name, presence: { allow_b... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/bed.rb | spec/support/models/bed.rb | # frozen_string_literal: true
# rubocop:todo all
class Bed; end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/building_address.rb | spec/support/models/building_address.rb | # frozen_string_literal: true
# rubocop:todo all
class BuildingAddress
include Mongoid::Document
field :city, type: String
embedded_in :building
validates_presence_of :city
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/profile.rb | spec/support/models/profile.rb | # frozen_string_literal: true
# rubocop:todo all
class Profile
include Mongoid::Document
field :name, type: String
embeds_one :profile_image
shard_key :name
end
class ProfileImage
include Mongoid::Document
field :url, type: String
embedded_in :profile
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/toy.rb | spec/support/models/toy.rb | # frozen_string_literal: true
# rubocop:todo all
class Toy
include Mongoid::Document
embedded_in :crate
field :name
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/cookie.rb | spec/support/models/cookie.rb | # frozen_string_literal: true
# rubocop:todo all
class Cookie
include Mongoid::Document
include Mongoid::Timestamps::Updated
belongs_to :jar
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/nut.rb | spec/support/models/nut.rb | # frozen_string_literal: true
# rubocop:todo all
class Nut
include Mongoid::Document
belongs_to :hole
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/service.rb | spec/support/models/service.rb | # frozen_string_literal: true
# rubocop:todo all
class Service
include Mongoid::Document
field :sid
field :before_destroy_called, type: Mongoid::Boolean, default: false
field :after_destroy_called, type: Mongoid::Boolean, default: false
field :after_initialize_called, type: Mongoid::Boolean, default: false
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/series.rb | spec/support/models/series.rb | # frozen_string_literal: true
# rubocop:todo all
class Series
include Mongoid::Document
# Must not have dependent: :destroy
has_many :books
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/eye.rb | spec/support/models/eye.rb | # frozen_string_literal: true
# rubocop:todo all
class Eye
include Mongoid::Document
field :pupil_dilation, type: Integer
belongs_to :eyeable, polymorphic: true
belongs_to :suspended_in, polymorphic: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/role.rb | spec/support/models/role.rb | # frozen_string_literal: true
# rubocop:todo all
class Role
include Mongoid::Document
field :name, type: String
belongs_to :user
belongs_to :post
recursively_embeds_many
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/truck.rb | spec/support/models/truck.rb | # frozen_string_literal: true
# rubocop:todo all
class Truck < Vehicle
embeds_one :bed
field :capacity, type: Integer
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/phone.rb | spec/support/models/phone.rb | # frozen_string_literal: true
# rubocop:todo all
class Phone
include Mongoid::Document
field :_id, type: String, overwrite: true, default: ->{ number }
field :number
field :ext, as: :extension
field :landline, type: Boolean
embeds_one :country_code
embedded_in :person
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/learner.rb | spec/support/models/learner.rb | # frozen_string_literal: true
# rubocop:todo all
class Learner < Driver
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/audio.rb | spec/support/models/audio.rb | # frozen_string_literal: true
# rubocop:todo all
class Audio
include Mongoid::Document
field :likes, type: Integer
default_scope ->{ self.or({:likes => nil}, {:likes.gt => 100}) }
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/shop.rb | spec/support/models/shop.rb | # frozen_string_literal: true
# rubocop:todo all
class Shop
include Mongoid::Document
field :title, type: String
has_and_belongs_to_many :followers, inverse_of: :followed_shops, class_name: "User"
belongs_to :user
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/even.rb | spec/support/models/even.rb | # frozen_string_literal: true
# rubocop:todo all
class Even
include Mongoid::Document
field :name
belongs_to :parent, class_name: 'Odd', inverse_of: :evens
has_many :odds, inverse_of: :parent, autosave: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/tool.rb | spec/support/models/tool.rb | # frozen_string_literal: true
# rubocop:todo all
class Tool
include Mongoid::Document
embedded_in :palette
accepts_nested_attributes_for :palette
end
require "support/models/eraser"
require "support/models/pencil"
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/dokument.rb | spec/support/models/dokument.rb | # frozen_string_literal: true
# rubocop:todo all
class Dokument
include Mongoid::Document
include Mongoid::Timestamps
embeds_many :addresses, as: :addressable, validate: false
field :title
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/consumption_period.rb | spec/support/models/consumption_period.rb | # frozen_string_literal: true
# rubocop:todo all
class ConsumptionPeriod
include Mongoid::Document
belongs_to :account
field :started_at, type: Time
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/purse.rb | spec/support/models/purse.rb | # frozen_string_literal: true
class Purse
include Mongoid::Document
field :brand, type: String
embedded_in :person
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/contextable_item.rb | spec/support/models/contextable_item.rb | # frozen_string_literal: true
# rubocop:todo all
class ContextableItem
include Mongoid::Document
field :title
validates :title, presence: true, on: :in_context
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/survey.rb | spec/support/models/survey.rb | # frozen_string_literal: true
# rubocop:todo all
class Survey
include Mongoid::Document
embeds_many :questions
accepts_nested_attributes_for :questions, reject_if: ->(a){ a[:content].blank? }, allow_destroy: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/big_palette.rb | spec/support/models/big_palette.rb | # frozen_string_literal: true
# rubocop:todo all
class BigPalette < Palette
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/store_as_dup_test2.rb | spec/support/models/store_as_dup_test2.rb | # frozen_string_literal: true
# rubocop:todo all
class StoreAsDupTest2
include Mongoid::Document
embedded_in :store_as_dup_test1
field :name
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/augmentation.rb | spec/support/models/augmentation.rb | # frozen_string_literal: true
# rubocop:todo all
class Augmentation
include Mongoid::Document
field :name
embedded_in :player, inverse_of: :augmentation
after_build do
self.name = "Infolink (#{player.frags})"
end
field :after_find_player
field :after_initialize_player
field :after_default_playe... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/princess.rb | spec/support/models/princess.rb | # frozen_string_literal: true
# rubocop:todo all
class Princess
include Mongoid::Document
field :primary_color
field :name, type: String
def color
primary_color.to_s
end
validates_presence_of :color
validates :name, presence: true, on: :update
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/person.rb | spec/support/models/person.rb | # frozen_string_literal: true
# rubocop:todo all
class Person
include Mongoid::Document
include Mongoid::Attributes::Dynamic
attr_accessor :mode
class_attribute :somebody_elses_important_class_options
self.somebody_elses_important_class_options = { keep_me_around: true }
field :username, default: -> { "a... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/spacer.rb | spec/support/models/spacer.rb | # frozen_string_literal: true
# rubocop:todo all
class Spacer
include Mongoid::Document
belongs_to :hole
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/bus.rb | spec/support/models/bus.rb | # frozen_string_literal: true
# rubocop:todo all
class Bus
include Mongoid::Document
field :saturday, type: Mongoid::Boolean, default: false
field :departure_time, type: Time
field :number, type: Integer
embedded_in :circuit
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/shirt.rb | spec/support/models/shirt.rb | # frozen_string_literal: true
# rubocop:todo all
class Shirt
include Mongoid::Document
field :color, type: String
unalias_attribute :id
field :id, type: String
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/artwork.rb | spec/support/models/artwork.rb | # frozen_string_literal: true
# rubocop:todo all
class Artwork
include Mongoid::Document
has_and_belongs_to_many :exhibitors
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/shipment_address.rb | spec/support/models/shipment_address.rb | # frozen_string_literal: true
# rubocop:todo all
class ShipmentAddress < Address
field :shipping_name, localize: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/image.rb | spec/support/models/image.rb | # frozen_string_literal: true
# rubocop:todo all
class Image
attr_reader :name
def initialize(name)
@name = name
end
def self.demongoize(value)
Image.new(value)
end
def mongoize
name
end
def hash_is_hash
{}.is_a?(Hash)
end
end
class Thumbnail < Image
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/delegating_patient.rb | spec/support/models/delegating_patient.rb | # frozen_string_literal: true
# rubocop:todo all
class DelegatingPatient
include Mongoid::Document
embeds_one :email
# Instance level delegation
delegate :address, to: :email
class << self
# Class level delegation
delegate :default_client, to: ::Mongoid
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/eraser.rb | spec/support/models/eraser.rb | # frozen_string_literal: true
# rubocop:todo all
class Eraser < Tool; end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/circus.rb | spec/support/models/circus.rb | # frozen_string_literal: true
# rubocop:todo all
class Circus
include Mongoid::Document
field :name
field :slogan
validates_uniqueness_of :slogan, allow_blank: true
embeds_many :animals
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/lat_lng.rb | spec/support/models/lat_lng.rb | # frozen_string_literal: true
# rubocop:todo all
class LatLng
attr_accessor :lat, :lng
def self.demongoize(object)
return if object.nil?
LatLng.new(object[1], object[0])
end
def initialize(lat, lng)
@lat, @lng = lat, lng
end
def mongoize
[ lng, lat ]
end
def ==(other)
lat == ot... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/filesystem.rb | spec/support/models/filesystem.rb | # frozen_string_literal: true
# rubocop:todo all
class Filesystem
include Mongoid::Document
include Mongoid::Attributes::Dynamic
embedded_in :server
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/alert.rb | spec/support/models/alert.rb | # frozen_string_literal: true
# rubocop:todo all
class Alert
include Mongoid::Document
field :message, type: String
belongs_to :account
has_many :items
belongs_to :post
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/wiki_page.rb | spec/support/models/wiki_page.rb | # frozen_string_literal: true
# rubocop:todo all
class WikiPage
include Mongoid::Document
include Mongoid::Timestamps
field :title, type: String
field :transient_property, type: String
field :author, type: String
field :description, type: String, localize: true
embeds_many :edits, validate: false
# M... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/song.rb | spec/support/models/song.rb | # frozen_string_literal: true
# rubocop:todo all
class Song
include Mongoid::Document
field :title
embedded_in :artist
attr_accessor :before_add_called
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/short_quiz.rb | spec/support/models/short_quiz.rb | # frozen_string_literal: true
# rubocop:todo all
class ShortQuiz
include Mongoid::Document
include Mongoid::Timestamps::Created::Short
field :name, type: String
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/ghost.rb | spec/support/models/ghost.rb | # frozen_string_literal: true
# rubocop:todo all
class Ghost
include Mongoid::Document
field :name, type: String
belongs_to :movie, autosave: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/album.rb | spec/support/models/album.rb | # frozen_string_literal: true
# rubocop:todo all
class Album
include Mongoid::Document
belongs_to :artist
before_destroy :set_parent_name
attr_accessor :before_add_called
private
def set_parent_name
artist.name = "destroyed" if artist
end
def set_parent_name_fail
throw(:abort)
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/breed.rb | spec/support/models/breed.rb | # frozen_string_literal: true
# rubocop:todo all
class Breed
include Mongoid::Document
has_and_belongs_to_many :dogs
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/label.rb | spec/support/models/label.rb | # frozen_string_literal: true
# rubocop:todo all
class Label
include Mongoid::Document
include Mongoid::Timestamps::Updated::Short
field :name, type: String
field :sales, type: BigDecimal
field :age, type: Integer
field :after_create_called, type: Mongoid::Boolean, default: false
field :after_save_call... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/topping.rb | spec/support/models/topping.rb | # frozen_string_literal: true
# rubocop:todo all
class Topping
include Mongoid::Document
field :name, type: String
belongs_to :pizza
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/fruits.rb | spec/support/models/fruits.rb | # frozen_string_literal: true
# rubocop:todo all
module Fruits
class Apple
include Mongoid::Document
has_many :bananas, class_name: "Fruits::Banana"
has_many :fruits_melons, class_name: "Fruits::Melon"
recursively_embeds_many
end
class Banana
include Mongoid::Document
belongs_to :apple, ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/company.rb | spec/support/models/company.rb | # frozen_string_literal: true
# rubocop:todo all
class Company
include Mongoid::Document
embeds_many :staffs
has_many :products
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/html_writer.rb | spec/support/models/html_writer.rb | # frozen_string_literal: true
# rubocop:todo all
class HtmlWriter < Writer
def write; end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/cat.rb | spec/support/models/cat.rb | # frozen_string_literal: true
# rubocop:todo all
class Cat
include Mongoid::Document
field :name
belongs_to :person, primary_key: :username
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/id_key.rb | spec/support/models/id_key.rb | # frozen_string_literal: true
# rubocop:todo all
class IdKey
include Mongoid::Document
field :key
alias_method :id, :key
alias_method :id=, :key=
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/user.rb | spec/support/models/user.rb | # frozen_string_literal: true
# rubocop:todo all
class User
include Mongoid::Document
field :name
field :last_login, type: DateTime
field :account_expires, type: Date
has_one :account, foreign_key: :creator_id, validate: false
has_many :posts, foreign_key: :author_id, validate: false
has_many :descript... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/edit.rb | spec/support/models/edit.rb | # frozen_string_literal: true
# rubocop:todo all
class Edit
include Mongoid::Document
include Mongoid::Timestamps::Updated
embedded_in :wiki_page, touch: true
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/coding/pull_request.rb | spec/support/models/coding/pull_request.rb | # frozen_string_literal: true
# rubocop:todo all
module Coding
class PullRequest
include Mongoid::Document
field :title, type: String
has_many :reviews, class_name: 'Publication::Review', as: :reviewable
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/publication/review.rb | spec/support/models/publication/review.rb | # frozen_string_literal: true
# rubocop:todo all
module Publication
class Review
include Mongoid::Document
field :summary
belongs_to :reviewable, polymorphic: true
belongs_to :reviewer, polymorphic: true
belongs_to :template
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/publication/encyclopedia.rb | spec/support/models/publication/encyclopedia.rb | # frozen_string_literal: true
# rubocop:todo all
module Publication
class Encyclopedia
include Mongoid::Document
field :title, type: String
has_many :reviews, class_name: 'Publication::Review', as: :reviewable
end
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/sandbox/sandbox_user.rb | spec/support/models/sandbox/sandbox_user.rb | # rubocop:todo all
class SandboxUser
include Mongoid::Document
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/sandbox/sandbox_message.rb | spec/support/models/sandbox/sandbox_message.rb | # rubocop:todo all
class SandboxMessage
include Mongoid::Document
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/sandbox/app/models/app_models_message.rb | spec/support/models/sandbox/app/models/app_models_message.rb | # rubocop:todo all
class AppModelsMessage
include Mongoid::Document
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/sandbox/lib/models/lib_models_message.rb | spec/support/models/sandbox/lib/models/lib_models_message.rb | # rubocop:todo all
class LibModelsMessage
include Mongoid::Document
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/models/sandbox/subdir/sandbox_comment.rb | spec/support/models/sandbox/subdir/sandbox_comment.rb | # rubocop:todo all
class SandboxComment
include Mongoid::Document
end
| ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/crypt/models.rb | spec/support/crypt/models.rb | # rubocop:todo all
module Crypt
class Patient
include Mongoid::Document
encrypt_with key_id: "grolrnFVSSW9Gq04Q87R9Q=="
field :code, type: String
field :medical_records, type: Array, encrypt: { deterministic: false}
field :blood_type, type: String, encrypt: {
deterministic: false,
ke... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/support/shared/time.rb | spec/support/shared/time.rb | # frozen_string_literal: true
# rubocop:todo all
shared_context 'setting ActiveSupport time zone' do
time_zone_override 'Tokyo'
end
shared_examples_for 'mongoizes to AS::TimeWithZone' do
it 'is an AS::TimeWithZone' do
expect(mongoized.class).to eq(ActiveSupport::TimeWithZone)
end
it 'is equal to expected... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/callbacks_spec.rb | spec/integration/callbacks_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
require_relative './callbacks_models'
describe 'callbacks integration tests' do
context 'when modifying attributes in a callback' do
context 'when creating top-level document' do
context 'top level document' do
let(:instance) ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/stringified_symbol_field_spec.rb | spec/integration/stringified_symbol_field_spec.rb | # rubocop:todo all
require "spec_helper"
describe "StringifiedSymbol fields" do
before do
Order.destroy_all
end
context "when querying the database" do
let!(:document) do
Order.create!(saved_status: :test)
end
let(:string_query) do
{'saved_status' => {'$eq' => 'test'}}
end
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/server_query_spec.rb | spec/integration/server_query_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
# This file serves as a record of server query behavior.
describe 'Server queries' do
context 'scalar operator on scalar field' do
let!(:document) do
Survey.create!(
questions: [Question.new(
answers: [Answer.new(po... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/isolation_state_spec.rb | spec/integration/isolation_state_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Mongoid::Config.isolation_level' do
def thread_operation(value)
Thread.new do
Mongoid::Threaded.stack(:testing) << value
yield if block_given?
Mongoid::Threaded.stack(:testing)
end.join.value
end
def fibe... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/encryption_spec.rb | spec/integration/encryption_spec.rb | # rubocop:todo all
require 'spec_helper'
require 'support/crypt/models'
describe 'Encryption' do
require_enterprise
require_libmongocrypt
include_context 'with encryption'
restore_config_clients
let(:config) do
{
default: { hosts: SpecConfig.instance.addresses, database: database_id },
key_v... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/discriminator_value_spec.rb | spec/integration/discriminator_value_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe "#discriminator_key" do
context "when the discriminator value is not set on a class" do
let(:piano) do
Piano.new
end
let(:guitar) do
Guitar.new
end
it "sets the child discriminator key to _typ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/document_spec.rb | spec/integration/document_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe Mongoid::Document do
context 'when including class uses delegate' do
let(:patient) do
DelegatingPatient.new(
email: Email.new(address: 'test@example.com'),
)
end
it 'works for instance level delegation' ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/bson_regexp_raw_spec.rb | spec/integration/bson_regexp_raw_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe BSON::Regexp::Raw do
context 'fully qualified name' do
it 'can be created' do
regexp = BSON::Regexp::Raw.new('foo')
regexp.pattern.should == 'foo'
end
end
context 'via ::Regexp' do
it 'can be created' do
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/matcher_examples_spec.rb | spec/integration/matcher_examples_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
# Some of these tests duplicate the tests in matcher_operator_spec.rb.
# The tests in this file are retained because they use model instances
# rather than simple hashes as the YAML tests do, hence in theory these tests
# could provide additional ... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/matcher_spec.rb | spec/integration/matcher_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Matcher operators' do
let(:result) do
document._matches?(query)
end
shared_examples 'is true' do
it 'is true' do
result.should be true
end
end
shared_examples 'is false' do
it 'is false 'do
result.... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/i18n_fallbacks_spec.rb | spec/integration/i18n_fallbacks_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'i18n fallbacks' do
require_fallbacks
context 'when fallbacks are enabled with a locale list' do
with_default_i18n_configs
before do
I18n.fallbacks[:de] = [ :en ]
end
context 'when translation is present in ac... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/shardable_spec.rb | spec/integration/shardable_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
require_relative '../mongoid/shardable_models'
describe 'Sharding helpers' do
require_topology :sharded
min_server_version '4.4'
describe 'shard_collection rake task' do
let(:shard_collections) do
Mongoid::Tasks::Database.shard_co... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/dots_and_dollars_spec.rb | spec/integration/dots_and_dollars_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe "Dots and Dollars" do
min_server_version '5.0'
before(:all) do
class DADMUser
include Mongoid::Document
field :"first.last", type: String, default: "Neil.Shweky"
field :"$_amount", type: Integer, default: 0
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/discriminator_key_spec.rb | spec/integration/discriminator_key_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe "#discriminator_key" do
context "when the discriminator key is not set on a class" do
let(:piano) do
Piano.new
end
let(:guitar) do
Guitar.new
end
it "sets the child discriminator key to _type: Piano" d... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/caching_spec.rb | spec/integration/caching_spec.rb | # frozen_string_literal: true
require 'spec_helper'
describe 'caching integration tests' do
let(:store) { ActiveSupport::Cache::MemoryStore.new }
context 'without updated_at' do
let(:model1) { Person.create }
let(:model2) { Person.create }
before do
store.write(model1, 'model1')
store.wr... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/active_job_spec.rb | spec/integration/active_job_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
begin
require 'active_job'
require 'mongoid/railties/bson_object_id_serializer'
describe 'ActiveJob Serialization' do
skip unless defined?(ActiveJob)
class TestBsonObjectIdSerializerJob < ActiveJob::Base
def perform(*args)
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/callbacks_models.rb | spec/integration/callbacks_models.rb | # rubocop:todo all
class Galaxy
include Mongoid::Document
include Mongoid::Timestamps
field :age, type: Integer
field :was_touched, type: Mongoid::Boolean, default: false
before_validation :set_age
embeds_many :stars
set_callback(:touch, :before) do |document|
self.was_touched = true
end
priva... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/app_spec.rb | spec/integration/app_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
BASE = File.join(File.dirname(__FILE__), '../..')
TMP_BASE = File.join(BASE, 'tmp')
def check_call(cmd, **opts)
puts "Executing #{cmd.join(' ')}"
Mrss::ChildProcessHelper.check_call(cmd, **opts)
end
def gem_version_argument(version)
"_#{ve... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/matcher_operator_spec.rb | spec/integration/matcher_operator_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
def mop_error?(spec, kind)
unless %w(matcher driver dsl).include?(kind)
raise ArgumentError, "Bogus kind: #{kind}"
end
spec['error'] == true || spec['error'] == kind ||
spec['error'].is_a?(Array) && spec['error'].include?(kind)
end
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/atomic/modifiers_spec.rb | spec/integration/atomic/modifiers_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongoid::Atomic::Modifiers do
let(:modifiers) do
described_class.new
end
context 'when performing multiple operations with similar keys' do
let(:pushes) do
{ "addresses.0.locations" => { "street" => "Bond St" } }
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/contextual/empty_spec.rb | spec/integration/contextual/empty_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Contextual classes when dealing with empty result set' do
shared_examples 'behave as expected' do
context '#exists?' do
it 'is false' do
context.exists?.should be false
end
end
context '#count' do
... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/persistence/range_field_spec.rb | spec/integration/persistence/range_field_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Range field persistence' do
let!(:person) { Person.create!(field => value).reload }
subject { person.send(field) }
let(:now_utc) { Time.now }
let(:later_utc) { now_utc + 10.minutes }
let(:now_in_zone) { now_utc.in_time_zone('As... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/persistence/collection_options_spec.rb | spec/integration/persistence/collection_options_spec.rb | # frozen_string_literal: true
require 'spec_helper'
# rubocop:disable RSpec/LeakyConstantDeclaration
# rubocop:disable Lint/ConstantDefinitionInBlock
describe 'Collection options' do
before(:all) do
class CollectionOptionsCapped
include Mongoid::Document
store_in collection_options: {
cappe... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/criteria/default_scope_spec.rb | spec/integration/criteria/default_scope_spec.rb | # rubocop:todo all
require 'spec_helper'
describe 'Criteria and default scope' do
context 'order in query' do
let(:query) do
Acolyte.order(status: :desc)
end
let(:sort_options) do
query.options[:sort]
end
it 'is added after order of default scope' do
sort_options.should == {'... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/criteria/logical_spec.rb | spec/integration/criteria/logical_spec.rb | # rubocop:todo all
require 'spec_helper'
describe 'Criteria logical operations' do
let!(:ap) { Band.create!(name: 'Astral Projection', origin: 'SFX', genres: ['Goa', 'Psy']) }
let!(:im) { Band.create!(name: 'Infected Mushroom', origin: 'Computers', genres: ['Psy']) }
let!(:sp) { Band.create!(name: 'Sun Project',... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/criteria/date_field_spec.rb | spec/integration/criteria/date_field_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Queries on Date fields' do
let(:query) do
Band.where(founded: arg)
end
let(:selector) { query.selector }
shared_examples 'converts to beginning of day in UTC' do
it 'converts to beginning of day in UTC' do
selecto... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/criteria/raw_value_spec.rb | spec/integration/criteria/raw_value_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Queries with Mongoid::RawValue criteria' do
let(:now_utc) { Time.utc(2020, 1, 1, 16, 0, 0, 0) }
let(:today) { Date.new(2020, 1, 1) }
let(:labels) do
[ Label.new(age: 12), Label.new(age: 16) ]
end
let!(:band1) { Band.creat... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/criteria/alias_query_spec.rb | spec/integration/criteria/alias_query_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'distinct on aliased fields' do
let(:client) { Person.collection.client }
let(:subscriber) do
Mrss::EventSubscriber.new
end
before do
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
end
after do
client... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/criteria/range_spec.rb | spec/integration/criteria/range_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Queries with Range criteria' do
let(:now_utc) { Time.utc(2020, 1, 1, 16, 0, 0, 0) }
let(:now_in_zone) { now_utc.in_time_zone('Asia/Tokyo') }
let(:today) { Date.new(2020, 1, 1) }
let(:labels) do
[ Label.new(age: 12), Label.ne... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/criteria/time_with_zone_spec.rb | spec/integration/criteria/time_with_zone_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'TimeWithZone in queries' do
let(:now_utc) { Time.now.utc }
let(:now_in_zone) { now_utc.in_time_zone(time_zone) }
shared_examples_for 'time zone queries' do
let!(:book_earlier) { Book.create!(updated_at: now_utc - 20.minutes, d... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/reverse_population_spec_models.rb | spec/integration/associations/reverse_population_spec_models.rb | # frozen_string_literal: true
# rubocop:todo all
module ReversePopulationSpec
class Company
include Mongoid::Document
has_many :emails, class_name: 'ReversePopulationSpec::Email'
has_one :founder, class_name: 'ReversePopulationSpec::Founder'
end
class Email
include Mongoid::Document
belong... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/embedded_dirty_spec.rb | spec/integration/associations/embedded_dirty_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
describe 'dirty tracking' do
context 'when association is cy... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/has_many_spec.rb | spec/integration/associations/has_many_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
require 'mongoid/association/referenced/has_many_models'
describe 'has_many associations' do
context 'destroying parent in transaction with dependent child' do
require_transaction_support
let(:company) { HmmCompany.create! }
let(:ad... | ruby | MIT | 780b2fd823670611d49b3470d6b492e2a19dacf5 | 2026-01-04T15:47:58.642616Z | false |
mongodb/mongoid | https://github.com/mongodb/mongoid/blob/780b2fd823670611d49b3470d6b492e2a19dacf5/spec/integration/associations/reverse_population_spec.rb | spec/integration/associations/reverse_population_spec.rb | # frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
require_relative './reverse_population_spec_models'
describe 'Association reverse population' do
describe 'has_many/belongs_to' do
it 'populates child in parent' do
company = ReversePopulationSpec::Company.create!
email = Reverse... | 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.