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.17.29 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.28 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.27 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.27.beta1 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.26.beta1 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.24 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.23 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.23.beta8 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.23.beta7 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.23.beta6 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.23.beta5 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.23.beta4 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.23.beta2 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.23.beta1 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.20 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.19 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.18 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.17.beta1 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.16 spec/canvas_sync/services/module_item_event_spec.rb
canvas_sync-0.17.15 spec/canvas_sync/services/module_item_event_spec.rb