Sha256: fcab7d753be2e1cdb1cc28851394b5d9ee50dbee25d4fe6f1d68fd5b6e86c940
Contents?: true
Size: 1.33 KB
Versions: 26
Compression:
Stored size: 1.33 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_assignment_id) } it { should validate_uniqueness_of(:canvas_assignment_id) } end describe "associations" do it do should have_many(:submissions) .with_primary_key(:canvas_assignment_id) .with_foreign_key(:canvas_assignment_id) end it do should belong_to(:assignment_group) .with_primary_key(:canvas_assignment_group_id) .with_foreign_key(:canvas_assignment_group_id) end it do should have_many(:context_module_items) .with_primary_key(:canvas_assignment_id) .with_foreign_key(: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_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
26 entries across 26 versions & 1 rubygems