Sha256: e8cf0af829b55f4f32d212a3a42208e984e8e57160821a152eadb6951afdb8bf

Contents?: true

Size: 1.09 KB

Versions: 25

Compression:

Stored size: 1.09 KB

Contents

require "spec_helper"

RSpec.describe CanvasSync::LiveEvents::ProcessEventJob do
  before(:all) do
    User.include(CanvasSync::Concerns::LiveEventSync)
  end

  let(:event) {
    {
      "metadata" => {
        event_name: "user_created",
      },
      "payload" => {
        user_id: 1,
      },
    }
  }

  describe "#perform" do
    it "invokes a legacy handler if present" do
      expect(LiveEvents::UserCreatedEvent).to receive(:perform_later)
      described_class.perform_now(event)
    end

    it "does not invoke new handlers if legacy is present" do
      expect(CanvasSync::LiveEvents).to_not receive(:registered_handlers)
      described_class.perform_now(event)
    end

    it "invokes new handlers" do
      hide_const("LiveEvents::UserCreatedEvent")
      expect(CanvasSync::LiveEvents).to receive(:registered_handlers).and_call_original
      expect(User).to receive(:cs_internal_process_live_event).and_call_original
      expect_any_instance_of(User).to receive(:process_live_event).with(:created, event["payload"], event["metadata"])
      described_class.perform_now(event)
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
canvas_sync-0.22.9 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.8 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.6 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.5 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.4 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.3 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.2 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.1 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.0 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.0.beta8 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.0.beta7 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.0.beta6 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.0.beta5 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.0.beta4 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.0.beta3 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.0.beta2 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.22.0.beta1 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.21.1 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.21.1.beta1 spec/canvas_sync/live_events/process_event_job_spec.rb
canvas_sync-0.21.0 spec/canvas_sync/live_events/process_event_job_spec.rb