demarches-normaliennes/spec/models/export_item_spec.rb
2024-07-26 13:31:06 +02:00

20 lines
705 B
Ruby

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