Sha256: 2fccea9c73820a74ed43fb9f4506796344d986b0c2385918d6436449fb4d3845
Contents?: true
Size: 1.55 KB
Versions: 24
Compression:
Stored size: 1.55 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_context_module_item_id: payload["body"][:module_item_id]) } it "updates it" do expect { LiveEvents::ModuleItemEvent.new.perform(payload) }.to_not change { ContextModuleItem.count } expect(cmi.reload.canvas_context_module_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.content_type).to eq("Assignment") expect(cmi.content_id).to eq(143) end end context "the module item does not already exist" do it "creates it" do expect { LiveEvents::ModuleItemEvent.new.perform(payload) }.to change { ContextModuleItem.count }.by(1) cmi = ContextModuleItem.last expect(cmi.canvas_context_module_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.content_type).to eq("Assignment") expect(cmi.content_id).to eq(143) end end end end
Version data entries
24 entries across 24 versions & 1 rubygems