piecejusticative file validation focus on size
This commit is contained in:
parent
c155de1d7e
commit
eb46cc6425
7 changed files with 1 additions and 133 deletions
|
@ -207,22 +207,6 @@ feature 'The user' do
|
|||
expect(page).to have_text('RIB.pdf')
|
||||
end
|
||||
|
||||
scenario 'add an invalid attachment', js: true do
|
||||
log_in(user, procedure_with_pjs)
|
||||
fill_individual
|
||||
|
||||
# Test invalid file type
|
||||
attach_file('Pièce justificative 1', Rails.root + 'spec/fixtures/files/invalid_file_format.json')
|
||||
expect(page).to have_text('La pièce justificative n’est pas d’un type accepté')
|
||||
expect(page).to have_no_button('Ré-essayer', visible: true)
|
||||
|
||||
# Replace the file by another with a valid type
|
||||
attach_file('Pièce justificative 1', Rails.root + 'spec/fixtures/files/piece_justificative_0.pdf')
|
||||
expect(page).to have_no_text('La pièce justificative n’est pas d’un type accepté')
|
||||
expect(page).to have_text('analyse antivirus en cours')
|
||||
expect(page).to have_text('piece_justificative_0.pdf')
|
||||
end
|
||||
|
||||
scenario 'add an invalid attachment on an old procedure where pj validation is disabled', js: true do
|
||||
log_in(user, old_procedure_with_disabled_pj_validation)
|
||||
fill_individual
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
RSpec.describe ContentTypeHelper, type: :helper do
|
||||
describe ".file_descriptions_from_content_types" do
|
||||
subject { file_descriptions_from_content_types(content_types) }
|
||||
|
||||
context "when a content-type does not exist" do
|
||||
let(:content_types) { ['invalid content type'] }
|
||||
it { is_expected.to eq("") }
|
||||
end
|
||||
|
||||
context "when a content type is valid" do
|
||||
let(:content_types) { ["application/msword"] }
|
||||
it { is_expected.to eq 'Word' }
|
||||
end
|
||||
|
||||
context "when two content types have the same description" do
|
||||
let(:content_types) { ["application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.ms-excel"] }
|
||||
it { is_expected.to eq 'Excel' }
|
||||
end
|
||||
|
||||
context "when two content types have different descriptions" do
|
||||
let(:content_types) { ["application/msword", "application/vnd.ms-excel"] }
|
||||
it { is_expected.to eq 'Word, Excel' }
|
||||
end
|
||||
end
|
||||
|
||||
describe ".file_extensions_from_content_types" do
|
||||
subject { file_extensions_from_content_types(content_types) }
|
||||
|
||||
context "when a content-type does not exist" do
|
||||
let(:content_types) { ['invalid content type'] }
|
||||
it { is_expected.to eq("") }
|
||||
end
|
||||
|
||||
context "when a content type is valid" do
|
||||
let(:content_types) { ["application/msword"] }
|
||||
it { is_expected.to eq '.doc' }
|
||||
end
|
||||
|
||||
context "when two content types have different extensions" do
|
||||
let(:content_types) { ["application/vnd.ms-excel", "application/msword"] }
|
||||
it { is_expected.to eq '.doc, .xls' }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -22,7 +22,6 @@ describe Champs::PieceJustificativeChamp do
|
|||
|
||||
context "by default" do
|
||||
it { is_expected.to validate_size_of(:piece_justificative_file).less_than(Champs::PieceJustificativeChamp::MAX_SIZE) }
|
||||
it { is_expected.to validate_content_type_of(:piece_justificative_file).allowing(Champs::PieceJustificativeChamp::ACCEPTED_CONTENT_TYPES) }
|
||||
it { expect(champ_pj.type_de_champ.skip_pj_validation).to be_falsy }
|
||||
end
|
||||
|
||||
|
@ -30,7 +29,6 @@ describe Champs::PieceJustificativeChamp do
|
|||
before { champ_pj.type_de_champ.update(skip_pj_validation: true) }
|
||||
|
||||
it { is_expected.not_to validate_size_of(:piece_justificative_file).less_than(Champs::PieceJustificativeChamp::MAX_SIZE) }
|
||||
it { is_expected.not_to validate_content_type_of(:piece_justificative_file).allowing(Champs::PieceJustificativeChamp::ACCEPTED_CONTENT_TYPES) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue