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
67a3fe27
Commit
67a3fe27
authored
Jan 18, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split create_wiki_repository
parent
3e67e371
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
ee/app/models/group_wiki.rb
ee/app/models/group_wiki.rb
+5
-1
ee/spec/models/group_wiki_spec.rb
ee/spec/models/group_wiki_spec.rb
+18
-9
No files found.
ee/app/models/group_wiki.rb
View file @
67a3fe27
...
@@ -8,8 +8,12 @@ class GroupWiki < Wiki
...
@@ -8,8 +8,12 @@ class GroupWiki < Wiki
def
create_wiki_repository
def
create_wiki_repository
super
super
track_wiki_repository
(
repository
.
shard
)
end
def
track_wiki_repository
(
shard
)
storage_record
=
container
.
group_wiki_repository
||
container
.
build_group_wiki_repository
storage_record
=
container
.
group_wiki_repository
||
container
.
build_group_wiki_repository
storage_record
.
update!
(
shard_name:
repository
.
shard
,
disk_path:
storage
.
disk_path
)
storage_record
.
update!
(
shard_name:
shard
,
disk_path:
storage
.
disk_path
)
end
end
override
:storage
override
:storage
...
...
ee/spec/models/group_wiki_spec.rb
View file @
67a3fe27
...
@@ -12,46 +12,55 @@ RSpec.describe GroupWiki do
...
@@ -12,46 +12,55 @@ RSpec.describe GroupWiki do
end
end
describe
'#create_wiki_repository'
do
describe
'#create_wiki_repository'
do
before
do
it
'tracks the repository storage in the database'
do
shard
=
'foo'
# Use a custom storage shard value, to make sure we're not falling back to the default.
# Use a custom storage shard value, to make sure we're not falling back to the default.
allow
(
subject
).
to
receive
(
:repository_storage
).
and_return
(
'foo'
)
allow
(
subject
).
to
receive
(
:repository_storage
).
and_return
(
shard
)
# Don't actually create the repository, because the storage shard doesn't exist.
# Don't actually create the repository, because the storage shard doesn't exist.
allow
(
subject
.
repository
).
to
receive
(
:create_if_not_exists
)
expect
(
subject
.
repository
).
to
receive
(
:create_if_not_exists
)
allow
(
subject
).
to
receive
(
:repository_exists?
).
and_return
(
true
)
allow
(
subject
).
to
receive
(
:repository_exists?
).
and_return
(
true
)
expect
(
subject
).
to
receive
(
:track_wiki_repository
).
with
(
shard
)
subject
.
create_wiki_repository
end
end
end
describe
'#track_wiki_repository'
do
let
(
:shard
)
{
'foo'
}
context
'when a tracking entry does not exist'
do
context
'when a tracking entry does not exist'
do
let
(
:wiki_container
)
{
wiki_container_without_repo
}
let
(
:wiki_container
)
{
wiki_container_without_repo
}
it
'creates a new entry'
do
it
'creates a new entry'
do
expect
{
subject
.
create_wiki_repository
}.
to
change
(
wiki_container
,
:group_wiki_repository
)
expect
{
subject
.
track_wiki_repository
(
shard
)
}.
to
change
(
wiki_container
,
:group_wiki_repository
)
.
from
(
nil
).
to
(
kind_of
(
GroupWikiRepository
))
.
from
(
nil
).
to
(
kind_of
(
GroupWikiRepository
))
end
end
it
'tracks the storage location'
do
it
'tracks the storage location'
do
subject
.
create_wiki_repository
subject
.
track_wiki_repository
(
shard
)
expect
(
wiki_container
.
group_wiki_repository
).
to
have_attributes
(
expect
(
wiki_container
.
group_wiki_repository
).
to
have_attributes
(
disk_path:
subject
.
storage
.
disk_path
,
disk_path:
subject
.
storage
.
disk_path
,
shard_name:
'foo'
shard_name:
shard
)
)
end
end
end
end
context
'when a tracking entry exists'
do
context
'when a tracking entry exists'
do
it
'does not create a new entry in the database'
do
it
'does not create a new entry in the database'
do
expect
{
subject
.
create_wiki_repository
}.
not_to
change
(
wiki_container
,
:group_wiki_repository
)
expect
{
subject
.
track_wiki_repository
(
shard
)
}.
not_to
change
(
wiki_container
,
:group_wiki_repository
)
end
end
it
'updates the storage location'
do
it
'updates the storage location'
do
expect
(
subject
.
storage
).
to
receive
(
:disk_path
).
and_return
(
'fancy/new/path'
)
expect
(
subject
.
storage
).
to
receive
(
:disk_path
).
and_return
(
'fancy/new/path'
)
subject
.
create_wiki_repository
subject
.
track_wiki_repository
(
shard
)
expect
(
wiki_container
.
group_wiki_repository
).
to
have_attributes
(
expect
(
wiki_container
.
group_wiki_repository
).
to
have_attributes
(
disk_path:
'fancy/new/path'
,
disk_path:
'fancy/new/path'
,
shard_name:
'foo'
shard_name:
shard
)
)
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