Skip to content

Commit

Permalink
Undercover fixes 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie committed Dec 20, 2024
1 parent 0681ae9 commit 89d2f91
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 30 deletions.
8 changes: 0 additions & 8 deletions app/controllers/claims/support/claims/samplings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ def update
}
end

# def confirm_provider_rejected; end

# def provider_rejected
# Claims::Claim::Sampling::ProviderNotApproved.call(claim: @claim)
# redirect_to claims_support_claims_sampling_path(@claim),
# flash: { heading: t(".success") }
# end

def confirm_rejection; end

def reject
Expand Down
6 changes: 1 addition & 5 deletions app/wizards/claims/provider_rejected_claim_wizard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def mentor_trainings
end

def selected_mentor_trainings
return [] if steps[:mentor_training].blank?
return [] if steps.fetch(:mentor_training).mentor_training_ids.blank?

mentor_trainings.where(
id: steps.fetch(:mentor_training).mentor_training_ids,
Expand All @@ -44,10 +44,6 @@ def step_name_for_provider_response(mentor_training)

private

def provider_response_steps
steps.values.select { |step| step.is_a?(ProviderResponseStep) }
end

def provider_responses_for_mentor_trainings
mentor_trainings.map do |mentor_training|
provider_response_step = steps[step_name_for_provider_response(mentor_training)]
Expand Down
51 changes: 46 additions & 5 deletions spec/services/claims/claim/sampling/provider_not_approved_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,53 @@
let!(:claim) { create(:claim, :submitted, status: :sampling_in_progress) }

describe "#call" do
subject(:call) { described_class.call(claim:) }
subject(:call) { described_class.call(claim:, provider_responses:) }

it "changes to status of the claim to provider not approved" do
expect { call }.to change(claim, :status)
.from("sampling_in_progress")
.to("sampling_provider_not_approved")
context "when given no provider responses" do
let(:provider_responses) { [] }

it "changes to status of the claim to provider not approved" do
expect { call }.to change(claim, :status)
.from("sampling_in_progress")
.to("sampling_provider_not_approved")
end
end

context "when given provider responses" do
let(:mentor_training_1) { create(:mentor_training, claim:) }
let(:mentor_training_2) { create(:mentor_training, claim:) }
let(:provider_responses) do
[
{ id: mentor_training_1.id, not_assured: true, reason_not_assured: "Some reason" },
{ id: mentor_training_2.id, not_assured: false, reason_not_assured: nil },
]
end

it "updates the mentor trainings with the given response" do
expect { call }.to change(claim, :status)
.from("sampling_in_progress")
.to("sampling_provider_not_approved")

mentor_training_1.reload
expect(mentor_training_1.not_assured).to be(true)
expect(mentor_training_1.reason_not_assured).to eq("Some reason")
expect(mentor_training_2.reload.not_assured).to be(false)
end

context "when given a provider response for a mentor training not associated with this claim" do
let(:mentor_training_3) { create(:mentor_training) }
let(:provider_responses) do
[
{ id: mentor_training_1.id, not_assured: true, reason_not_assured: "Some reason" },
{ id: mentor_training_2.id, not_assured: false, reason_not_assured: nil },
{ id: mentor_training_3.id, not_assured: true, reason_not_assured: "Another reason" },
]
end

it "skips the mentor training not associated with the claim" do
expect { call }.not_to change(mentor_training_3, :not_assured).from(false)
end
end
end
end
end
32 changes: 20 additions & 12 deletions spec/wizards/claims/provider_rejected_claim_wizard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,29 @@
describe "#selected_mentor_trainings" do
subject(:selected_mentor_trainings) { wizard.selected_mentor_trainings }

let(:state) do
{
"mentor_training" => {
"mentor_training_ids" => [mentor_training_1.id],
},
}
context "when mentors have not been selected" do
it "returns an empty array" do
expect(selected_mentor_trainings).to eq([])
end
end

before do
mentor_training_1
mentor_training_2
end
context "when mentors have been selected" do
let(:state) do
{
"mentor_training" => {
"mentor_training_ids" => [mentor_training_1.id],
},
}
end

it "returns a list of mentor trainings selected in the mentor training step" do
expect(selected_mentor_trainings).to eq([mentor_training_1])
before do
mentor_training_1
mentor_training_2
end

it "returns a list of mentor trainings selected in the mentor training step" do
expect(selected_mentor_trainings).to eq([mentor_training_1])
end
end
end

Expand Down

0 comments on commit 89d2f91

Please sign in to comment.