Sha256: 0978cfb1c243320d733791b0905a81b965894d32e34a783a871369dc86311d34
Contents?: true
Size: 1.12 KB
Versions: 29
Compression:
Stored size: 1.12 KB
Contents
# 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) end let(:college) do HomCollege.where(state: 'ny').only('accreditation._id', 'accreditation.degree').first end let(:accreditation) { college.accreditation } it 'populates specified fields only' do pending 'https://jira.mongodb.org/browse/MONGOID-4704' expect(accreditation.degree).to eq('cs') # has a default value specified in the model expect do accreditation.year end.to raise_error(ActiveModel::MissingAttributeError) expect(legislator.attributes.keys).to eq(['_id', 'degree']) end # Delete this test when https://jira.mongodb.org/browse/MONGOID-4704 is # implemented and above test is unpended it 'fetches all fields' do expect(accreditation.degree).to eq('cs') expect(accreditation.year).to eq(2017) end end end
Version data entries
29 entries across 29 versions & 1 rubygems