Sha256: 5b223074381f4a739884af97b9594ca88fdbf2d1f99dce50fa671b55d19db0bc
Contents?: true
Size: 758 Bytes
Versions: 27
Compression:
Stored size: 758 Bytes
Contents
# frozen_string_literal: true # encoding: utf-8 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 let(:parent) do EomParent.where(name: 'foo').only(:name, 'child._id', 'child.a').first end it 'populates specified fields only' do expect(parent.child.a).to eq(1) # has a default value specified in the model expect do parent.child.b end.to raise_error(ActiveModel::MissingAttributeError) expect(parent.child.attributes.keys).to eq(['_id', 'a']) end end end
Version data entries
27 entries across 27 versions & 2 rubygems