gitlabhq/spec/models/protected_branch_spec.rb

39 lines
904 B
Ruby
Raw Normal View History

require 'spec_helper'
describe ProtectedBranch do
2012-05-11 00:43:12 +02:00
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') }
2012-05-11 00:43:12 +02:00
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 '#commit' do
subject { ProtectedBranch.new(project: project, name: 'cant_touch_this') }
2012-05-11 00:43:12 +02:00
it 'commits itself to its project' do
project.should_receive(:commit).with('cant_touch_this')
subject.commit
end
end
end