-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create actions component instead of view partial
- Loading branch information
Showing
6 changed files
with
195 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class Claims::Support::Claim::ActionsComponent < ApplicationComponent | ||
def initialize(claim:, classes: [], html_attributes: {}) | ||
super(classes:, html_attributes:) | ||
|
||
@claim = claim | ||
end | ||
|
||
def call | ||
tag.div(class: "claim-actions") do | ||
render_actions | ||
end | ||
end | ||
|
||
private | ||
|
||
attr_reader :claim | ||
|
||
def render_actions | ||
case claim.status | ||
when *Claims::Claim::PAYMENT_ACTIONABLE_STATUSES | ||
render "claims/support/claims/payments/claims/actions", claim: | ||
when *Claims::Claim::SAMPLING_STATUSES | ||
render "claims/support/claims/samplings/actions", claim: | ||
when *Claims::Claim::CLAWBACK_STATUSES | ||
render "claims/support/claims/clawbacks/actions", claim: | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
spec/components/claims/support/claim/actions_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Claims::Support::Claim::ActionsComponent, type: :component do | ||
before { render_inline(described_class.new(claim:)) } | ||
|
||
context "when claim status is submitted" do | ||
let(:claim) { create(:claim, :submitted) } | ||
|
||
it "does not render actions" do | ||
expect(page).not_to have_element(:div, class: ".claim-actions") | ||
end | ||
end | ||
|
||
context "when claim status is paid" do | ||
let(:claim) { create(:claim, :paid) } | ||
|
||
it "does not renders actions" do | ||
expect(page).not_to have_element(:div, class: ".claim-actions") | ||
end | ||
end | ||
|
||
context "when claim status is payment information requested" do | ||
let(:claim) { create(:claim, :payment_information_requested, unpaid_reason: "Reason") } | ||
|
||
it "renders actions" do | ||
expect(page).to have_element(:h2, text: "Reason claim was not paid") | ||
expect(page).to have_element(:p, text: "Reason") | ||
|
||
expect(page).to have_element(:a, text: "Confirm information sent", class: "govuk-button") | ||
expect(page).to have_link("Confirm information sent", href: "/support/claims/payments/claims/#{claim.id}/information-sent") | ||
|
||
expect(page).to have_element(:a, text: "Reject claim", class: "govuk-button") | ||
expect(page).to have_link("Reject claim", href: "/support/claims/payments/claims/#{claim.id}/reject") | ||
end | ||
end | ||
|
||
context "when claim status is payment information sent" do | ||
let(:claim) { create(:claim, :payment_information_sent, unpaid_reason: "Reason") } | ||
|
||
it "renders actions" do | ||
expect(page).to have_element(:h2, text: "Reason claim was not paid") | ||
expect(page).to have_element(:p, text: "Reason") | ||
|
||
expect(page).to have_element(:a, text: "Confirm claim paid", class: "govuk-button") | ||
expect(page).to have_link("Confirm claim paid", href: "/support/claims/payments/claims/#{claim.id}/paid") | ||
|
||
expect(page).to have_element(:a, text: "Reject claim", class: "govuk-button") | ||
expect(page).to have_link("Reject claim", href: "/support/claims/payments/claims/#{claim.id}/reject") | ||
end | ||
end | ||
|
||
context "when claim status is payment not approved" do | ||
let(:claim) { create(:claim, :payment_not_approved) } | ||
|
||
it "does not renders actions" do | ||
expect(page).not_to have_element(:div, class: ".claim-actions") | ||
end | ||
end | ||
|
||
context "when claim status is sampling in progress" do | ||
let(:claim) { create(:claim, :audit_requested, sampling_reason: "Reason") } | ||
|
||
it "renders actions" do | ||
expect(page).to have_element(:div, class: "claim-actions") | ||
|
||
expect(page).to have_element(:h3, text: "Reason claim is being audited") | ||
expect(page).to have_element(:p, text: "Reason") | ||
|
||
expect(page).to have_element(:a, text: "Approve claim", class: "govuk-button") | ||
expect(page).to have_link("Approve claim", href: "/support/claims/sampling/claims/#{claim.id}/confirm_approval") | ||
|
||
expect(page).to have_element(:a, text: "Confirm provider rejected claim") | ||
expect(page).to have_link("Confirm provider rejected claim", href: "/support/claims/sampling/claims/#{claim.id}/provider_rejected/new") | ||
end | ||
end | ||
|
||
context "when claim status is sampling provider not approved" do | ||
let(:claim) { create(:claim, :sampling_provider_not_approved, mentor_trainings: [mentor_training]) } | ||
let(:mentor) { build(:claims_mentor, first_name: "John", last_name: "Doe") } | ||
let(:mentor_training) { build(:mentor_training, mentor:, not_assured: true, reason_not_assured: "Incorrect number of hours") } | ||
|
||
it "renders actions" do | ||
expect(page).to have_element(:div, class: "claim-actions") | ||
|
||
expect(page).to have_element(:h3, text: "Provider response", class: "govuk-heading-s") | ||
expect(page).to have_element(:li, text: "John Doe: Incorrect number of hours") | ||
|
||
expect(page).to have_element(:a, text: "Approve claim", class: "govuk-button") | ||
expect(page).to have_link("Approve claim", href: "/support/claims/sampling/claims/#{claim.id}/confirm_approval") | ||
|
||
expect(page).to have_element(:a, text: "Reject claim", class: "govuk-button") | ||
expect(page).to have_link("Reject claim", href: "/support/claims/sampling/claims/#{claim.id}/reject/new") | ||
end | ||
end | ||
|
||
context "when claim status is sampling not approved" do | ||
let(:claim) { create(:claim, :sampling_not_approved) } | ||
|
||
it "renders actions" do | ||
expect(page).to have_element(:div, class: "claim-actions") | ||
|
||
expect(page).to have_element(:a, text: "Request clawback", class: "govuk-button") | ||
expect(page).to have_link("Request clawback", href: "/support/claims/clawbacks/claims/new/#{claim.id}") | ||
end | ||
end | ||
|
||
context "when claim status is clawback requested" do | ||
let(:claim) { create(:claim, :clawback_requested) } | ||
|
||
it "does not renders actions" do | ||
expect(page).not_to have_element(:div, class: ".claim-actions") | ||
end | ||
end | ||
|
||
context "when claim status is clawback in progress" do | ||
let(:claim) { create(:claim, :clawback_in_progress) } | ||
|
||
it "does not renders actions" do | ||
expect(page).not_to have_element(:div, class: ".claim-actions") | ||
end | ||
end | ||
|
||
context "when claim status is clawback complete" do | ||
let(:claim) { create(:claim, :clawback_complete) } | ||
|
||
it "does not renders actions" do | ||
expect(page).not_to have_element(:div, class: ".claim-actions") | ||
end | ||
end | ||
end |
31 changes: 31 additions & 0 deletions
31
spec/components/previews/claims/support/claim/actions_component_preview.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class Claims::Support::Claim::ActionsComponentPreview < ApplicationComponentPreview | ||
def default | ||
claim = FactoryBot.build(:claim, :submitted, school:) | ||
render Claims::Support::Claim::ActionsComponent.new(claim:) | ||
end | ||
|
||
def with_payment_information_requested_claim | ||
claim = FactoryBot.build(:claim, :payment_information_requested, school:) | ||
render Claims::Support::Claim::ActionsComponent.new(claim:) | ||
end | ||
|
||
def with_payment_information_sent_claim | ||
claim = FactoryBot.build(:claim, :payment_information_sent, school:) | ||
render Claims::Support::Claim::ActionsComponent.new(claim:) | ||
end | ||
|
||
def with_sampling_in_progress_claim | ||
claim = FactoryBot.build(:claim, :sampling_in_progress, school:) | ||
render Claims::Support::Claim::ActionsComponent.new(claim:) | ||
end | ||
|
||
def with_sampling_provider_not_approved_claim | ||
claim = FactoryBot.build(:claim, :sampling_provider_not_approved, school:) | ||
render Claims::Support::Claim::ActionsComponent.new(claim:) | ||
end | ||
|
||
def with_sampling_not_approved_claim | ||
claim = FactoryBot.build(:claim, :sampling_not_approved, school:) | ||
render Claims::Support::Claim::ActionsComponent.new(claim:) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters