Sha256: 7ca2e3651d8ed044fc07f0361e5706aa03bdb09de46cc45f171a753a95df8d33

Contents?: true

Size: 933 Bytes

Versions: 3

Compression:

Stored size: 933 Bytes

Contents

require 'spec_helper'

describe Gaku::LessonPlan do

  describe 'concerns' do
    it_behaves_like 'notable'
  end

  describe 'relations' do
  	it { should have_many :lessons }
  	it { should have_many :attachments }
  	it { should belong_to :syllabus }
  end

  describe 'validations' do
    it { should validate_presence_of :syllabus }
  end

  context 'counter_cache' do

    let!(:lesson_plan) { create(:lesson_plan) }

    context 'notes_count' do

      let(:note) { build(:note) }
      let(:lesson_plan_with_note) { create(:lesson_plan, :with_note) }

      it 'increments notes_count' do
        expect do
          lesson_plan.notes << note
        end.to change { lesson_plan.reload.notes_count }.by 1
      end

      it 'decrements notes_count' do
        expect do
          lesson_plan_with_note.notes.last.destroy
        end.to change { lesson_plan_with_note.reload.notes_count }.by -1
      end

    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gaku-0.0.3 core/spec/models/lesson_plan_spec.rb
gaku-0.0.2 core/spec/models/lesson_plan_spec.rb
gaku-0.0.1 core/spec/models/lesson_plan_spec.rb