From 6537198cc053d36f305b341af34254fe34c5465a Mon Sep 17 00:00:00 2001 From: moveson Date: Thu, 19 Dec 2024 23:15:33 -0700 Subject: [PATCH] Use a Struct instead of OpenStruct in job --- app/jobs/delete_topic_resource_key_job.rb | 6 +++--- spec/jobs/delete_topic_resource_key_job_spec.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/jobs/delete_topic_resource_key_job.rb b/app/jobs/delete_topic_resource_key_job.rb index 7d898eace..4e6fccd51 100644 --- a/app/jobs/delete_topic_resource_key_job.rb +++ b/app/jobs/delete_topic_resource_key_job.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require "ostruct" - class DeleteTopicResourceKeyJob < ApplicationJob + MockResource = Struct.new(:topic_resource_key, :slug, keyword_init: true) + queue_as :default def perform(topic_resource_key, topic_manager_string: "SnsTopicManager") topic_manager = topic_manager_string.constantize - mock_resource = OpenStruct.new(topic_resource_key: topic_resource_key, slug: topic_resource_key) + mock_resource = MockResource.new(topic_resource_key: topic_resource_key, slug: topic_resource_key) topic_manager.delete(resource: mock_resource) end end diff --git a/spec/jobs/delete_topic_resource_key_job_spec.rb b/spec/jobs/delete_topic_resource_key_job_spec.rb index 01ef4c097..23f8ec323 100644 --- a/spec/jobs/delete_topic_resource_key_job_spec.rb +++ b/spec/jobs/delete_topic_resource_key_job_spec.rb @@ -9,7 +9,7 @@ describe "#perform" do let(:perform_job) { subject.perform(topic_resource_key) } - let(:expected_mock_resource) { OpenStruct.new(topic_resource_key: topic_resource_key, slug: topic_resource_key) } + let(:expected_mock_resource) { described_class::MockResource.new(topic_resource_key: topic_resource_key, slug: topic_resource_key) } before { allow(SnsTopicManager).to receive(:delete) }