From 2849ba18ed82381b1f92a53f8fbef6424b3d6942 Mon Sep 17 00:00:00 2001 From: Avin Hurry Date: Tue, 17 Dec 2024 16:46:10 +0000 Subject: [PATCH] [512] Expose the inactive status --- app/lib/vendor_api.rb | 5 ++++- ...inactive_to_application_attribute_statuses.rb | 10 ++++++++++ .../application_presenter/add_inactive_status.rb | 9 +++++++++ .../v1.6/application_presenter_spec.rb | 16 ++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 app/lib/vendor_api/changes/v16/add_inactive_to_application_attribute_statuses.rb create mode 100644 app/presenters/vendor_api/application_presenter/add_inactive_status.rb create mode 100644 spec/presenters/vendor_api/v1.6/application_presenter_spec.rb diff --git a/app/lib/vendor_api.rb b/app/lib/vendor_api.rb index e376cbb5e73..0ef2a642a98 100644 --- a/app/lib/vendor_api.rb +++ b/app/lib/vendor_api.rb @@ -66,6 +66,9 @@ module VendorAPI Changes::V15::AddApplicationSentToProviderDatetime, Changes::V15::AddReferenceFeedbackProvidedAtDatetime, ], - '1.6pre' => [Changes::V16::AddConfidentialToReference], + '1.6pre' => [ + Changes::V16::AddConfidentialToReference, + Changes::V16::AddInactiveToApplicationAttributeStatuses, + ], }.freeze end diff --git a/app/lib/vendor_api/changes/v16/add_inactive_to_application_attribute_statuses.rb b/app/lib/vendor_api/changes/v16/add_inactive_to_application_attribute_statuses.rb new file mode 100644 index 00000000000..2cc5136e46e --- /dev/null +++ b/app/lib/vendor_api/changes/v16/add_inactive_to_application_attribute_statuses.rb @@ -0,0 +1,10 @@ +module VendorAPI + module Changes + module V16 + class AddInactiveToApplicationAttributeStatuses < VersionChange + description 'Add inactive to the application attributes' + resource ApplicationPresenter, [ApplicationPresenter::AddInactiveStatus] + end + end + end +end diff --git a/app/presenters/vendor_api/application_presenter/add_inactive_status.rb b/app/presenters/vendor_api/application_presenter/add_inactive_status.rb new file mode 100644 index 00000000000..916da3c17cf --- /dev/null +++ b/app/presenters/vendor_api/application_presenter/add_inactive_status.rb @@ -0,0 +1,9 @@ +module VendorAPI::ApplicationPresenter::AddInactiveStatus + def schema + super.deep_merge( + attributes: { + inactive: @application_choice.inactive?, + }, + ) + end +end diff --git a/spec/presenters/vendor_api/v1.6/application_presenter_spec.rb b/spec/presenters/vendor_api/v1.6/application_presenter_spec.rb new file mode 100644 index 00000000000..d7ec6e977b9 --- /dev/null +++ b/spec/presenters/vendor_api/v1.6/application_presenter_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +RSpec.describe VendorAPI::ApplicationPresenter do + let(:application_json) { described_class.new(version, application_choice).as_json } + let(:version) { '1.6' } + + describe '#status' do + context 'when the application choice is inactive' do + let(:application_choice) { create(:application_choice, :inactive) } + + it 'returns the status as inactive' do + expect(application_json.dig(:attributes, :inactive)).to be(true) + end + end + end +end