Sha256: d32f59628d354aaa248273681a9dd983540d816f8853f345dd08e4a1e141e0f0

Contents?: true

Size: 869 Bytes

Versions: 3

Compression:

Stored size: 869 Bytes

Contents

module Ddr::Models
  RSpec.describe HasChildren do 

    subject { FactoryGirl.create(:collection) }

    describe "#first_child" do
      describe "when the object has no children" do
        it "should return nil" do
          expect(subject.first_child).to be_nil
        end
      end
      describe "when the object has children" do
        let(:child1) { FactoryGirl.create(:item) }
        let(:child2) { FactoryGirl.create(:item) }
        before do
          child1.identifier = ["test002"]
          child1.save
          child2.identifier = ["test001"]
          child2.save          
          subject.children << child1
          subject.children << child2
          subject.save
        end
        it "should return the first child as sorted by identifiers" do
          expect(subject.first_child).to eq(child2)
        end
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ddr-models-1.13.2 spec/models/has_children_spec.rb
ddr-models-1.13.1 spec/models/has_children_spec.rb
ddr-models-1.13.0 spec/models/has_children_spec.rb