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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
3326fc75
Commit
3326fc75
authored
Jul 07, 2020
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add default_branch_name as fallback when available
parent
6566448f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletion
+32
-1
app/models/concerns/has_repository.rb
app/models/concerns/has_repository.rb
+1
-1
spec/features/projects/show/user_sees_git_instructions_spec.rb
...features/projects/show/user_sees_git_instructions_spec.rb
+1
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+30
-0
No files found.
app/models/concerns/has_repository.rb
View file @
3326fc75
...
...
@@ -76,7 +76,7 @@ module HasRepository
end
def
default_branch
@default_branch
||=
repository
.
root_ref
@default_branch
||=
repository
.
root_ref
||
Gitlab
::
CurrentSettings
.
default_branch_name
end
def
reload_default_branch
...
...
spec/features/projects/show/user_sees_git_instructions_spec.rb
View file @
3326fc75
...
...
@@ -67,6 +67,7 @@ RSpec.describe 'Projects > Show > User sees Git instructions' do
before
do
expect
(
Gitlab
::
CurrentSettings
)
.
to
receive
(
:default_branch_name
)
.
at_least
(
:once
)
.
and_return
(
'example_branch'
)
sign_in
(
project
.
owner
)
...
...
spec/models/project_spec.rb
View file @
3326fc75
...
...
@@ -4861,6 +4861,36 @@ RSpec.describe Project do
end
end
describe
"#default_branch"
do
context
"with an empty repository"
do
let_it_be
(
:project
)
{
create
(
:project_empty_repo
)
}
context
"Gitlab::CurrentSettings.default_branch_name is unavailable"
do
before
do
expect
(
Gitlab
::
CurrentSettings
)
.
to
receive
(
:default_branch_name
)
.
and_return
(
nil
)
end
it
"returns that value"
do
expect
(
project
.
default_branch
).
to
be_nil
end
end
context
"Gitlab::CurrentSettings.default_branch_name is available"
do
before
do
expect
(
Gitlab
::
CurrentSettings
)
.
to
receive
(
:default_branch_name
)
.
and_return
(
'example_branch'
)
end
it
"returns that value"
do
expect
(
project
.
default_branch
).
to
eq
(
"example_branch"
)
end
end
end
end
describe
'#to_ability_name'
do
it
'returns project'
do
project
=
build
(
:project_empty_repo
)
...
...
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