2012-02-15 20:02:33 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ProtectedBranch do
|
2012-05-10 22:43:12 +00:00
|
|
|
describe 'Associations' do
|
|
|
|
it { should belong_to(:project) }
|
|
|
|
end
|
|
|
|
|
2012-09-26 18:17:17 +00:00
|
|
|
describe "Mass assignment" do
|
|
|
|
it { should_not allow_mass_assignment_of(:project_id) }
|
|
|
|
end
|
|
|
|
|
2012-05-10 22:43:12 +00:00
|
|
|
describe 'Validation' do
|
2012-10-09 00:10:16 +00:00
|
|
|
it { should validate_presence_of(:project) }
|
2012-05-10 22:43:12 +00:00
|
|
|
it { should validate_presence_of(:name) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Callbacks' do
|
2012-08-29 15:36:02 +00:00
|
|
|
let(:branch) { build(:protected_branch) }
|
2012-05-10 22:43:12 +00:00
|
|
|
|
|
|
|
it 'call update_repository after save' do
|
2012-08-29 15:36:02 +00:00
|
|
|
branch.should_receive(:update_repository)
|
|
|
|
branch.save
|
2012-05-10 22:43:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'call update_repository after destroy' do
|
2012-08-29 15:36:02 +00:00
|
|
|
branch.save
|
|
|
|
branch.should_receive(:update_repository)
|
|
|
|
branch.destroy
|
2012-05-10 22:43:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#commit' do
|
2012-08-29 15:36:02 +00:00
|
|
|
let(:branch) { create(:protected_branch) }
|
2012-05-10 22:43:12 +00:00
|
|
|
|
|
|
|
it 'commits itself to its project' do
|
2012-08-29 15:36:02 +00:00
|
|
|
branch.project.should_receive(:commit).with(branch.name)
|
|
|
|
branch.commit
|
2012-05-10 22:43:12 +00:00
|
|
|
end
|
|
|
|
end
|
2012-02-15 20:02:33 +00:00
|
|
|
end
|