Sha256: d23f8eafd5fceddc383e7ee296526e78787fed02b3b2e124521f063ef0bb7b65
Contents?: true
Size: 1.29 KB
Versions: 79
Compression:
Stored size: 1.29 KB
Contents
require "spec_helper" RSpec.describe Assignment, type: :model do let(:subject) { FactoryGirl.create(:assignment) } describe "validations" do it { should validate_presence_of(:canvas_id) } it { should validate_uniqueness_of(:canvas_id) } end describe "associations" do it do should have_many(:submissions) .with_primary_key(:canvas_id) .with_foreign_key(:canvas_assignment_id) end it do should belong_to(:assignment_group) .with_primary_key(:canvas_id) .with_foreign_key(:canvas_assignment_group_id) end it do should have_many(:context_module_items) .with_primary_key(:canvas_id) .with_foreign_key(:canvas_content_id) .dependent(:destroy) end it { should have_many(:context_modules).through(:context_module_items) } describe "context" do let!(:other_course) { FactoryGirl.create(:course) } let!(:matching_course) { FactoryGirl.create(:course) } before do subject.update(canvas_context_type: "Course", canvas_context_id: matching_course.canvas_id) end it "should belong to courses where the canvas_context_type is Course and canvas_context_id is the canvas_course_id" do expect(subject.context).to eq(matching_course) end end end end
Version data entries
79 entries across 79 versions & 1 rubygems