diff options
author | Robb Kidd <robb@thekidds.org> | 2012-05-11 02:43:12 +0400 |
---|---|---|
committer | Robb Kidd <robb@thekidds.org> | 2012-05-11 02:43:12 +0400 |
commit | d50446088c05409604f8daad0879a23b3c5f5e8f (patch) | |
tree | 4cdab27bc21372de3a194be1d157d1d876c5ef45 /spec/models/protected_branch_spec.rb | |
parent | 9e5c016847f99350d3eb5444d58a9e9944294fc6 (diff) |
Add spec for ProtectedBranch.
Diffstat (limited to 'spec/models/protected_branch_spec.rb')
-rw-r--r-- | spec/models/protected_branch_spec.rb | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb index a0b0032a558..ce79f674787 100644 --- a/spec/models/protected_branch_spec.rb +++ b/spec/models/protected_branch_spec.rb @@ -12,5 +12,51 @@ require 'spec_helper' describe ProtectedBranch do - pending "add some examples to (or delete) #{__FILE__}" + let(:project) { Factory(:project) } + + describe 'Associations' do + it { should belong_to(:project) } + end + + describe 'Validation' do + it { should validate_presence_of(:project_id) } + it { should validate_presence_of(:name) } + end + + describe 'Callbacks' do + subject { ProtectedBranch.new(:project => project, :name => 'branch_name') } + + it 'call update_repository after save' do + subject.should_receive(:update_repository) + subject.save + end + + it 'call update_repository after destroy' do + subject.should_receive(:update_repository) + subject.destroy + end + end + + describe '#update_repository' do + let(:gitolite) { mock } + + subject { ProtectedBranch.new(:project => project) } + + it "updates the branch's project repo permissions" do + Gitlabhq::GitHost.should_receive(:system).and_return(gitolite) + gitolite.should_receive(:update_project).with(project.path, project) + + subject.update_repository + end + end + + describe '#commit' do + subject { ProtectedBranch.new(:project => project, :name => 'cant_touch_this') } + + it 'commits itself to its project' do + project.should_receive(:commit).with('cant_touch_this') + + subject.commit + end + end end |