Sha256: bd66028d65306bc141959fa07e4355d79f1e28abd2eb441c1054101ad1cd41b1

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

RSpec.describe Course, type: :model do
  let(:subject) { FactoryBot.create(:course) }

  describe 'validations' do
    it { should validate_presence_of(:canvas_id) }
    it { should validate_uniqueness_of(:canvas_id) }
  end

  describe 'associations' do
    it do
      should belong_to(:term)
        .with_primary_key(:canvas_id)
        .with_foreign_key(:canvas_term_id)
    end

    it do
      should have_many(:enrollments)
        .with_primary_key(:canvas_id)
        .with_foreign_key(:canvas_course_id)
    end

    it do
      should have_many(:sections)
        .with_primary_key(:canvas_id)
        .with_foreign_key(:canvas_course_id)
    end

    it do
      should have_many(:assignment_groups)
        .with_primary_key(:canvas_id)
        .with_foreign_key(:canvas_course_id)
    end

    it do
      should have_many(:assignments)
        .with_primary_key(:canvas_id)
    end

    it do
      should have_many(:submissions)
    end

    it do
      should have_many(:groups)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
canvas_sync-0.22.6 spec/canvas_sync/models/course_spec.rb
canvas_sync-0.22.5 spec/canvas_sync/models/course_spec.rb
canvas_sync-0.22.4 spec/canvas_sync/models/course_spec.rb
canvas_sync-0.22.3 spec/canvas_sync/models/course_spec.rb
canvas_sync-0.22.2 spec/canvas_sync/models/course_spec.rb