diff --git a/app/controllers/claims_controller.rb b/app/controllers/claims_controller.rb index b1419827..c7febd25 100644 --- a/app/controllers/claims_controller.rb +++ b/app/controllers/claims_controller.rb @@ -19,6 +19,7 @@ def send_qf result = StoreQuotientFamilial.call(user: Current.user, identity: Current.pivot_identity, quotient_familial: Current.quotient_familial, recipient: hubee_recipient) if result.success? + reset_session Rails.logger.debug "Noïce" @folder = result.folder else diff --git a/app/interactors/clear_current_attributes.rb b/app/interactors/clear_current_attributes.rb new file mode 100644 index 00000000..27da3a96 --- /dev/null +++ b/app/interactors/clear_current_attributes.rb @@ -0,0 +1,7 @@ +class ClearCurrentAttributes < BaseInteractor + def call + Current.user = nil + Current.pivot_identity = nil + Current.quotient_familial = nil + end +end diff --git a/app/organizers/store_quotient_familial.rb b/app/organizers/store_quotient_familial.rb index 28059138..3c5a9c8b 100644 --- a/app/organizers/store_quotient_familial.rb +++ b/app/organizers/store_quotient_familial.rb @@ -1,3 +1,3 @@ class StoreQuotientFamilial < BaseOrganizer - organize UploadQuotientFamilialToHubEE, CreateShipment + organize UploadQuotientFamilialToHubEE, CreateShipment, ClearCurrentAttributes end diff --git a/spec/interactors/clear_current_attributes_spec.rb b/spec/interactors/clear_current_attributes_spec.rb new file mode 100644 index 00000000..dc5d1bc7 --- /dev/null +++ b/spec/interactors/clear_current_attributes_spec.rb @@ -0,0 +1,17 @@ +require "rails_helper" + +RSpec.describe ClearCurrentAttributes, type: :interactor do + subject(:interactor) { described_class.call } + + before do + Current.user = "user" + Current.pivot_identity = "pivot_identity" + Current.quotient_familial = "quotient_familial" + end + + it "clears the user session" do + expect { interactor }.to change { Current.user }.from("user").to(nil) + .and change { Current.pivot_identity }.from("pivot_identity").to(nil) + .and change { Current.quotient_familial }.from("quotient_familial").to(nil) + end +end diff --git a/spec/organizers/store_quotient_familial_spec.rb b/spec/organizers/store_quotient_familial_spec.rb index 9a852f09..7cf4aec2 100644 --- a/spec/organizers/store_quotient_familial_spec.rb +++ b/spec/organizers/store_quotient_familial_spec.rb @@ -5,6 +5,7 @@ [ UploadQuotientFamilialToHubEE, CreateShipment, + ClearCurrentAttributes, ] end @@ -31,6 +32,10 @@ before do allow(SecureRandom).to receive(:hex).and_return("abcdef1234567thiswontbeused") + Current.user = "user" + Current.pivot_identity = "pivot_identity" + Current.quotient_familial = "quotient_familial" + stub_hubee_token stub_hubee_create_folder stub_hubee_upload_attachment @@ -42,5 +47,11 @@ it "creates a shipment" do expect { organizer }.to change(Shipment, :count).by(1) end + + it "clears the user session" do + expect { organizer }.to change { Current.user }.from("user").to(nil) + .and change { Current.pivot_identity }.from("pivot_identity").to(nil) + .and change { Current.quotient_familial }.from("quotient_familial").to(nil) + end end end