Skip to content

Commit

Permalink
Add the current user to the upload sampling data wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
Kizr committed Dec 24, 2024
1 parent 6f270e2 commit 9656159
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def update
def set_wizard
state = session[state_key] ||= {}
current_step = params[:step]&.to_sym
@wizard = Claims::UploadSamplingDataWizard.new(params:, state:, current_step:)
@wizard = Claims::UploadSamplingDataWizard.new(params:, state:, current_step:, current_user:)
end

def step_path(step)
Expand Down
10 changes: 9 additions & 1 deletion app/wizards/claims/upload_sampling_data_wizard.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
module Claims
class UploadSamplingDataWizard < BaseWizard
def initialize(current_user:, params:, state:, current_step: nil)
@current_user = current_user

super(state:, params:, current_step:)
end

attr_reader :current_user

def define_steps
if paid_claims.present?
add_step(UploadStep)
Expand All @@ -12,7 +20,7 @@ def define_steps
def upload_data
raise "Invalid wizard state" unless valid?

Claims::Sampling::FlagCollectionForSamplingJob.perform_later(uploaded_claim_ids)
Claims::Sampling::CreateAndDeliverJob.perform_later(current_user_id: current_user.id, claim_ids: uploaded_claim_ids)
end

def paid_claims
Expand Down
6 changes: 4 additions & 2 deletions spec/wizards/claims/upload_sampling_data_wizard_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "rails_helper"

RSpec.describe Claims::UploadSamplingDataWizard do
subject(:wizard) { described_class.new(state:, params:, current_step: nil) }
subject(:wizard) { described_class.new(current_user:, state:, params:, current_step: nil) }

let(:state) { {} }
let(:params_data) { {} }
Expand All @@ -22,6 +22,8 @@
reference: "11111111")
end

let(:current_user) { create(:claims_user) }

describe "#steps" do
subject { wizard.steps.keys }

Expand Down Expand Up @@ -53,7 +55,7 @@

it "queues a job to flag the claim for sampling" do
expect { wizard.upload_data }.to have_enqueued_job(
Claims::Sampling::FlagCollectionForSamplingJob,
Claims::Sampling::CreateAndDeliverJob,
).exactly(:once)
end
end
Expand Down

0 comments on commit 9656159

Please sign in to comment.