Sha256: d8d53aef20ab0c574af9f35f2a3631d6d619a7f59d34d3f19f434eea022c69f6

Contents?: true

Size: 1.37 KB

Versions: 19

Compression:

Stored size: 1.37 KB

Contents

require 'rails_helper'

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

  context "associations" do
    it 'should belong_to a course' do
      expect(CoalescingPanda::Assignment.reflect_on_association(:course)).to_not be_nil
      expect(CoalescingPanda::Assignment.reflect_on_association(:course).macro).to eql(:belongs_to)
    end

    it 'should have many submisssions' do
      expect(CoalescingPanda::Assignment.reflect_on_association(:submissions)).to_not be_nil
      expect(CoalescingPanda::Assignment.reflect_on_association(:submissions).macro).to eql(:has_many)
    end
  end

  context "validations" do
    it "should require a canvas id" do
      expect(FactoryGirl.build(:assignment, canvas_assignment_id: "")).to_not be_valid
    end

    it "should require a course" do
      expect(FactoryGirl.build(:assignment, coalescing_panda_course_id: "")).to_not be_valid
    end

    it 'should be unique to a course' do
      course = FactoryGirl.create(:course)
      assignment = FactoryGirl.create(:assignment, course: course, canvas_assignment_id: "1")
      expect { FactoryGirl.create(:assignment, course: course, canvas_assignment_id: "1") }.to raise_error ActiveRecord::RecordNotUnique
    end

    it "should be valid with valid data" do
      expect(FactoryGirl.build(:assignment)).to be_valid
    end
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
coalescing_panda-4.1.0 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-4.0.4 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-4.0.3 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-4.0.2 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-4.0.1 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-4.0.0 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.2.3 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.2.2 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.2.1 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.2.0 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.1.14 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.1.13 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.1.12 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.1.11 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.1.10 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.1.9 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.1.8 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.1.7 spec/models/coalescing_panda/assignment_spec.rb
coalescing_panda-3.1.6 spec/models/coalescing_panda/assignment_spec.rb