Sha256: c3605460ad8e4e8241134cc5b206d3302db165f5f86d12a2921c694b37e18c21

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 KB

Contents

RSpec.describe Item, type: :model do

  it_behaves_like "a DDR model"
  it_behaves_like "it has an association", :belongs_to, :parent, :is_member_of_collection, "Collection"
  it_behaves_like "it has an association", :has_many, :children, :is_part_of, "Component"
  it_behaves_like "a non-collection model"
  it_behaves_like "a potentially publishable object"

  describe "indexing text" do
    let(:children) { FactoryGirl.build_list(:component, 5) }

    let(:text1) { fixture_file_upload('extractedText1.txt', 'text/plain') }
    let(:text2) { fixture_file_upload('extractedText2.txt', 'text/plain') }
    let(:text3) { fixture_file_upload('extractedText3.txt', 'text/plain') }

    before {
      children[0].extractedText.content = text1
      children[0].save!
      children[1].extractedText.content = text2
      children[1].save!
      children[2].extractedText.content = text3
      children[2].save!
      children[3].save!
      children[4].save!
      subject.children = children
      subject.save!
    }

    it "indexes the combined text of its children" do
      expect(subject.index_fields[Ddr::Index::Fields::ALL_TEXT]).to contain_exactly(File.read(text1.path), File.read(text2.path), File.read(text3.path))
    end
  end

  describe "content" do
    its(:can_have_content?) { is_expected.to be false }
    it { is_expected.to_not have_content }
  end

  describe "children" do
    its(:can_have_children?) { is_expected.to be true }
    it { is_expected.to_not have_children }
    specify {
      subject.children << Component.new
      expect(subject).to have_children
    }
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ddr-models-2.7.6 spec/models/item_spec.rb
ddr-models-2.7.5 spec/models/item_spec.rb
ddr-models-2.7.4 spec/models/item_spec.rb
ddr-models-2.7.3 spec/models/item_spec.rb
ddr-models-2.7.2 spec/models/item_spec.rb
ddr-models-2.7.1 spec/models/item_spec.rb
ddr-models-2.7.0 spec/models/item_spec.rb
ddr-models-2.7.0.rc1 spec/models/item_spec.rb