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.6.2 spec/models/has_children_spec.rb
ddr-models-2.6.1 spec/models/has_children_spec.rb
ddr-models-2.6.0 spec/models/has_children_spec.rb
ddr-models-2.6.0.rc4 spec/models/has_children_spec.rb
ddr-models-2.6.0.rc3 spec/models/has_children_spec.rb
ddr-models-2.6.0.rc2 spec/models/has_children_spec.rb
ddr-models-2.6.0.rc1 spec/models/has_children_spec.rb
ddr-models-2.5.3 spec/models/has_children_spec.rb
ddr-models-2.5.2 spec/models/has_children_spec.rb
ddr-models-2.5.1 spec/models/has_children_spec.rb
ddr-models-2.5.0 spec/models/has_children_spec.rb
ddr-models-2.5.0.rc1 spec/models/has_children_spec.rb
ddr-models-2.4.16 spec/models/has_children_spec.rb
ddr-models-2.4.15 spec/models/has_children_spec.rb
ddr-models-2.4.14 spec/models/has_children_spec.rb
ddr-models-2.4.13 spec/models/has_children_spec.rb
ddr-models-2.4.12 spec/models/has_children_spec.rb
ddr-models-2.4.11 spec/models/has_children_spec.rb
ddr-models-2.4.10 spec/models/has_children_spec.rb
ddr-models-2.4.9 spec/models/has_children_spec.rb