Add more coverage for model validations and associations

This commit is contained in:
Robert Speicher 2012-08-29 11:36:02 -04:00
parent 2bdea8651f
commit 97423a0bed
12 changed files with 96 additions and 50 deletions

View file

@ -1,8 +1,6 @@
require 'spec_helper'
describe ProtectedBranch do
let(:project) { Factory(:project) }
describe 'Associations' do
it { should belong_to(:project) }
end
@ -13,26 +11,26 @@ describe ProtectedBranch do
end
describe 'Callbacks' do
subject { ProtectedBranch.new(project: project, name: 'branch_name') }
let(:branch) { build(:protected_branch) }
it 'call update_repository after save' do
subject.should_receive(:update_repository)
subject.save
branch.should_receive(:update_repository)
branch.save
end
it 'call update_repository after destroy' do
subject.should_receive(:update_repository)
subject.destroy
branch.save
branch.should_receive(:update_repository)
branch.destroy
end
end
describe '#commit' do
subject { ProtectedBranch.new(project: project, name: 'cant_touch_this') }
let(:branch) { create(:protected_branch) }
it 'commits itself to its project' do
project.should_receive(:commit).with('cant_touch_this')
subject.commit
branch.project.should_receive(:commit).with(branch.name)
branch.commit
end
end
end