Sha256: cef00311c56397bb4d5b11be0f393ce9f029ab592d6d3698ea8c00ce89d0c10d

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

require "spec_helper"

RSpec.describe LiveEvents::ModuleItemEvent do
  let(:payload) {
    {
      "body" => {
        module_item_id: 1,
        module_id: 1,
        context_id: 1,
        context_type: "assignment",
        position: 10,
        workflow_state: "active",
      },
    }
  }

  describe "#perform" do
    context "the module item already exists" do
      let!(:cmi) { FactoryBot.create(:context_module_item, canvas_id: payload["body"][:module_item_id]) }

      xit "updates it" do
        expect {
          LiveEvents::ModuleItemEvent.new.perform(payload)
        }.to_not change { ContextModuleItem.count }
        expect(cmi.reload.canvas_id).to eq(payload["body"][:module_item_id])
        expect(cmi.position).to eq(payload["body"][:position])
        expect(cmi.workflow_state).to eq(payload["body"][:workflow_state])
        expect(cmi.canvas_content_type).to eq("Assignment")
        expect(cmi.canvas_content_id).to eq(143)
      end
    end

    context "the module item does not already exist" do
      xit "creates it" do
        expect {
          LiveEvents::ModuleItemEvent.new.perform(payload)
        }.to change { ContextModuleItem.count }.by(1)
        cmi = ContextModuleItem.last
        expect(cmi.canvas_id).to eq(payload["body"][:module_item_id])
        expect(cmi.position).to eq(payload["body"][:position])
        expect(cmi.workflow_state).to eq(payload["body"][:workflow_state])
        expect(cmi.canvas_content_type).to eq("Assignment")
        expect(cmi.canvas_content_id).to eq(143)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
canvas_sync-0.22.6 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.22.5 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.22.4 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.22.3 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.22.2 spec/canvas_sync/services/module_item_event_spec.rb