-
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.
Update activity log title by using a decorator
- Loading branch information
Showing
23 changed files
with
317 additions
and
147 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
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
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,36 @@ | ||
class Claims::ClaimActivityDecorator < Draper::Decorator | ||
delegate_all | ||
|
||
def title | ||
case action | ||
when "payment_request_delivered" | ||
I18n.t("#{translation_path}.payment_request_delivered", count: record.claims.count) | ||
when "payment_response_uploaded" | ||
I18n.t("#{translation_path}.payment_response_uploaded") | ||
when "sampling_uploaded" | ||
I18n.t("#{translation_path}.sampling_uploaded", count: record.claims.count) | ||
when "sampling_response_uploaded" | ||
I18n.t("#{translation_path}.sampling_response_uploaded", count: record.claims.count) | ||
when "clawback_request_delivered" | ||
I18n.t("#{translation_path}.clawback_request_delivered", count: record.claims.count) | ||
when "clawback_response_uploaded" | ||
I18n.t("#{translation_path}.clawback_response_uploaded", count: record.claims.count) | ||
when "provider_approved_audit" | ||
I18n.t("#{translation_path}.provider_approved_audit", provider_name: record.provider_name, claim_reference: record.reference) | ||
when "rejected_by_provider" | ||
I18n.t("#{translation_path}.rejected_by_provider", provider_name: record.provider_name, claim_reference: record.reference) | ||
when "rejected_by_school" | ||
I18n.t("#{translation_path}.rejected_by_school", school_name: record.school_name, claim_reference: record.reference) | ||
when "approved_by_school" | ||
I18n.t("#{translation_path}.approved_by_school", school_name: record.school_name, claim_reference: record.reference) | ||
when "clawback_requested" | ||
I18n.t("#{translation_path}.clawback_requested", claim_reference: record.reference) | ||
end | ||
end | ||
|
||
private | ||
|
||
def translation_path | ||
"activerecord.attributes.claims/claim_activity/action" | ||
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
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
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
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
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
214 changes: 214 additions & 0 deletions
214
spec/decorators/claims/claim_activity_decorator_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,214 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Claims::ClaimActivityDecorator do | ||
describe "#title" do | ||
context "when the claim activity action is payment_request_delivered" do | ||
let(:claim_activity) { create(:claim_activity, :payment_request_delivered, record:) } | ||
let(:decorated_claim_activity) { claim_activity.decorate } | ||
|
||
context "when the claim activity has one claim" do | ||
let(:record) { build(:claims_payment, claims: [build(:claim, :submitted)]) } | ||
|
||
it "returns the translation for payment_request_delivered" do | ||
expect(decorated_claim_activity.title).to eq("1 claim sent to payer for payment") | ||
end | ||
end | ||
|
||
context "when the claim activity has more than one claim" do | ||
let(:record) { build(:claims_payment, claims: build_list(:claim, 3, :submitted)) } | ||
|
||
it "returns the translation for payment_request_delivered" do | ||
expect(decorated_claim_activity.title).to eq("3 claims sent to payer for payment") | ||
end | ||
end | ||
|
||
context "when the claim activity has no claims" do | ||
let(:record) { build(:claims_payment, claims: []) } | ||
|
||
it "returns the translation for payment_request_delivered" do | ||
expect(decorated_claim_activity.title).to eq("0 claims sent to payer for payment") | ||
end | ||
end | ||
end | ||
|
||
context "when the claim activity action is payment_response_uploaded" do | ||
let(:claim_activity) { create(:claim_activity, :payment_response_uploaded, record: create(:claims_payment)) } | ||
let(:decorated_claim_activity) { claim_activity.decorate } | ||
|
||
it "returns the translation for payment_response_uploaded" do | ||
expect(decorated_claim_activity.title).to eq("Payer payment response uploaded") | ||
end | ||
end | ||
|
||
context "when the claim activity action is sampling_uploaded" do | ||
let(:claim_activity) { create(:claim_activity, :sampling_uploaded, record:) } | ||
let(:decorated_claim_activity) { claim_activity.decorate } | ||
|
||
context "when the claim activity has one claim" do | ||
let(:provider_sampling) { build(:provider_sampling, provider_sampling_claims: [build(:claims_provider_sampling_claim)]) } | ||
let(:record) { build(:claims_sampling, provider_samplings: [provider_sampling]) } | ||
|
||
it "returns the translation for sampling_uploaded" do | ||
expect(decorated_claim_activity.title).to eq("Audit data uploaded for 1 claim") | ||
end | ||
end | ||
|
||
context "when the claim activity has more than one claim" do | ||
let(:provider_sampling) { build(:provider_sampling, provider_sampling_claims: build_list(:claims_provider_sampling_claim, 3)) } | ||
let(:record) { build(:claims_sampling, provider_samplings: [provider_sampling]) } | ||
|
||
it "returns the translation for sampling_uploaded" do | ||
expect(decorated_claim_activity.title).to eq("Audit data uploaded for 3 claims") | ||
end | ||
end | ||
|
||
context "when the claim activity has no claims" do | ||
let(:provider_sampling) { build(:provider_sampling, provider_sampling_claims: []) } | ||
let(:record) { build(:claims_sampling, provider_samplings: [provider_sampling]) } | ||
|
||
it "returns the translation for sampling_uploaded" do | ||
expect(decorated_claim_activity.title).to eq("Audit data uploaded for 0 claims") | ||
end | ||
end | ||
end | ||
|
||
context "when the claim activity action is sampling_response_uploaded" do | ||
let(:claim_activity) { create(:claim_activity, :sampling_response_uploaded, record:) } | ||
let(:decorated_claim_activity) { claim_activity.decorate } | ||
|
||
context "when the claim activity has one claim" do | ||
let(:provider_sampling) { build(:provider_sampling, provider_sampling_claims: [build(:claims_provider_sampling_claim)]) } | ||
let(:record) { build(:claims_sampling, provider_samplings: [provider_sampling]) } | ||
|
||
it "returns the translation for sampling_response_uploaded" do | ||
expect(decorated_claim_activity.title).to eq("Provider audit response uploaded for 1 claim") | ||
end | ||
end | ||
|
||
context "when the claim activity has more than one claim" do | ||
let(:provider_sampling) { build(:provider_sampling, provider_sampling_claims: build_list(:claims_provider_sampling_claim, 3)) } | ||
let(:record) { build(:claims_sampling, provider_samplings: [provider_sampling]) } | ||
|
||
it "returns the translation for sampling_response_uploaded" do | ||
expect(decorated_claim_activity.title).to eq("Provider audit response uploaded for 3 claims") | ||
end | ||
end | ||
|
||
context "when the claim activity has no claims" do | ||
let(:provider_sampling) { build(:provider_sampling, provider_sampling_claims: []) } | ||
let(:record) { build(:claims_sampling, provider_samplings: [provider_sampling]) } | ||
|
||
it "returns the translation for sampling_response_uploaded" do | ||
expect(decorated_claim_activity.title).to eq("Provider audit response uploaded for 0 claims") | ||
end | ||
end | ||
end | ||
|
||
context "when the claim activity action is clawback_request_delivered" do | ||
let(:claim_activity) { create(:claim_activity, :clawback_request_delivered, record:) } | ||
let(:decorated_claim_activity) { claim_activity.decorate } | ||
|
||
context "when the claim activity has one claim" do | ||
let(:record) { build(:claims_clawback, claims: [build(:claim, :submitted)]) } | ||
|
||
it "returns the translation for clawback_request_delivered" do | ||
expect(decorated_claim_activity.title).to eq("1 claim sent to payer for clawback") | ||
end | ||
end | ||
|
||
context "when the claim activity has more than one claim" do | ||
let(:record) { build(:claims_clawback, claims: build_list(:claim, 3, :submitted)) } | ||
|
||
it "returns the translation for clawback_request_delivered" do | ||
expect(decorated_claim_activity.title).to eq("3 claims sent to payer for clawback") | ||
end | ||
end | ||
|
||
context "when the claim activity has no claims" do | ||
let(:record) { build(:claims_clawback, claims: []) } | ||
|
||
it "returns the translation for clawback_request_delivered" do | ||
expect(decorated_claim_activity.title).to eq("0 claims sent to payer for clawback") | ||
end | ||
end | ||
end | ||
|
||
context "when the claim activity action is clawback_response_uploaded" do | ||
let(:claim_activity) { create(:claim_activity, :clawback_response_uploaded, record:) } | ||
let(:decorated_claim_activity) { claim_activity.decorate } | ||
|
||
context "when the claim activity has one claim" do | ||
let(:record) { build(:claims_clawback, claims: [build(:claim, :submitted)]) } | ||
|
||
it "returns the translation for clawback_response_uploaded" do | ||
expect(decorated_claim_activity.title).to eq("Payer clawback response uploaded for 1 claim") | ||
end | ||
end | ||
|
||
context "when the claim activity has more than one claim" do | ||
let(:record) { build(:claims_clawback, claims: build_list(:claim, 3, :submitted)) } | ||
|
||
it "returns the translation for clawback_response_uploaded" do | ||
expect(decorated_claim_activity.title).to eq("Payer clawback response uploaded for 3 claims") | ||
end | ||
end | ||
|
||
context "when the claim activity has no claims" do | ||
let(:record) { build(:claims_clawback, claims: []) } | ||
|
||
it "returns the translation for clawback_response_uploaded" do | ||
expect(decorated_claim_activity.title).to eq("Payer clawback response uploaded for 0 claims") | ||
end | ||
end | ||
end | ||
|
||
context "when the claim activity action is provider_approved_audit" do | ||
let(:record) { create(:claim, reference: "12345678") } | ||
let(:claim_activity) { create(:claim_activity, :provider_approved_audit, record:) } | ||
let(:decorated_claim_activity) { claim_activity.decorate } | ||
|
||
it "returns the translation for provider_approved_audit" do | ||
expect(decorated_claim_activity.title).to eq("Provider #{record.provider_name} approved audit for claim 12345678") | ||
end | ||
end | ||
|
||
context "when the claim activity action is rejected_by_provider" do | ||
let(:record) { create(:claim, reference: "12345678") } | ||
let(:claim_activity) { create(:claim_activity, :rejected_by_provider, record:) } | ||
let(:decorated_claim_activity) { claim_activity.decorate } | ||
|
||
it "returns the translation for rejected_by_provider" do | ||
expect(decorated_claim_activity.title).to eq("Provider #{record.provider_name} rejected audit for claim 12345678") | ||
end | ||
end | ||
|
||
context "when the claim activity action is rejected_by_school" do | ||
let(:record) { create(:claim, reference: "12345678") } | ||
let(:claim_activity) { create(:claim_activity, :rejected_by_school, record:) } | ||
let(:decorated_claim_activity) { claim_activity.decorate } | ||
|
||
it "returns the translation for rejected_by_school" do | ||
expect(decorated_claim_activity.title).to eq("School #{record.school_name} rejected audit for claim 12345678") | ||
end | ||
end | ||
|
||
context "when the claim activity action is approved_by_school" do | ||
let(:record) { create(:claim, reference: "12345678") } | ||
let(:claim_activity) { create(:claim_activity, :approved_by_school, record:) } | ||
let(:decorated_claim_activity) { claim_activity.decorate } | ||
|
||
it "returns the translation for approved_by_school" do | ||
expect(decorated_claim_activity.title).to eq("School #{record.school_name} approved audit for claim 12345678") | ||
end | ||
end | ||
|
||
context "when the claim activity action is clawback_requested" do | ||
let(:claim_activity) { create(:claim_activity, :clawback_requested, record: build(:claim, reference: "12345678")) } | ||
let(:decorated_claim_activity) { claim_activity.decorate } | ||
|
||
it "returns the translation for clawback_requested" do | ||
expect(decorated_claim_activity.title).to eq("Clawback requested for claim 12345678") | ||
end | ||
end | ||
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
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
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
Oops, something went wrong.