Skip to content

Commit c7148c3

Browse files
author
root
committed
Add tests for RepositoryProtectedBranche
1 parent 6a0df15 commit c7148c3

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

Diff for: spec/factories/repository_protected_branche.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FactoryGirl.define do
2+
3+
factory :repository_protected_branche do |protected_branch|
4+
5+
end
6+
7+
end

Diff for: spec/models/repository_protected_branche_spec.rb

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2+
3+
describe RepositoryProtectedBranche do
4+
5+
before(:all) do
6+
@project = FactoryGirl.create(:project)
7+
@repository = FactoryGirl.create(:repository, :project_id => @project.id)
8+
end
9+
10+
11+
def build_protected_branch(opts = {})
12+
opts = opts.merge(:repository_id => @repository.id)
13+
FactoryGirl.build(:repository_protected_branche, opts)
14+
end
15+
16+
17+
describe "Valid RepositoryProtectedBranche creation" do
18+
before do
19+
@protected_branch = build_protected_branch(:path => 'devel', :permissions => 'RW', :user_list => %w(user1 user2))
20+
end
21+
22+
subject { @protected_branch }
23+
24+
## Attributes
25+
it { should allow_mass_assignment_of(:path) }
26+
it { should allow_mass_assignment_of(:permissions) }
27+
it { should allow_mass_assignment_of(:position) }
28+
it { should allow_mass_assignment_of(:user_list) }
29+
30+
## Relations
31+
it { should belong_to(:repository) }
32+
33+
## Validations
34+
it { should be_valid }
35+
36+
it { should validate_presence_of(:repository_id) }
37+
it { should validate_presence_of(:path) }
38+
it { should validate_presence_of(:permissions) }
39+
it { should validate_presence_of(:user_list) }
40+
41+
it {
42+
should ensure_inclusion_of(:permissions).
43+
in_array(%w(RW RW+))
44+
}
45+
46+
## Serializations
47+
it { should serialize(:user_list) }
48+
end
49+
end

0 commit comments

Comments
 (0)