Sha256: 2d3f2b7171c6c07301612383ea165e002ce7c399e380de8dc973f654dfec4479
Contents?: true
Size: 1015 Bytes
Versions: 27
Compression:
Stored size: 1015 Bytes
Contents
# frozen_string_literal: true # encoding: utf-8 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 "#bind_one" do let(:binding) do described_class.new(person, target, association) end context "when the document is bindable" do let(:address_two) do Address.new end before do binding.bind_one(address_two) end it "parentizes the document" do expect(address_two._parent).to eq(person) end it "sets the inverse relation" do expect(address_two.addressable).to eq(person) end end context "when the document is not bindable" do it "does nothing" do expect(person.addresses).to receive(:<<).never binding.bind_one(address) end end end end
Version data entries
27 entries across 27 versions & 2 rubygems