Sha256: 2c43d4829d0134eb455965e4315ed5d7ff24e0195ad7f4fd00a136c89d77007f

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Spotlight::BulkUpdatesCsvTemplateService do
  subject(:service) { described_class.new(exhibit: exhibit) }

  let(:exhibit) { FactoryBot.create(:exhibit) }
  let!(:tag1) { FactoryBot.create(:tagging, tagger: exhibit, taggable: exhibit) }
  let!(:tag2) { FactoryBot.create(:tagging, tagger: exhibit, taggable: exhibit) }

  describe '#template' do
    let(:view_context) { double('ViewContext', document_presenter: double('DocumentPresenter', heading: 'Document Title')) }

    it 'has a row for every document (+ the header)' do
      template = CSV.parse(service.template(view_context: view_context).to_a.join)
      expect(template).to have_at_least(56).items
      expect(template[0].join(',')).to match(/Item ID,Item Title,Visibility,Tag: tagging\d,Tag: tagging\d/)
    end

    it 'only has requested columns' do
      template = CSV.parse(service.template(view_context: view_context, tags: false).to_a.join)
      expect(template[0].join(',')).to eq 'Item ID,Item Title,Visibility'
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
blacklight-spotlight-3.4.0 spec/services/spotlight/bulk_updates_csv_template_service_spec.rb
blacklight-spotlight-3.3.0 spec/services/spotlight/bulk_updates_csv_template_service_spec.rb
blacklight-spotlight-3.2.0 spec/services/spotlight/bulk_updates_csv_template_service_spec.rb
blacklight-spotlight-3.1.0 spec/services/spotlight/bulk_updates_csv_template_service_spec.rb
blacklight-spotlight-3.0.3 spec/services/spotlight/bulk_updates_csv_template_service_spec.rb
blacklight-spotlight-3.0.2 spec/services/spotlight/bulk_updates_csv_template_service_spec.rb
blacklight-spotlight-3.0.1 spec/services/spotlight/bulk_updates_csv_template_service_spec.rb
blacklight-spotlight-3.0.0 spec/services/spotlight/bulk_updates_csv_template_service_spec.rb
blacklight-spotlight-3.0.0.rc6 spec/services/spotlight/bulk_updates_csv_template_service_spec.rb
blacklight-spotlight-3.0.0.rc5 spec/services/spotlight/bulk_updates_csv_template_service_spec.rb