Fix tests involving attachment urls

This commit is contained in:
Paul Chavard 2019-12-19 18:29:01 +01:00
parent 785a09b326
commit c6326bfa77
10 changed files with 14 additions and 13 deletions

View file

@ -209,7 +209,6 @@ describe API::V2::GraphqlController do
checksum
byteSize
contentType
url
}
}
avis {
@ -270,8 +269,7 @@ describe API::V2::GraphqlController do
filename: commentaire.piece_jointe.filename.to_s,
contentType: commentaire.piece_jointe.content_type,
checksum: commentaire.piece_jointe.checksum,
byteSize: commentaire.piece_jointe.byte_size,
url: Rails.application.routes.url_helpers.url_for(commentaire.piece_jointe)
byteSize: commentaire.piece_jointe.byte_size
},
email: commentaire.email
}

View file

@ -17,9 +17,9 @@ describe Instructeurs::DossiersController, type: :controller do
context 'when a dossier has an attestation' do
let(:dossier) { create(:dossier, :accepte, attestation: create(:attestation, :with_pdf), procedure: procedure) }
it 'redirects to attestation pdf' do
it 'redirects to a service tmp_url' do
get :attestation, params: { procedure_id: procedure.id, dossier_id: dossier.id }
expect(response).to redirect_to(dossier.attestation.pdf_url.gsub('http://localhost:3000', ''))
expect(response.location).to match '/rails/active_storage/disk/'
end
end
end

View file

@ -14,7 +14,7 @@ describe NewAdministrateur::MailTemplatesController, type: :controller do
it { expect(response).to have_http_status(:ok) }
it 'displays the procedure logo' do
expect(response.body).to have_css("img[src*='#{procedure.logo_url}']")
expect(response.body).to have_css("img[src*='/rails/active_storage/blobs/']")
end
it 'displays the action buttons' do

View file

@ -145,7 +145,7 @@ describe Users::DossiersController, type: :controller do
it 'redirects to attestation pdf' do
get :attestation, params: { id: dossier.id }
expect(response).to redirect_to(dossier.attestation.pdf_url.gsub('http://localhost:3000', ''))
expect(response.location).to match '/rails/active_storage/disk/'
end
end
end

View file

@ -9,12 +9,12 @@ describe Champs::PieceJustificativeChamp do
context 'when file is safe' do
let(:status) { ActiveStorage::VirusScanner::SAFE }
it { is_expected.to include("/rails/active_storage/blobs/") }
it { is_expected.to include("/rails/active_storage/disk/") }
end
context 'when file is not scanned' do
let(:status) { ActiveStorage::VirusScanner::PENDING }
it { is_expected.to include("/rails/active_storage/blobs/") }
it { is_expected.to include("/rails/active_storage/disk/") }
end
context 'when file is infected' do

View file

@ -14,7 +14,7 @@ describe ChampSerializer do
end
after { champ.piece_justificative_file.purge }
it { is_expected.to include(value: url_for(champ.piece_justificative_file)) }
it { expect(subject[:value]).to match('/rails/active_storage/disk/') }
end
context 'when type champ is not piece justificative' do

View file

@ -79,13 +79,14 @@ describe DossierSerializer do
],
pieces_justificatives: [
{
"content_url" => champ_pj.for_api,
"content_url" => subject[:pieces_justificatives][0]["content_url"],
"created_at" => champ_pj.created_at.in_time_zone('UTC').iso8601(3),
"type_de_piece_justificative_id" => original_pj_id,
"user" => a_hash_including("id" => dossier.user.id)
}
]
)
expect(subject[:pieces_justificatives][0]["content_url"]).to match('/rails/active_storage/disk/')
end
it "does not expose the PJ as a champ" do

View file

@ -150,6 +150,8 @@ RSpec.configure do |config|
Typhoeus::Expectation.clear
ActionMailer::Base.deliveries.clear
ActiveStorage::Current.host = 'http://test.host'
}
RSpec::Matchers.define :have_same_attributes_as do |expected, options|

View file

@ -103,7 +103,7 @@ describe 'instructeurs/dossiers/state_button.html.haml', type: :view do
it 'allows to download the justificatif' do
expect(rendered).to have_dropdown_item('Justificatif')
expect(rendered).to have_link(href: url_for(dossier.justificatif_motivation.attachment.blob))
expect(response).to have_css("a[href*='/rails/active_storage/blobs/']", text: dossier.justificatif_motivation.attachment.filename.to_s)
end
end
end

View file

@ -17,7 +17,7 @@ describe 'users/dossiers/brouillon.html.haml', type: :view do
end
it 'affiche un lien vers la notice' do
expect(rendered).to have_link("Guide de la démarche", href: url_for(procedure.notice))
expect(response).to have_css("a[href*='/rails/active_storage/blobs/']", text: "Guide de la démarche")
end
it 'affiche les boutons de validation' do