demarches-normaliennes/spec/models/export_item_spec.rb

23 lines
736 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2024-07-18 09:57:23 +02:00
describe ExportItem do
describe 'path' do
let(:export_item) { ExportItem.default(prefix: 'custom') }
let(:dossier) { create(:dossier) }
let(:attachment) do
ActiveStorage::Attachment.new(
name: 'filename',
blob: ActiveStorage::Blob.new(filename: "file.pdf")
)
end
context 'without index nor row_index' do
it do
expect(export_item.path(dossier, attachment:)).to eq("custom-#{dossier.id}.pdf")
expect(export_item.path(dossier, attachment:, index: 3)).to eq("custom-#{dossier.id}-04.pdf")
expect(export_item.path(dossier, attachment:, row_index: 2, index: 3)).to eq("custom-#{dossier.id}-03-04.pdf")
end
end
end
end