Sha256: b713fbd73f7ed89ad41edb99bdb93ebbd6ea9ab63f6c04ff592537b4b15e6d33
Contents?: true
Size: 945 Bytes
Versions: 5
Compression:
Stored size: 945 Bytes
Contents
require 'spec_helper_models' 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
5 entries across 5 versions & 1 rubygems