diff --git a/modules/va_notify/app/services/va_notify/status_update.rb b/modules/va_notify/app/services/va_notify/status_update.rb index 41adf07cad9..444d5b4e3fd 100644 --- a/modules/va_notify/app/services/va_notify/status_update.rb +++ b/modules/va_notify/app/services/va_notify/status_update.rb @@ -9,7 +9,7 @@ def delegate(notification_callback) return if callback_info_missing? - klass = constantized_class(notification.callback) + klass = constantized_class(notification.callback_klass) if klass.respond_to?(:call) begin klass.call(notification) @@ -35,7 +35,7 @@ def constantized_class(class_name) end def callback_info_missing? - if notification.callback.blank? + if notification.callback_klass.blank? Rails.logger.info(message: "VANotify - no callback provided for notification: #{notification.id}") true else diff --git a/modules/va_notify/lib/va_notify/service.rb b/modules/va_notify/lib/va_notify/service.rb index 04c78069e49..2763c565bfd 100644 --- a/modules/va_notify/lib/va_notify/service.rb +++ b/modules/va_notify/lib/va_notify/service.rb @@ -108,7 +108,7 @@ def create_notification(response) notification = VANotify::Notification.new( notification_id: response.id, source_location: find_caller_locations, - callback: callback_options[:callback], + callback_klass: callback_options[:callback], callback_metadata: callback_options[:callback_metadata] ) diff --git a/modules/va_notify/spec/lib/service_spec.rb b/modules/va_notify/spec/lib/service_spec.rb index cb11653e9f4..dd13ce0b1a8 100644 --- a/modules/va_notify/spec/lib/service_spec.rb +++ b/modules/va_notify/spec/lib/service_spec.rb @@ -124,8 +124,8 @@ expect(VANotify::Notification.count).to eq(1) notification = VANotify::Notification.first expect(notification.source_location).to include('modules/va_notify/spec/lib/service_spec.rb') - expect(notification.callback).to eq(nil) - expect(notification.metadata).to eq(nil) + expect(notification.callback_klass).to eq(nil) + expect(notification.callback_metadata).to eq(nil) end end @@ -139,8 +139,8 @@ expect(VANotify::Notification.count).to eq(1) notification = VANotify::Notification.first expect(notification.source_location).to include('modules/va_notify/spec/lib/service_spec.rb') - expect(notification.callback).to eq(nil) - expect(notification.metadata).to eq(nil) + expect(notification.callback_klass).to eq(nil) + expect(notification.callback_metadata).to eq(nil) end end @@ -154,7 +154,7 @@ expect(VANotify::Notification.count).to eq(1) notification = VANotify::Notification.first expect(notification.source_location).to include('modules/va_notify/spec/lib/service_spec.rb') - expect(notification.callback).to eq('TestCallback') + expect(notification.callback_klass).to eq('TestCallback') expect(notification.callback_metadata).to eq('optional_metadata') end end diff --git a/modules/va_notify/spec/services/status_update_spec.rb b/modules/va_notify/spec/services/status_update_spec.rb index 2185122ea84..252a96c5de5 100644 --- a/modules/va_notify/spec/services/status_update_spec.rb +++ b/modules/va_notify/spec/services/status_update_spec.rb @@ -10,7 +10,7 @@ context 'notification with callback' do it 'invokes callback class #call' do notification_id = SecureRandom.uuid - create(:notification, notification_id:, callback: 'VANotify::OtherTeam::OtherForm') + create(:notification, notification_id:, callback_klass: 'VANotify::OtherTeam::OtherForm') allow(VANotify::OtherTeam::OtherForm).to receive(:call) provider_callback = { @@ -24,13 +24,14 @@ it 'logs error message if #call fails' do notification_id = SecureRandom.uuid - notification = create(:notification, notification_id:, callback: 'VANotify::OtherTeam::OtherForm') + notification = create(:notification, notification_id:, callback_klass: 'VANotify::OtherTeam::OtherForm') provider_callback = { id: notification_id } - allow(notification.callback.constantize).to receive(:call).with(notification).and_raise(StandardError, - 'Something went wrong') + allow(notification.callback_klass.constantize).to receive(:call) + .with(notification).and_raise(StandardError, + 'Something went wrong') expect(Rails.logger).to receive(:info).with('Something went wrong') @@ -40,7 +41,7 @@ it 'logs a message and source location if callback klass does not implement #call' do notification_id = SecureRandom.uuid notification = create(:notification, notification_id:, - callback: 'VANotify::NonCompliantModule::NonCompliantClass') + callback_klass: 'VANotify::NonCompliantModule::NonCompliantClass') provider_callback = { id: notification_id }