diff --git a/spec/controllers/api/v2/graphql_controller_spec.rb b/spec/controllers/api/v2/graphql_controller_spec.rb index 9192325a6..d92e06160 100644 --- a/spec/controllers/api/v2/graphql_controller_spec.rb +++ b/spec/controllers/api/v2/graphql_controller_spec.rb @@ -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 } diff --git a/spec/controllers/instructeurs/dossiers_controller_spec.rb b/spec/controllers/instructeurs/dossiers_controller_spec.rb index db3e30ef0..264d68ae3 100644 --- a/spec/controllers/instructeurs/dossiers_controller_spec.rb +++ b/spec/controllers/instructeurs/dossiers_controller_spec.rb @@ -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 diff --git a/spec/controllers/new_administrateur/mail_templates_controller_spec.rb b/spec/controllers/new_administrateur/mail_templates_controller_spec.rb index b93d4857c..527dc11d7 100644 --- a/spec/controllers/new_administrateur/mail_templates_controller_spec.rb +++ b/spec/controllers/new_administrateur/mail_templates_controller_spec.rb @@ -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 diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 72c7833b6..f9fd181b5 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -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 diff --git a/spec/models/champs/piece_justificative_champ_spec.rb b/spec/models/champs/piece_justificative_champ_spec.rb index 4b38613d0..506eba015 100644 --- a/spec/models/champs/piece_justificative_champ_spec.rb +++ b/spec/models/champs/piece_justificative_champ_spec.rb @@ -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 diff --git a/spec/serializers/champ_serializer_spec.rb b/spec/serializers/champ_serializer_spec.rb index 07ff5e10e..602356312 100644 --- a/spec/serializers/champ_serializer_spec.rb +++ b/spec/serializers/champ_serializer_spec.rb @@ -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 diff --git a/spec/serializers/dossier_serializer_spec.rb b/spec/serializers/dossier_serializer_spec.rb index 54c29b033..f40d45186 100644 --- a/spec/serializers/dossier_serializer_spec.rb +++ b/spec/serializers/dossier_serializer_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 655686eb2..538b95806 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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| diff --git a/spec/views/instructeur/dossiers/_state_button.html.haml_spec.rb b/spec/views/instructeur/dossiers/_state_button.html.haml_spec.rb index 048b8b7bb..1ee153818 100644 --- a/spec/views/instructeur/dossiers/_state_button.html.haml_spec.rb +++ b/spec/views/instructeur/dossiers/_state_button.html.haml_spec.rb @@ -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 diff --git a/spec/views/users/dossiers/brouillon.html.haml_spec.rb b/spec/views/users/dossiers/brouillon.html.haml_spec.rb index 5a1802c1e..dc13af78a 100644 --- a/spec/views/users/dossiers/brouillon.html.haml_spec.rb +++ b/spec/views/users/dossiers/brouillon.html.haml_spec.rb @@ -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