Sha256: 009828f86e8ff22a8cfb2a4af19b66995a7ee2ebdbeaf0f8474ac05e4b976bfc

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

RSpec.describe CanvasSync::Processors::ProvisioningReportProcessor do
  let(:subject) { CanvasSync::Processors::ProvisioningReportProcessor }

  describe '#process' do
    it 'process users' do
      expect {
        subject.process('spec/support/fixtures/reports/users.csv', { models: ['users'] })
      }.to change { User.count }.by(2)
    end

    it 'processes courses' do
      expect {
        subject.process('spec/support/fixtures/reports/courses.csv', { models: ['courses'] })
      }.to change { Course.count }.by(2)
    end

    it 'processes enrollments' do
      expect {
        subject.process('spec/support/fixtures/reports/enrollments.csv', { models: ['enrollments'] })
      }.to change { Enrollment.count }.by(2)
    end

    it 'processes sections' do
      expect {
        subject.process('spec/support/fixtures/reports/sections.csv', { models: ['sections'] })
      }.to change { Section.count }.by(2)
    end

    context 'options[:models] is multiple models' do
      it 'extracts the ZIP and processes each model' do
        user_count = User.count
        course_count = Course.count
        subject.process('spec/support/fixtures/reports/provisioning_csv', { models: ['courses', 'users'] })
        expect(User.count).to eq(user_count + 2)
        expect(Course.count).to eq(course_count + 2)
      end
    end

    context 'legacy_support is true' do
      it 'uses the LegacyImporter' do
        expect(User).to receive(:create_or_update_from_csv).at_least(:once)
        subject.process('spec/support/fixtures/reports/users.csv', { models: ['users'], legacy_support: true })
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
canvas_sync-0.2.2 spec/canvas_sync/processors/provisioning_report_processor_spec.rb
canvas_sync-0.2.1 spec/canvas_sync/processors/provisioning_report_processor_spec.rb
canvas_sync-0.2.0 spec/canvas_sync/processors/provisioning_report_processor_spec.rb