diff --git a/modules/vaos/app/models/vaos/appointment_time.rb b/modules/vaos/app/models/vaos/appointment_time.rb deleted file mode 100644 index 342e08abb8d..00000000000 --- a/modules/vaos/app/models/vaos/appointment_time.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module VAOS - # This is a custom type class for ensuring Time is always coerced as UTC - class AppointmentTime < Virtus::Attribute - def coerce(value) - return nil if value.to_s.empty? - return value.strftime('%m/%d/%Y %T') if value.is_a?(Time) - return Time.zone.parse(value).strftime('%m/%d/%Y %T') if value.is_a?(String) && value.include?('-') - - value - end - end -end diff --git a/modules/vaos/app/models/vaos/cancel_form.rb b/modules/vaos/app/models/vaos/cancel_form.rb deleted file mode 100644 index 74fb88ebc04..00000000000 --- a/modules/vaos/app/models/vaos/cancel_form.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -require 'active_model' -require 'common/models/form' -require 'common/exceptions' - -module VAOS - class CancelForm < Common::Form - attribute :appointment_time, VAOS::AppointmentTime - attribute :clinic_id, String - attribute :cancel_reason, String - attribute :cancel_code, String - attribute :remarks, String - attribute :clinic_name, String - attribute :facility_id, String - - validates :appointment_time, :facility_id, :cancel_code, presence: true - - def params - raise Common::Exceptions::ValidationErrors, self unless valid? - - attributes - end - end -end diff --git a/modules/vaos/spec/models/cancel_form_spec.rb b/modules/vaos/spec/models/cancel_form_spec.rb deleted file mode 100644 index 00bae6c8e88..00000000000 --- a/modules/vaos/spec/models/cancel_form_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -# frozen_string_literal: true - -# frozen_string_literal true - -require 'rails_helper' - -describe VAOS::CancelForm, type: :model do - describe 'invalid object' do - subject { described_class.new } - - it 'validates presence of required attributes' do - expect(subject).not_to be_valid - expect(subject.errors.attribute_names).to contain_exactly(:appointment_time, :cancel_code, :facility_id) - end - - it 'raises a Common::Exceptions::ValidationErrors when trying to fetch coerced params' do - expect { subject.params }.to raise_error(Common::Exceptions::ValidationErrors) - end - end - - describe 'valid object' do - subject do - described_class.new( - appointment_time: '2019-11-13T20:19:12Z', - clinic_id: 455, - facility_id: 983, - cancel_reason: 5, - cancel_code: 'PC', - remarks: nil, - clinic_name: '' - ) - end - - it 'validates presence of required attributes' do - expect(subject).to be_valid - end - - it 'coerces params to correct types' do - expect(subject.params).to eq( - appointment_time: '11/13/2019 20:19:12', - clinic_id: '455', - facility_id: '983', - cancel_reason: '5', - cancel_code: 'PC', - remarks: nil, # doesn't coerce nil to "" - clinic_name: '' - ) - end - end -end