Skip to content

Commit

Permalink
Use a Struct instead of OpenStruct in job
Browse files Browse the repository at this point in the history
  • Loading branch information
moveson committed Dec 20, 2024
1 parent 4249852 commit 6537198
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/jobs/delete_topic_resource_key_job.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion spec/jobs/delete_topic_resource_key_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand Down

0 comments on commit 6537198

Please sign in to comment.