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
a0222cf8
Commit
a0222cf8
authored
Dec 18, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track storage location for legacy storage projects
parent
a9049532
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
17 deletions
+43
-17
app/models/project.rb
app/models/project.rb
+2
-4
spec/models/project_spec.rb
spec/models/project_spec.rb
+41
-13
No files found.
app/models/project.rb
View file @
a0222cf8
...
@@ -1244,10 +1244,8 @@ class Project < ActiveRecord::Base
...
@@ -1244,10 +1244,8 @@ class Project < ActiveRecord::Base
end
end
def
track_project_repository
def
track_project_repository
return
unless
hashed_storage?
(
:repository
)
repository
=
project_repository
||
build_project_repository
repository
.
update!
(
shard_name:
repository_storage
,
disk_path:
disk_path
)
project_repo
=
project_repository
||
build_project_repository
project_repo
.
update!
(
shard_name:
repository_storage
,
disk_path:
disk_path
)
end
end
def
create_repository
(
force:
false
)
def
create_repository
(
force:
false
)
...
...
spec/models/project_spec.rb
View file @
a0222cf8
...
@@ -1651,26 +1651,54 @@ describe Project do
...
@@ -1651,26 +1651,54 @@ describe Project do
end
end
describe
'#track_project_repository'
do
describe
'#track_project_repository'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
shared_examples
'tracks storage location'
do
context
'when a project repository entry does not exist'
do
it
'creates a new entry'
do
expect
{
project
.
track_project_repository
}.
to
change
(
project
,
:project_repository
)
end
it
'creates a project_repository
'
do
it
'tracks the project storage location
'
do
project
.
track_project_repository
project
.
track_project_repository
expect
(
project
.
reload
.
project_repository
).
to
be_present
expect
(
project
.
project_repository
).
to
have_attributes
(
expect
(
project
.
project_repository
.
disk_path
).
to
eq
(
project
.
disk_path
)
disk_path:
project
.
disk_path
,
expect
(
project
.
project_repository
.
shard_name
).
to
eq
(
project
.
repository_storage
)
shard_name:
project
.
repository_storage
)
end
end
end
it
'updates the project_repository'
do
context
'when a tracking entry exists'
do
project
.
track_project_repository
let!
(
:project_repository
)
{
create
(
:project_repository
,
project:
project
)
}
let!
(
:shard
)
{
create
(
:shard
,
name:
'foo'
)
}
allow
(
project
).
to
receive
(
:disk_path
).
and_return
(
'@fancy/new/path'
)
it
'does not create a new entry in the database'
do
expect
{
project
.
track_project_repository
}.
not_to
change
(
project
,
:project_repository
)
end
it
'updates the project storage location'
do
allow
(
project
).
to
receive
(
:disk_path
).
and_return
(
'fancy/new/path'
)
allow
(
project
).
to
receive
(
:repository_storage
).
and_return
(
'foo'
)
expect
do
project
.
track_project_repository
project
.
track_project_repository
end
.
not_to
change
(
ProjectRepository
,
:count
)
expect
(
project
.
reload
.
project_repository
.
disk_path
).
to
eq
(
project
.
disk_path
)
expect
(
project
.
project_repository
).
to
have_attributes
(
disk_path:
'fancy/new/path'
,
shard_name:
'foo'
)
end
end
end
context
'with projects on legacy storage'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
:legacy_storage
)
}
it_behaves_like
'tracks storage location'
end
context
'with projects on hashed storage'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
it_behaves_like
'tracks storage location'
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