diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index 14f04fe45..5c9b7f4ca 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -23,7 +23,8 @@ class Backoffice::DossiersController < Backoffice::DossiersListController end def show - create_dossier_facade params[:id] + dossier_id = params[:id] + create_dossier_facade dossier_id unless @facade.nil? @champs_private = @facade.champs_private @@ -31,7 +32,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController @headers_private = @champs_private.select { |champ| champ.type_champ == 'header_section' } end - Notification.where(dossier_id: params[:id].to_i).update_all already_read: true + Notification.where(dossier_id: dossier_id).update_all already_read: true @new_avis = Avis.new(introduction: "Bonjour, merci de me donner votre avis sur ce dossier.") end diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 169e976d6..7a647f51c 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -97,7 +97,7 @@ describe Backoffice::DossiersController, type: :controller do describe 'all notifications unread are changed' do it do - expect(Notification).to receive(:where).with(dossier_id: dossier_id).and_return(Notification::ActiveRecord_Relation) + expect(Notification).to receive(:where).with(dossier_id: dossier_id.to_s).and_return(Notification::ActiveRecord_Relation) expect(Notification::ActiveRecord_Relation).to receive(:update_all).with(already_read: true).and_return(true) subject