gitlabhq/spec/models/protected_branch_spec.rb

37 lines
817 B
Ruby
Raw Normal View History

require 'spec_helper'
describe ProtectedBranch do
2012-05-11 00:43:12 +02:00
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
let(:branch) { build(:protected_branch) }
2012-05-11 00:43:12 +02:00
it 'call update_repository after save' do
branch.should_receive(:update_repository)
branch.save
2012-05-11 00:43:12 +02:00
end
it 'call update_repository after destroy' do
branch.save
branch.should_receive(:update_repository)
branch.destroy
2012-05-11 00:43:12 +02:00
end
end
describe '#commit' do
let(:branch) { create(:protected_branch) }
2012-05-11 00:43:12 +02:00
it 'commits itself to its project' do
branch.project.should_receive(:commit).with(branch.name)
branch.commit
2012-05-11 00:43:12 +02:00
end
end
end