source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/validatable/format_spec.rb
Ruby
mit
3,920
master
1,986
# frozen_string_literal: true 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: [ :brand_name ], with: ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/validatable/uniqueness_spec.rb
Ruby
mit
3,920
master
67,274
# frozen_string_literal: true 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.validates_uniqueness_of :nam...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/validatable/associated_spec.rb
Ruby
mit
3,920
master
4,531
# frozen_string_literal: true 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') end let(:d...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/validatable/numericality_spec.rb
Ruby
mit
3,920
master
3,347
# frozen_string_literal: true require 'spec_helper' describe ActiveModel::Validations::NumericalityValidator do describe '#validate_each' do context 'when allow_blank is false' do let(:model_class) do test_model do field :amount, type: BigDecimal validates_numericality_of :amou...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/validatable/length_spec.rb
Ruby
mit
3,920
master
5,343
# frozen_string_literal: true 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: [ :brand_name ], in: 1....
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/polymorphic_spec.rb
Ruby
mit
3,920
master
3,858
# frozen_string_literal: true 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 stores a foreign key' do ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/depending_spec.rb
Ruby
mit
3,920
master
26,763
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Depending do around do |example| relations_before = Person.relations example.run Person.relations = relations_before end describe '.included' do context 'when a destroy dependent is defined' do context 'whe...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/reflections_spec.rb
Ruby
mit
3,920
master
1,816
# frozen_string_literal: true 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 klass.embeds_many(:add...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/counter_cache_spec.rb
Ruby
mit
3,920
master
9,667
# frozen_string_literal: true 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 before do ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/eager_spec.rb
Ruby
mit
3,920
master
18,067
# frozen_string_literal: true 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) { Account } let(...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/builders_spec.rb
Ruby
mit
3,920
master
7,610
# frozen_string_literal: true 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 person.build_...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/options_spec.rb
Ruby
mit
3,920
master
37,490
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Options do STORES_FOREIGN_KEY = [ Mongoid::Association::Referenced::HasAndBelongsToMany, Mongoid::Association::Referenced::BelongsTo ] [ Mongoid::Association::Embedded::EmbeddedIn, Mongoid::Association:...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/auto_save_spec.rb
Ruby
mit
3,920
master
12,257
# frozen_string_literal: true require 'spec_helper' require_relative 'referenced/has_many_models' require_relative 'referenced/has_one_models' # Models for the MONGOID-5751 regression test: after_save callbacks must not # fire for pre-existing, unchanged documents when autosave: true cascades a # save from a parent t...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/constrainable_spec.rb
Ruby
mit
3,920
master
2,501
# frozen_string_literal: true 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, pre_processed: true, ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/macros_spec.rb
Ruby
mit
3,920
master
27,508
# frozen_string_literal: true 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 klass.validators.c...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/syncable_spec.rb
Ruby
mit
3,920
master
10,628
# frozen_string_literal: true 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 end after(:al...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/accessors_spec.rb
Ruby
mit
3,920
master
25,145
# frozen_string_literal: true 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 person.build_...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/nested/many_spec.rb
Ruby
mit
3,920
master
4,841
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Nested::Many do let(:association) do Person.relations['addresses'] end let(:person) do Person.new end describe '#allow_destroy?' do context 'when the option is provided' do let(:builder) do describ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/nested/one_spec.rb
Ruby
mit
3,920
master
5,254
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Nested::One do let(:association) do Person.relations['name'] end describe '#allow_destroy?' do context 'when the option is provided' do let(:builder) do described_class.new(association, {}, allow_destroy: t...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/belongs_to_query_spec.rb
Ruby
mit
3,920
master
1,810
# frozen_string_literal: true 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!(school: school, name: 'Dav...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_one_query_spec.rb
Ruby
mit
3,920
master
1,145
# frozen_string_literal: true 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, degree: 'cs', year: 2017) ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_one_models.rb
Ruby
mit
3,920
master
2,269
# frozen_string_literal: true 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: String end class HomA...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_and_belongs_to_many_query_spec.rb
Ruby
mit
3,920
master
1,268
# frozen_string_literal: true 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.signatures << HabtmmSignat...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/belongs_to_spec.rb
Ruby
mit
3,920
master
52,608
# frozen_string_literal: true 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::Association::Referenced:...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/belongs_to_models.rb
Ruby
mit
3,920
master
244
# frozen_string_literal: true 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
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_many_spec.rb
Ruby
mit
3,920
master
29,553
# frozen_string_literal: true 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.send(:remove_const, :Bel...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_one_spec.rb
Ruby
mit
3,920
master
32,081
# frozen_string_literal: true 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(:remove_const, :Belon...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_and_belongs_to_many_models.rb
Ruby
mit
3,920
master
2,367
# frozen_string_literal: true 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, ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_and_belongs_to_many_spec.rb
Ruby
mit
3,920
master
25,818
# frozen_string_literal: true 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; end end after do...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_many_query_spec.rb
Ruby
mit
3,920
master
1,095
# frozen_string_literal: true 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: 'Dave', grade: 10) e...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_many_models.rb
Ruby
mit
3,920
master
2,538
# frozen_string_literal: true 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: 'HmmAddress', dependent: :d...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/belongs_to/binding_spec.rb
Ruby
mit
3,920
master
5,148
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Referenced::BelongsTo::Binding do let(:person) do Person.new end let(:game) do Game.new end let(:post) do Post.new end let(:game_association) do Game.relations['person'] end let(:post_association) ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/belongs_to/proxy_spec.rb
Ruby
mit
3,920
master
31,089
# frozen_string_literal: true require 'spec_helper' require 'support/models/canvas' require_relative '../belongs_to_models' describe Mongoid::Association::Referenced::BelongsTo::Proxy do before(:all) do Person.reset_callbacks(:validate) end let(:person) do Person.create! end describe '#=' do c...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/belongs_to/eager_spec.rb
Ruby
mit
3,920
master
10,626
# frozen_string_literal: true require 'spec_helper' require_relative '../has_many_models' require_relative '../has_one_models' describe Mongoid::Association::Referenced::BelongsTo::Eager do describe '.grouped_docs' do let(:docs) do Post.all.to_a end let(:person) do Person.create! end ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/belongs_to/buildable_spec.rb
Ruby
mit
3,920
master
6,238
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Referenced::BelongsTo::Buildable do let(:base) do double end describe '#build' do let(:document) do association.build(base, object) end let(:options) do {} end let(:association) do Mon...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_many/binding_spec.rb
Ruby
mit
3,920
master
2,882
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Referenced::HasMany::Binding do let(:person) do Person.new end let(:post) do Post.new end let(:target) do Mongoid::Association::Referenced::HasMany::Enumerable.new([ post ]) end let(:association) do Per...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_many/buildable_spec.rb
Ruby
mit
3,920
master
5,544
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Referenced::HasMany::Buildable do let(:base) do double end describe '#build' do let(:documents) do association.build(base, object) end let(:options) do {} end let(:association) do Mong...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_many/proxy_query_spec.rb
Ruby
mit
3,920
master
584
# frozen_string_literal: true require 'spec_helper' require_relative '../has_many_models' describe Mongoid::Association::Referenced::HasMany::Proxy do context 'with primary_key and foreign_key given' do let(:company) { HmmCompany.create!(p: 123) } let(:criteria) { company.emails } it 'generates correct...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_many/enumerable_spec.rb
Ruby
mit
3,920
master
55,793
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Referenced::HasMany::Enumerable do describe '#==' do context 'when comparing with an enumerable' do let(:person) do Person.create! end let!(:post) do Post.create!(person_id: person.id) end...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_many/eager_spec.rb
Ruby
mit
3,920
master
8,380
# frozen_string_literal: true require 'spec_helper' require_relative '../has_many_models' describe Mongoid::Association::Referenced::HasMany::Eager do describe '.grouped_docs' do let(:docs) do Person.all.to_a end let(:person) do Person.create! end let(:association) do Person....
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_many/proxy_spec.rb
Ruby
mit
3,920
master
95,628
# frozen_string_literal: true require 'spec_helper' module RefHasManySpec module OverrideInitialize class Parent include Mongoid::Document has_many :children, inverse_of: :parent end class Child include Mongoid::Document belongs_to :parent field :name, type: String ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_persistence_spec.rb
Ruby
mit
3,920
master
2,118
# frozen_string_literal: true require 'spec_helper' require_relative '../has_and_belongs_to_many_models' describe Mongoid::Association::Referenced::HasAndBelongsToMany::Proxy do context 'with primary_key and foreign_key given' do let(:company) { HabtmmCompany.create!(c_id: 123) } let(:employee) { HabtmmEmpl...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb
Ruby
mit
3,920
master
93,568
# frozen_string_literal: true require 'spec_helper' require_relative '../has_and_belongs_to_many_models' describe Mongoid::Association::Referenced::HasAndBelongsToMany::Proxy do config_override :raise_not_found_error, true around do |example| original_preferences_association = Person.relations['preferences']...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_and_belongs_to_many/eager_spec.rb
Ruby
mit
3,920
master
5,435
# frozen_string_literal: true 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.create!(houses: [ house ]...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_and_belongs_to_many/buildable_spec.rb
Ruby
mit
3,920
master
3,209
# frozen_string_literal: true 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(:association) do ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_and_belongs_to_many/binding_spec.rb
Ruby
mit
3,920
master
3,905
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Referenced::HasAndBelongsToMany::Binding do let(:person) do Person.new end let(:preference) do Preference.new end let(:target) do Mongoid::Association::Referenced::HasMany::Enumerable.new([ preference ]) end ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_one/binding_spec.rb
Ruby
mit
3,920
master
2,426
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Referenced::HasOne::Binding do let(:person) do Person.new end let(:game) do Game.new end let(:association) do Person.relations['game'] end describe '#bind_one' do let(:binding) do described_class....
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_one/buildable_spec.rb
Ruby
mit
3,920
master
3,617
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Referenced::HasOne::Buildable do let(:base) do double(new_record?: false) end describe '#build' do let(:document) do association.build(base, object) end let(:options) do {} end let(:associat...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_one/proxy_spec.rb
Ruby
mit
3,920
master
28,655
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Referenced::HasOne::Proxy do describe '#=' do context 'when the relationship is an illegal embedded reference' do let(:game) do Game.new end let(:video) do Video.new end it 'raises ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/referenced/has_one/eager_spec.rb
Ruby
mit
3,920
master
4,453
# frozen_string_literal: true require 'spec_helper' require_relative '../has_one_models' describe Mongoid::Association::Referenced::HasOne::Eager do describe '.grouped_doc' do let(:person) do Person.create! end let(:docs) do Person.all.to_a end let(:association) do Person.ref...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_many_spec.rb
Ruby
mit
3,920
master
21,191
# frozen_string_literal: true require 'spec_helper' require_relative 'embeds_many_models' describe Mongoid::Association::Embedded::EmbedsMany do before do class Container; include Mongoid::Document; end class EmbeddedObject; include Mongoid::Document; end end after do Container.relations.clear ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_one_query_spec.rb
Ruby
mit
3,920
master
830
# frozen_string_literal: true require 'spec_helper' require_relative 'embeds_one_models' describe Mongoid::Association::Embedded::EmbedsOne do context 'when projecting with #only' do before do parent = EomParent.new(name: 'foo') parent.child = EomChild.new(a: 1, b: 2) parent.save! end ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embedded_in_spec.rb
Ruby
mit
3,920
master
23,026
# frozen_string_literal: true require 'spec_helper' require_relative 'embeds_one_models' describe Mongoid::Association::Embedded::EmbeddedIn do before do class Container; include Mongoid::Document; end class EmbeddedObject; include Mongoid::Document; end end after do Object.send(:remove_const, :Con...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_one_spec.rb
Ruby
mit
3,920
master
22,377
# frozen_string_literal: true require 'spec_helper' require_relative 'embeds_one_models' describe Mongoid::Association::Embedded::EmbedsOne do before do class Container; include Mongoid::Document; end class EmbeddedObject; include Mongoid::Document; end end after do Container.relations.clear Em...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_many_models.rb
Ruby
mit
3,920
master
4,975
# frozen_string_literal: true class EmmCongress include Mongoid::Document include Mongoid::Timestamps embeds_many :legislators, class_name: 'EmmLegislator' field :name, type: String end class EmmLegislator include Mongoid::Document embedded_in :congress, class_name: 'EmmCongress' field :a, type: Int...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_many_query_spec.rb
Ruby
mit
3,920
master
1,953
# frozen_string_literal: true require 'spec_helper' require_relative 'embeds_many_models' describe Mongoid::Association::Embedded::EmbedsMany do context 'when projecting with #only' do before do congress = EmmCongress.new(name: 'foo') congress.legislators << EmmLegislator.new(a: 1, b: 2) congr...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_one_dnl_models.rb
Ruby
mit
3,920
master
219
# frozen_string_literal: true # This file is added as an autoload target, but should never be actually # processed. # Marker class - if this class exists, this file was attempted to be required. class EoDnlMarker end
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/cyclic_spec.rb
Ruby
mit
3,920
master
3,791
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Embedded::Cyclic do describe '.recursively_embeds_many' do context 'when the name is inflected easily' do let(:document) do Role.new end it 'creates the parent relation' do expect(document).to r...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/dirty_spec.rb
Ruby
mit
3,920
master
1,425
# frozen_string_literal: true require 'spec_helper' describe 'when initialize a model with an embedded model' do let(:person) do Person.new(pet: Pet.new) end it 'has changes in the embedded model' do expect(person.pet.changes).not_to be_empty end it 'does not have previous_changes in the embedded ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_one_models.rb
Ruby
mit
3,920
master
1,910
# frozen_string_literal: true class EomParent include Mongoid::Document include Mongoid::Timestamps embeds_one :child, class_name: 'EomChild' field :name, type: String end class EomChild include Mongoid::Document embedded_in :parent, class_name: 'EomParent' field :a, type: Integer, default: 0 fiel...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_many/proxy_spec.rb
Ruby
mit
3,920
master
116,346
# frozen_string_literal: true require 'spec_helper' require_relative '../embeds_many_models' describe Mongoid::Association::Embedded::EmbedsMany::Proxy do %i[<< push].each do |method| describe "##{method}" do context 'when the parent is a new record' do let(:person) do Person.new ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_many/buildable_spec.rb
Ruby
mit
3,920
master
4,558
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Embedded::EmbedsMany::Buildable do let(:base) do double end let(:options) do {} end describe '#build' do let(:documents) do association.build(base, object) end let(:association) do Mongoid::...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_many/binding_spec.rb
Ruby
mit
3,920
master
991
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Embedded::EmbedsMany::Binding do let(:person) do Person.new end let(:address) do Address.new end let(:target) do [ address ] end let(:association) do Person.relations['addresses'] end describe '#bi...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_one/binding_spec.rb
Ruby
mit
3,920
master
1,413
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Embedded::EmbedsOne::Binding do let(:person) do Person.new end let(:target) do Name.new end let(:association) do Person.relations['name'] end describe '#bind' do let(:binding) do described_class.n...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_one/buildable_spec.rb
Ruby
mit
3,920
master
1,992
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Embedded::EmbedsOne::Buildable do let(:base) do double end let(:options) do {} end describe '#build' do let(:document) do association.build(base, object) end let(:association) do Mongoid::As...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embeds_one/proxy_spec.rb
Ruby
mit
3,920
master
22,967
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Embedded::EmbedsOne::Proxy do describe '#===' do let(:base) do Person.new end let(:target) do Name.new end let(:association) do Person.relations['name'] end let(:relation) do des...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embedded_in/proxy_spec.rb
Ruby
mit
3,920
master
15,059
# frozen_string_literal: true require 'spec_helper' require_relative '../embeds_many_models' describe Mongoid::Association::Embedded::EmbeddedIn::Proxy do describe '#===' do let(:base) do Name.new end let(:target) do Person.new end let(:association) do Name.relations['namable...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embedded_in/binding_spec.rb
Ruby
mit
3,920
master
3,630
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Embedded::EmbeddedIn::Binding do let(:person) do Person.new end let(:name) do Name.new end let(:address) do Address.new end let(:name_association) do Name.relations['namable'] end let(:address_asso...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/association/embedded/embedded_in/buildable_spec.rb
Ruby
mit
3,920
master
1,729
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Association::Embedded::EmbeddedIn::Buildable do describe '#build' do let(:base) do double end let(:options) do {} end let(:association) do Mongoid::Association::Embedded::EmbeddedIn.new(Person, :addresses, ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/scopable_spec.rb
Ruby
mit
3,920
master
14,083
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Scopable do describe '#apply_default_scope' do context 'when the default scope has options' do let(:scope) do Band.skip(20) end let(:scoped) do Band.all.tap do |criteria| criteria.apply_de...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/modifiable_spec.rb
Ruby
mit
3,920
master
43,819
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Modifiable do describe '#create' do let(:criteria) do Band.where(name: 'Depeche Mode') end context 'when provided valid attributes' do let(:band) do criteria.create!(genres: [ 'electro' ]) end ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/inspectable_spec.rb
Ruby
mit
3,920
master
595
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Inspectable do describe '#inspect' do let(:criteria) do Person.where(:age.gt => 10, title: 'Sir') end it 'includes the selector' do expect(criteria.inspect).to include('selector') end it 'includes the o...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/includable_spec_models.rb
Ruby
mit
3,920
master
1,213
# frozen_string_literal: true class IncUser include Mongoid::Document has_many :posts, class_name: 'IncPost' has_many :comments, class_name: 'IncComment' end class IncAdmin < IncUser field :admin_level, type: Integer end class IncPost include Mongoid::Document belongs_to :user, class_name: 'IncUser' ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/options_spec.rb
Ruby
mit
3,920
master
786
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Options do context 'when a persistence context with options is set on the class of the criteria' do let(:context) do Band.with(connect_timeout: 10) do |klass| klass.where(name: 'FKA Twigs').persistence_context en...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable_mql_spec.rb
Ruby
mit
3,920
master
1,833
# frozen_string_literal:true require 'spec_helper' describe Mongoid::Criteria::Queryable do let(:db) do Mongoid.default_client.database.name end let(:collection) do Band.collection_name.to_s end shared_examples 'translatable to mql' do it 'returns mql' do expect(criteria.to_mql).to eq(mq...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/includable_spec.rb
Ruby
mit
3,920
master
39,150
# frozen_string_literal: true require 'spec_helper' require_relative 'includable_spec_models' describe Mongoid::Criteria::Includable do shared_examples_for 'eager loading' do |method_name| let!(:person) do Person.create!(age: 1) end context 'when providing a name that is not a relation' do ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/findable_spec.rb
Ruby
mit
3,920
master
33,968
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Findable do describe '#find' do context 'when finding by a document' do let(:band) do Band.create!(name: 'Tool') end let!(:record) do band.records.create!(name: 'Undertow') end context...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/marshalable_spec.rb
Ruby
mit
3,920
master
1,085
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Marshalable do describe 'Marshal.dump' do let(:criteria) do Band.where(name: 'Depeche Mode') end it 'does not error' do expect do Marshal.dump(criteria) end.not_to raise_error end end desc...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/translator_spec.rb
Ruby
mit
3,920
master
3,638
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Translator do describe '#to_direction' do context 'when the value is a string' do context 'when ascending' do it 'returns 1' do expect(described_class.to_direction('ascending')).to eq(1) end end...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/key_spec.rb
Ruby
mit
3,920
master
2,390
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Key do describe '#initialize' do let(:key) do described_class.new('field', :__union__, '$all') end it 'sets the name' do expect(key.name).to eq('field') end it 'sets the operator' do ex...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/smash_spec.rb
Ruby
mit
3,920
master
604
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Smash do let(:smash) do described_class.new(ns: :namespace) end describe '#[]' do before do smash.store(:namespace, :default) smash.store(:some_field, 42) end context 'when accessing aliased ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/selectable_spec.rb
Ruby
mit
3,920
master
64,249
# frozen_string_literal: true require 'spec_helper' require_relative 'selectable_shared_examples' class FieldWithSerializer def evolve(object) Integer.evolve(object) end def localized? false end end describe Mongoid::Criteria::Queryable::Selectable do let(:query) do Mongoid::Query.new('id' => ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/aggregable_spec.rb
Ruby
mit
3,920
master
9,151
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Aggregable do let(:query) do Mongoid::Query.new('id' => '_id', 'alias' => 'a') end shared_examples_for 'an aggregable object' do it 'clones the queryable' do expect(aggregation).not_to equal(query) end ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/pipeline_spec.rb
Ruby
mit
3,920
master
4,779
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Pipeline do describe '#__deep_copy' do let(:project) do { '$project' => { 'name' => 1 } } end let(:copied) do pipeline.__deep_copy__ end let(:pipeline) do described_class.new end ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/selector_spec.rb
Ruby
mit
3,920
master
27,549
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Selector do describe 'merge!' do let(:selector) do described_class.new end context 'when selector is nested' do before do selector[:field] = selection selector.merge!(other) end ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/selectable_where_spec.rb
Ruby
mit
3,920
master
14,380
# frozen_string_literal: true require 'spec_helper' require_relative 'selectable_shared_examples' describe Mongoid::Criteria::Queryable::Selectable do let(:query) do Mongoid::Query.new('id' => '_id') end describe '#where' do let(:query_method) { :where } context 'when provided no criterion' do ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/selectable_shared_examples.rb
Ruby
mit
3,920
master
796
# frozen_string_literal: true shared_examples_for 'returns a cloned query' do it 'returns a cloned query' do expect(selection).not_to equal(query) end end shared_examples_for 'requires an argument' do context 'when provided no argument' do let(:selection) do query.send(query_method) end i...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/options_spec.rb
Ruby
mit
3,920
master
9,267
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Options do describe '#__deep_copy__' do let(:sort) do [ %i[name asc] ] end let(:cloned) do options.__deep_copy__ end let(:options) do described_class.new end before do opt...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/optional_spec.rb
Ruby
mit
3,920
master
31,149
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Optional do let(:query) do Mongoid::Query.new end shared_examples_for 'a cloning option' do it 'returns a cloned query' do expect(selection).not_to equal(query) end end %i[asc ascending].each do |m...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/queryable_spec.rb
Ruby
mit
3,920
master
2,717
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Query do describe '#==' do let(:query) do described_class.new end context 'when the objects have the same selector' do let(:other) do described_class.new end context 'when the options are the same' do...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/mergeable_spec.rb
Ruby
mit
3,920
master
4,826
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Mergeable do let(:query) do Mongoid::Query.new end describe '#intersect' do before do query.intersect end it 'sets the strategy to intersect' do expect(query.strategy).to eq(:__intersect__) ...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/expandable_spec.rb
Ruby
mit
3,920
master
1,213
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Expandable do let(:query) do Mongoid::Query.new end describe '#expand_condition_to_array_values' do shared_examples_for 'expands' do it 'expands' do query.send(:expand_condition_to_array_values, cri...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/storable_spec.rb
Ruby
mit
3,920
master
7,004
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Storable do let(:query) do Mongoid::Query.new end shared_examples_for 'logical operator expressions' do context '$and operator' do context '$and to empty query' do let(:modified) do query....
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/selectable_logical_spec.rb
Ruby
mit
3,920
master
75,634
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Selectable do let(:query) do Mongoid::Query.new('id' => '_id') end shared_examples_for 'returns a cloned query' do it 'returns a cloned query' do expect(selection).not_to equal(query) end end # Hoi...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/extensions/time_spec.rb
Ruby
mit
3,920
master
8,403
# frozen_string_literal: true require 'lite_spec_helper' describe Time do describe '.evolve' do context 'when provided a time' do context 'when the time is not in utc' do let(:time) do Time.new(2010, 1, 1, 14, 0, 0, '+02:00') end let(:evolved) do described_clas...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/extensions/regexp_raw_spec.rb
Ruby
mit
3,920
master
1,638
# frozen_string_literal: true require 'spec_helper' describe Mongoid::Criteria::Queryable::Extensions::Regexp::Raw_ do describe '.evolve' do context 'when provided a bson raw regexp' do let(:regexp) do BSON::Regexp::Raw.new('^[123]') end let(:evolved) do BSON::Regexp::Raw.evol...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/extensions/float_spec.rb
Ruby
mit
3,920
master
2,918
# frozen_string_literal: true require 'spec_helper' describe Float do describe '.evolve' do context 'when provided a string' do context 'when the string is a number' do context 'when the string is an integer' do it 'returns a float' do expect(described_class.evolve('1')).to e...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/extensions/date_time_spec.rb
Ruby
mit
3,920
master
8,941
# frozen_string_literal: true require 'spec_helper' describe DateTime do describe '#__evolve_time' do context 'when the date time is not utc' do let(:date) do DateTime.new(2010, 1, 1, 12, 0, 0, '+01:00') end let(:evolved) do date.__evolve_time__ end let(:expected)...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/extensions/set_spec.rb
Ruby
mit
3,920
master
772
# frozen_string_literal: true require 'spec_helper' describe Set do describe '.evolve' do context 'when provided a set' do let(:set) do Set.new([ 1, 2, 3 ]) end it 'returns an array' do expect(described_class.evolve(set)).to eq([ 1, 2, 3 ]) end end context 'when...
github
mongodb/mongoid
https://github.com/mongodb/mongoid
spec/mongoid/criteria/queryable/extensions/symbol_spec.rb
Ruby
mit
3,920
master
2,200
# frozen_string_literal: true require 'spec_helper' describe Symbol do describe '.add_key' do before do described_class.add_key(:fubar, :union, '$fu', '$bar') do |value| value.to_s end end after do Symbol.undef_method(:fubar) end let(:fubar) do :testing.fubar ...