Sha256: 1dc187ea9d6602add4d8b4299f78fb82f3518d75884978f6ad541a240c3f9966
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 KB
Contents
require 'spec_helper_models' describe Gaku::ExtracurricularActivity do describe 'concerns' do it_behaves_like 'enrollmentable' end describe 'associations' do end describe 'validations' do it { should validate_presence_of :name } it { should validate_uniqueness_of :name } end describe '#to_s' do let(:extracurricular_activity) { build(:extracurricular_activity) } specify { extracurricular_activity.to_s.should eq extracurricular_activity.name } end context 'counter_cache' do let!(:extracurricular_activity) { create(:extracurricular_activity) } context 'enrollments_count' do let(:student) { build(:student) } let(:extracurricular_activity_with_enrollment) { create(:extracurricular_activity, :with_enrollment) } it 'increments enrollments_count' do expect do extracurricular_activity.students << student end.to change { extracurricular_activity.reload.enrollments_count }.by(1) end it 'decrements enrollments_count' do expect do extracurricular_activity_with_enrollment.students.last.destroy end.to change { extracurricular_activity_with_enrollment.reload.enrollments_count }.by(-1) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems