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.
30 lines
851 B
Ruby
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
|