Sha256: d9f13c66b6043240021d1f76308523297b133b754e653f8a8f63c54cf01dc0d6
Contents?: true
Size: 1.31 KB
Versions: 25
Compression:
Stored size: 1.31 KB
Contents
require "spec_helper" RSpec.describe LiveEvents::ModuleEvent do let(:payload) { { "body" => { module_id: "1", name: "Module 2", position: 1337, workflow_state: "active", context_id: 1, context_type: "Course", }, } } describe "#perform" do context "the module already exists" do let!(:context_module) { FactoryGirl.create(:context_module, canvas_context_module_id: payload["body"][:module_id]) } it "updates it" do expect { LiveEvents::ModuleEvent.new.perform(payload) }.to_not change { ContextModule.count } expect(context_module.reload.name).to eq(payload["body"][:name]) expect(context_module.position).to eq(payload["body"][:position]) expect(context_module.workflow_state).to eq(payload["body"][:workflow_state]) end end context "the module does not already exist" do it "creates it" do expect { LiveEvents::ModuleEvent.new.perform(payload) }.to change { ContextModule.count }.by(1) expect(ContextModule.last.name).to eq(payload["body"][:name]) expect(ContextModule.last.position).to eq(payload["body"][:position]) expect(ContextModule.last.workflow_state).to eq(payload["body"][:workflow_state]) end end end end
Version data entries
25 entries across 25 versions & 1 rubygems