# frozen_string_literal: true require "rails_helper" RSpec.describe YoutubeRelayStopJob, type: :job do it "requeues when stop runs on the wrong host" do session = instance_double(StreamSession, id: SecureRandom.uuid, stream_node: nil) allow(StreamSession).to receive(:find_by).and_return(session) allow(Streams::YoutubeRelay).to receive(:worker?).and_return(true) allow(Streams::YoutubeRelay).to receive(:stop_on_worker!).and_return(:wrong_host) job_proxy = double("ConfiguredJob") expect(described_class).to receive(:set).with(wait: 2.seconds, queue: "youtube_relay_home").and_return(job_proxy) expect(job_proxy).to receive(:perform_later).with(session.id, 1) described_class.new.perform(session.id, 0) end end