Sha256: ba7ad1d588f49fb477bae6da1385d58d7b8f8a37ab25e771f16eaa094ac4beb6

Contents?: true

Size: 780 Bytes

Versions: 2

Compression:

Stored size: 780 Bytes

Contents

require "spec_helper"

RSpec.describe Assignment, type: :model do
  let(:subject) { FactoryGirl.create(:assignment) }

  describe "validations" do
    it { should validate_presence_of(:canvas_assignment_id) }
    it { should validate_uniqueness_of(:canvas_assignment_id) }
  end

  describe "associations" do
    describe "context" do
      let!(:other_course) { FactoryGirl.create(:course) }
      let!(:matching_course) { FactoryGirl.create(:course) }

      before do
        subject.update_attributes(context_type: "Course", context_id: matching_course.canvas_course_id)
      end

      it "should belong to courses where the context_type is Course and context_id is the canvas_course_id" do
        expect(subject.context).to eq(matching_course)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
canvas_sync-0.3.13 spec/canvas_sync/models/assignments_spec.rb
canvas_sync-0.3.12 spec/canvas_sync/models/assignments_spec.rb