Add specs for Project#discover_default_branch
This commit is contained in:
parent
42032956bd
commit
36738897bf
|
@ -19,4 +19,30 @@ describe Project, "Repository" do
|
||||||
project.should_not be_empty_repo
|
project.should_not be_empty_repo
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#discover_default_branch" do
|
||||||
|
let(:master) { double(name: 'master') }
|
||||||
|
let(:stable) { double(name: 'stable') }
|
||||||
|
|
||||||
|
it "returns 'master' when master exists" do
|
||||||
|
project.should_receive(:heads).and_return([stable, master])
|
||||||
|
project.discover_default_branch.should == 'master'
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns non-master when master exists but default branch is set to something else" do
|
||||||
|
project.default_branch = 'stable'
|
||||||
|
project.should_receive(:heads).and_return([stable, master])
|
||||||
|
project.discover_default_branch.should == 'stable'
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns a non-master branch when only one exists" do
|
||||||
|
project.should_receive(:heads).and_return([stable])
|
||||||
|
project.discover_default_branch.should == 'stable'
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns nil when no branch exists" do
|
||||||
|
project.should_receive(:heads).and_return([])
|
||||||
|
project.discover_default_branch.should be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue