docbrown/spec/workers/podcast_episodes/create_worker_spec.rb
Asha Balasubramaniam bc137ff762 Migrate PodcastEpisodes::CreateJob to PodcastEpisodes::CreateWorker for Sidekiq (#5633)
The tests around `Podcasts::Feed` helped catch a bug around the
migration of the podcast episode creation delayed job where the sidekiq
version was passing a string version of item hash to
`Podcasts::CreateEpisode` which was in fact expecting the hash to
contain symbols.
2020-01-23 15:37:43 -05:00

30 lines
851 B
Ruby

require "rails_helper"
RSpec.describe PodcastEpisodes::CreateWorker, type: :worker do
include_examples "#enqueues_on_correct_queue", "high_priority", [123, {}]
describe "#perform" do
let(:worker) { subject }
let(:podcast_id) { 781 }
let(:item) { { foo: "bar" } }
before do
allow(Podcasts::CreateEpisode).to receive(:call)
end
it "creates a podcast episode" do
worker.perform(podcast_id, item)
expect(Podcasts::CreateEpisode).to have_received(:call).with(podcast_id, item).once
end
context "when item has string keys" do
it "creates a podcast episode regardless of whether item has string or symbol keys" do
worker.perform(podcast_id, item.stringify_keys)
expect(Podcasts::CreateEpisode).to have_received(:call).with(podcast_id, item).once
end
end
end
end