Sha256: af2524280c9e57c1bf7fba9db0d4121a7c9f6e27cc6317bdd7293ad90ae842fa

Contents?: true

Size: 847 Bytes

Versions: 63

Compression:

Stored size: 847 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.local_id = "test002"
          child1.save
          child2.local_id = "test001"
          child2.save
          subject.children << child1
          subject.children << child2
          subject.save
        end
        it "should return the first child as sorted by local ID" do
          expect(subject.first_child).to eq(child2)
        end
      end
    end

  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
ddr-models-2.3.0 spec/models/has_children_spec.rb
ddr-models-3.0.0.alpha.2 spec/models/has_children_spec.rb
ddr-models-3.0.0.alpha.1 spec/models/has_children_spec.rb
ddr-models-2.2.0 spec/models/has_children_spec.rb
ddr-models-2.1.3 spec/models/has_children_spec.rb
ddr-models-2.1.2 spec/models/has_children_spec.rb
ddr-models-2.1.1 spec/models/has_children_spec.rb
ddr-models-2.1.0 spec/models/has_children_spec.rb
ddr-models-2.1.0.rc2 spec/models/has_children_spec.rb
ddr-models-2.1.0.rc1 spec/models/has_children_spec.rb
ddr-models-2.0.1 spec/models/has_children_spec.rb
ddr-models-2.0.0 spec/models/has_children_spec.rb
ddr-models-2.0.0.rc6 spec/models/has_children_spec.rb
ddr-models-2.0.0.rc5 spec/models/has_children_spec.rb
ddr-models-2.0.0.rc4 spec/models/has_children_spec.rb
ddr-models-2.0.0.rc3 spec/models/has_children_spec.rb
ddr-models-2.0.0.rc2 spec/models/has_children_spec.rb
ddr-models-2.0.0.rc1 spec/models/has_children_spec.rb
ddr-models-2.0.0.pre.5 spec/models/has_children_spec.rb
ddr-models-2.0.0.pre.4 spec/models/has_children_spec.rb