summaryrefslogtreecommitdiff
path: root/spec/models/protected_branch_spec.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2012-08-29 11:36:02 -0400
committerRobert Speicher <rspeicher@gmail.com>2012-08-29 11:36:02 -0400
commit97423a0bed1148f65f9ed2bd8bf540e764d9576c (patch)
treed91a67a6a863a97b8cf2acd76b01c18de08c2dc5 /spec/models/protected_branch_spec.rb
parent2bdea8651fa3bd82418986ada84828c22d451405 (diff)
downloadgitlab-ce-97423a0bed1148f65f9ed2bd8bf540e764d9576c.tar.gz
Add more coverage for model validations and associations
Diffstat (limited to 'spec/models/protected_branch_spec.rb')
-rw-r--r--spec/models/protected_branch_spec.rb20
1 files changed, 9 insertions, 11 deletions
diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb
index 77a214ffed2..9180bc3bca6 100644
--- a/spec/models/protected_branch_spec.rb
+++ b/spec/models/protected_branch_spec.rb
@@ -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