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
05fca188
Commit
05fca188
authored
Jun 28, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Geo::RepositoryRenamedEventStore
parent
97192401
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
10 deletions
+59
-10
app/services/geo/repository_renamed_event_store.rb
app/services/geo/repository_renamed_event_store.rb
+17
-10
spec/services/geo/repository_renamed_event_store_spec.rb
spec/services/geo/repository_renamed_event_store_spec.rb
+42
-0
No files found.
app/services/geo/repository_renamed_event_store.rb
View file @
05fca188
module
Geo
class
RepositoryRenamedEventStore
attr_reader
:project
,
:old_
repo_path
,
:old_wiki_path
,
:old_nam
e
attr_reader
:project
,
:old_
path
,
:old_path_with_namespac
e
def
initialize
(
project
,
old_
repo_path
:,
old_wiki_path
:,
old_nam
e
:)
def
initialize
(
project
,
old_
path
:,
old_path_with_namespac
e
:)
@project
=
project
@old_repo_path
=
old_repo_path
@old_wiki_path
=
old_wiki_path
@old_name
=
old_name
@old_path
=
old_path
@old_path_with_namespace
=
old_path_with_namespace
end
def
create
...
...
@@ -28,15 +27,23 @@ module Geo
project:
project
,
repository_storage_name:
project
.
repository
.
storage
,
repository_storage_path:
project
.
repository_storage_path
,
old_path_with_namespace:
old_path_with_namespace
,
new_path_with_namespace:
project
.
full_path
,
old_path_with_namespace:
old_repo_path
,
old_wiki_path_with_namespace:
old_wiki_path
,
new_wiki_path_with_namespace:
project
.
wiki
.
path_with_namespace
,
old_project_name:
old_project_name
,
new_project_name:
project
.
name
old_wiki_path_with_namespace:
old_wiki_path_with_namespace
,
new_wiki_path_with_namespace:
new_wiki_path_with_namespace
,
old_path:
old_path
,
new_path:
project
.
path
)
end
def
old_wiki_path_with_namespace
"
#{
old_path_with_namespace
}
.wiki"
end
def
new_wiki_path_with_namespace
project
.
wiki
.
path_with_namespace
end
def
log
(
message
)
Rails
.
logger
.
info
(
"
#{
self
.
class
.
name
}
:
#{
message
}
for project
#{
project
.
path_with_namespace
}
(
#{
project
.
id
}
)"
)
end
...
...
spec/services/geo/repository_renamed_event_store_spec.rb
0 → 100644
View file @
05fca188
require
'spec_helper'
describe
Geo
::
RepositoryRenamedEventStore
,
services:
true
do
let
(
:project
)
{
create
(
:empty_project
,
path:
'bar'
)
}
let
(
:old_path
)
{
'foo'
}
let
(
:old_path_with_namespace
)
{
"
#{
project
.
namespace
.
full_path
}
/foo"
}
subject
{
described_class
.
new
(
project
,
old_path:
old_path
,
old_path_with_namespace:
old_path_with_namespace
)
}
describe
'#create'
do
it
'does not create an event when not running on a primary node'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
false
}
expect
{
subject
.
create
}.
not_to
change
(
Geo
::
RepositoryRenamedEvent
,
:count
)
end
context
'when running on a primary node'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
end
it
'creates a renamed event'
do
expect
{
subject
.
create
}.
to
change
(
Geo
::
RepositoryRenamedEvent
,
:count
).
by
(
1
)
end
it
'tracks old and new paths for project repositories'
do
subject
.
create
event
=
Geo
::
RepositoryRenamedEvent
.
last
expect
(
event
.
repository_storage_name
).
to
eq
(
project
.
repository_storage
)
expect
(
event
.
repository_storage_path
).
to
eq
(
project
.
repository_storage_path
)
expect
(
event
.
old_path_with_namespace
).
to
eq
(
old_path_with_namespace
)
expect
(
event
.
new_path_with_namespace
).
to
eq
(
project
.
full_path
)
expect
(
event
.
old_wiki_path_with_namespace
).
to
eq
(
"
#{
old_path_with_namespace
}
.wiki"
)
expect
(
event
.
new_wiki_path_with_namespace
).
to
eq
(
"
#{
project
.
full_path
}
.wiki"
)
expect
(
event
.
old_path
).
to
eq
(
old_path
)
expect
(
event
.
new_path
).
to
eq
(
project
.
path
)
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