summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-09-05 00:04:56 -0700
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-09-05 00:04:56 -0700
commit6e5cd8e0810c63e8744c23cdb887fea78ea37fb4 (patch)
tree10c5d3887040acf9bd8493479b3a550c34ad1e58 /spec
parent7c76c8d34803faaf606f9a2387f37529b3e42d41 (diff)
parent5e1c63d3f0f0729a1d9d9e19c64b2fef65cc30fb (diff)
downloadgitlab-ce-6e5cd8e0810c63e8744c23cdb887fea78ea37fb4.tar.gz
Merge pull request #1375 from tsigo/discover_default_branch
Default branch auto-discovery
Diffstat (limited to 'spec')
-rw-r--r--spec/roles/repository_spec.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/roles/repository_spec.rb b/spec/roles/repository_spec.rb
index 62aecc1341f..0fda57a3e27 100644
--- a/spec/roles/repository_spec.rb
+++ b/spec/roles/repository_spec.rb
@@ -19,4 +19,54 @@ describe Project, "Repository" do
project.should_not be_empty_repo
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
+
+ describe "#root_ref" do
+ it "returns default_branch when set" do
+ project.default_branch = 'stable'
+ project.root_ref.should == 'stable'
+ end
+
+ it "returns 'master' when default_branch is nil" do
+ project.default_branch = nil
+ project.root_ref.should == 'master'
+ end
+ end
+
+ describe "#root_ref?" do
+ it "returns true when branch is root_ref" do
+ project.default_branch = 'stable'
+ project.root_ref?('stable').should be_true
+ end
+
+ it "returns false when branch is not root_ref" do
+ project.default_branch = nil
+ project.root_ref?('stable').should be_false
+ end
+ end
end