Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supprime les données de la session après envoi chez hubee #19

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

@JeSuisUnCaillou JeSuisUnCaillou Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si on peut mettre ça dans le ClearCurrentAttributes, ça peut simplifier le controller (je sais pas si c'possible, ni même si c'est un si bonne idée de lui donner cette responsabilité)

Rails.logger.debug "Noïce"
@folder = result.folder
else
Expand Down
7 changes: 7 additions & 0 deletions app/interactors/clear_current_attributes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ClearCurrentAttributes < BaseInteractor
def call
Current.user = nil
Current.pivot_identity = nil
Current.quotient_familial = nil
end
end
2 changes: 1 addition & 1 deletion app/organizers/store_quotient_familial.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class StoreQuotientFamilial < BaseOrganizer
organize UploadQuotientFamilialToHubEE, CreateShipment
organize UploadQuotientFamilialToHubEE, CreateShipment, ClearCurrentAttributes
end
17 changes: 17 additions & 0 deletions spec/interactors/clear_current_attributes_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't clear the user session right now, only the Current's attributes

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
11 changes: 11 additions & 0 deletions spec/organizers/store_quotient_familial_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[
UploadQuotientFamilialToHubEE,
CreateShipment,
ClearCurrentAttributes,
]
end

Expand All @@ -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
Expand All @@ -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