blob: 1654e3b6f56b9f859d13f865363abb072d4a9eff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# == Schema Information
#
# Table name: protected_branches
#
# id :integer(4) not null, primary key
# project_id :integer(4) not null
# name :string(255) not null
# created_at :datetime not null
# updated_at :datetime not null
#
require 'spec_helper'
describe ProtectedBranch do
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 '#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
|