Sha256: d3e7c9c627cddb6a03261907033fff4325395fa5fd9bab0d2f9029264eec0c82

Contents?: true

Size: 1.53 KB

Versions: 135

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) { FactoryGirl.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

135 entries across 135 versions & 1 rubygems

Version Path
canvas_sync-0.18.5 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.18.3 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.18.2 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.18.1 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.18.0.beta2 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.18.0.beta1 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.43 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.42 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.41 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.40 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.39 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.38 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.37 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.36 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.35 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.34 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.33 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.32 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.31 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.30 spec/canvas_sync/services/module_item_event_spec.rb