Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
9f0e8059
Commit
9f0e8059
authored
Sep 26, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Repository role spec
parent
e9bd4506
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
app/roles/repository.rb
app/roles/repository.rb
+3
-0
spec/roles/repository_spec.rb
spec/roles/repository_spec.rb
+6
-6
No files found.
app/roles/repository.rb
View file @
9f0e8059
...
@@ -45,14 +45,17 @@ module Repository
...
@@ -45,14 +45,17 @@ module Repository
File
.
exists?
(
hook_file
)
File
.
exists?
(
hook_file
)
end
end
# Returns an Array of branch names
def
branches
def
branches
repo
.
branches
.
collect
(
&
:name
).
sort
repo
.
branches
.
collect
(
&
:name
).
sort
end
end
# Returns an Array of tag names
def
tags
def
tags
repo
.
tags
.
collect
(
&
:name
).
sort
.
reverse
repo
.
tags
.
collect
(
&
:name
).
sort
.
reverse
end
end
# Returns an Array of branch and tag names
def
ref_names
def
ref_names
[
branches
+
tags
].
flatten
[
branches
+
tags
].
flatten
end
end
...
...
spec/roles/repository_spec.rb
View file @
9f0e8059
...
@@ -21,27 +21,27 @@ describe Project, "Repository" do
...
@@ -21,27 +21,27 @@ describe Project, "Repository" do
end
end
describe
"#discover_default_branch"
do
describe
"#discover_default_branch"
do
let
(
:master
)
{
double
(
name:
'master'
)
}
let
(
:master
)
{
'master'
}
let
(
:stable
)
{
double
(
name:
'stable'
)
}
let
(
:stable
)
{
'stable'
}
it
"returns 'master' when master exists"
do
it
"returns 'master' when master exists"
do
project
.
should_receive
(
:
heads
).
and_return
([
stable
,
master
])
project
.
should_receive
(
:
branches
).
at_least
(
:once
).
and_return
([
stable
,
master
])
project
.
discover_default_branch
.
should
==
'master'
project
.
discover_default_branch
.
should
==
'master'
end
end
it
"returns non-master when master exists but default branch is set to something else"
do
it
"returns non-master when master exists but default branch is set to something else"
do
project
.
default_branch
=
'stable'
project
.
default_branch
=
'stable'
project
.
should_receive
(
:
heads
).
and_return
([
stable
,
master
])
project
.
should_receive
(
:
branches
).
at_least
(
:once
).
and_return
([
stable
,
master
])
project
.
discover_default_branch
.
should
==
'stable'
project
.
discover_default_branch
.
should
==
'stable'
end
end
it
"returns a non-master branch when only one exists"
do
it
"returns a non-master branch when only one exists"
do
project
.
should_receive
(
:
heads
).
and_return
([
stable
])
project
.
should_receive
(
:
branches
).
at_least
(
:once
).
and_return
([
stable
])
project
.
discover_default_branch
.
should
==
'stable'
project
.
discover_default_branch
.
should
==
'stable'
end
end
it
"returns nil when no branch exists"
do
it
"returns nil when no branch exists"
do
project
.
should_receive
(
:
heads
).
and_return
([])
project
.
should_receive
(
:
branches
).
at_least
(
:once
).
and_return
([])
project
.
discover_default_branch
.
should
be_nil
project
.
discover_default_branch
.
should
be_nil
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment