Skip to content

Commit

Permalink
revoke superadmin dossier transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
krichtof committed Nov 28, 2023
1 parent e8fb249 commit fc74367
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/manager/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def transfer
redirect_to manager_dossier_path(params[:id])
end

def transfer_destroy
dossier = Dossier.find(params[:id])
dossier.transfer.destroy_and_nullify
redirect_to manager_dossier_path(dossier), notice: t("users.dossiers.transferer.destroy")
end

private

def unfiltered_list?
Expand Down
8 changes: 8 additions & 0 deletions app/views/manager/dossiers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ as well as a link to its edit page.
</header>

<section class="main-content__body">
<div>
<% if dossier.transfer&.from_support %>
<p>
<%= t('views.users.dossiers.transfers.sender_demande_en_cours_from_support', id: dossier.id, email: dossier.transfer.email) %>
<br>
<%= link_to t('views.users.dossiers.transfers.revoke'), transfer_destroy_manager_dossier_path(dossier), class: 'fr-link', method: :delete %>
<% end %>
</div>
<dl>
<% page.attributes.each do |attribute| %>
<dt class="attribute-label" id="<%= attribute.name %>">
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
resources :dossiers, only: [:show] do
get 'transfer_edit', on: :member
post 'transfer', on: :member
delete 'transfer_destroy', on: :member
end

resources :bill_signatures, only: [:index]
Expand Down
10 changes: 10 additions & 0 deletions spec/controllers/manager/dossiers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,14 @@
it { expect(DossierMailer).not_to have_received(:notify_transfer) }
end
end

describe "DELETE #transfer_destroy" do
before do
DossierTransfer.create(email: 'coucou@laposte.net', dossiers: [@dossier])
delete :transfer_destroy, params: { id: @dossier.id }
end

it { expect(@dossier.transfer).to be_nil }
it { expect(flash[:notice]).to eq "La demande de transfert a été supprimée avec succès" }
end
end

0 comments on commit fc74367

Please sign in to comment.