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
c3361c2f
Commit
c3361c2f
authored
Jun 23, 2020
by
Markus Koller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip non-project containers in Repository#project
parent
687ff73d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
app/models/repository.rb
app/models/repository.rb
+1
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+23
-0
No files found.
app/models/repository.rb
View file @
c3361c2f
...
@@ -1113,7 +1113,7 @@ class Repository
...
@@ -1113,7 +1113,7 @@ class Repository
def
project
def
project
if
repo_type
.
snippet?
if
repo_type
.
snippet?
container
.
project
container
.
project
els
e
els
if
container
.
is_a?
(
Project
)
container
container
end
end
end
end
...
...
spec/models/repository_spec.rb
View file @
c3361c2f
...
@@ -2895,6 +2895,29 @@ describe Repository do
...
@@ -2895,6 +2895,29 @@ describe Repository do
end
end
end
end
describe
'#project'
do
it
'returns the project for a project snippet'
do
snippet
=
create
(
:project_snippet
)
expect
(
snippet
.
repository
.
project
).
to
be
(
snippet
.
project
)
end
it
'returns nil for a personal snippet'
do
snippet
=
create
(
:personal_snippet
)
expect
(
snippet
.
repository
.
project
).
to
be_nil
end
it
'returns the container if it is a project'
do
expect
(
repository
.
project
).
to
be
(
project
)
end
it
'returns nil if the container is not a project'
do
expect
(
repository
).
to
receive
(
:container
).
and_return
(
Group
.
new
)
expect
(
repository
.
project
).
to
be_nil
end
end
describe
'#submodule_links'
do
describe
'#submodule_links'
do
it
'returns an instance of Gitlab::SubmoduleLinks'
do
it
'returns an instance of Gitlab::SubmoduleLinks'
do
expect
(
repository
.
submodule_links
).
to
be_a
(
Gitlab
::
SubmoduleLinks
)
expect
(
repository
.
submodule_links
).
to
be_a
(
Gitlab
::
SubmoduleLinks
)
...
...
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