diff --git a/spec/factories/project_statistic.rb b/spec/factories/project_statistic.rb new file mode 100644 index 000000000..ec381ef09 --- /dev/null +++ b/spec/factories/project_statistic.rb @@ -0,0 +1,7 @@ +# -*- encoding : utf-8 -*- +FactoryGirl.define do + factory :project_statistic do + association :project, :factory => :project + association :arch, :factory => :arch + end +end diff --git a/spec/models/project_statistic_spec.rb b/spec/models/project_statistic_spec.rb new file mode 100644 index 000000000..e13a0ec20 --- /dev/null +++ b/spec/models/project_statistic_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe ProjectStatistic do + + context 'ensures that validations and associations exist' do + it { should belong_to(:project) } + it { should belong_to(:arch) } + + it { should validate_presence_of(:project_id) } + it { should validate_presence_of(:arch_id) } + it { should validate_presence_of(:average_build_time) } + it { should validate_presence_of(:build_count) } + + it { should_not allow_mass_assignment_of(:project_id) } + it { should_not allow_mass_assignment_of(:arch_id) } + + it 'uniqueness of project_id and arch_id' do + FactoryGirl.create(:project_statistic) + should validate_uniqueness_of(:project_id).scoped_to(:arch_id) + end + + end + +end