Sha256: e77bd4121d025359599e8cfcac5a5be321393da38c6158a34a5856810c95a9fb

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe FeaturedWorkList, :type => :model do
  let(:file1) { FactoryGirl.create(:generic_file) }
  let(:file2) { FactoryGirl.create(:generic_file) }

  before do
    FeaturedWork.create(generic_file_id: file1.noid)
    FeaturedWork.create(generic_file_id: file2.noid)
  end

  after { GenericFile.destroy_all }

  describe 'featured_works' do
    it 'should be a list of the featured work objects, each with the generic_file\'s solr_doc' do
      expect(subject.featured_works.size).to eq 2
      solr_doc = subject.featured_works.first.generic_file_solr_document
      expect(solr_doc).to be_kind_of SolrDocument
      expect(solr_doc.noid).to eq file1.noid 
    end 
  end

  describe 'file deleted' do
    before do
      file1.destroy
    end
    it 'should be a list of the remaining featured work objects, each with the generic_file\'s solr_doc' do
      expect(subject.featured_works.size).to eq 1
      solr_doc = subject.featured_works.first.generic_file_solr_document
      expect(solr_doc).to be_kind_of SolrDocument
      expect(solr_doc.noid).to eq file2.noid
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sufia-5.0.0 spec/models/featured_work_list_spec.rb
sufia-5.0.0.rc1 spec/models/featured_work_list_spec.rb
sufia-4.3.1 spec/models/featured_work_list_spec.rb