Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
projects.thm.de
GitLab
Commits
2a64607b
Commit
2a64607b
authored
Jun 28, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Project#ensure_repository
parent
4f620eb9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
app/models/project.rb
app/models/project.rb
+4
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+31
-0
No files found.
app/models/project.rb
View file @
2a64607b
...
...
@@ -1094,6 +1094,10 @@ def create_repository
end
end
def
ensure_repository
create_repository
unless
repository_exists?
end
def
repository_exists?
!!
repository
.
exists?
end
...
...
spec/models/project_spec.rb
View file @
2a64607b
...
...
@@ -1327,6 +1327,37 @@ def create_pipeline
end
end
describe
'#ensure_repository'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:shell
)
{
Gitlab
::
Shell
.
new
}
before
do
allow
(
project
).
to
receive
(
:gitlab_shell
).
and_return
(
shell
)
end
it
'creates the repository if it not exist'
do
allow
(
project
).
to
receive
(
:repository_exists?
)
.
and_return
(
false
)
allow
(
shell
).
to
receive
(
:add_repository
)
.
with
(
project
.
repository_storage_path
,
project
.
path_with_namespace
)
.
and_return
(
true
)
expect
(
project
).
to
receive
(
:create_repository
)
project
.
ensure_repository
end
it
'does not create the repository if it exists'
do
allow
(
project
).
to
receive
(
:repository_exists?
)
.
and_return
(
true
)
expect
(
project
).
not_to
receive
(
:create_repository
)
project
.
ensure_repository
end
end
describe
'#user_can_push_to_empty_repo?'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
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