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
77683e47
Commit
77683e47
authored
Nov 07, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Geo::HashedStorageMigratedEvent model
parent
925f3f78
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
1 deletion
+55
-1
app/models/geo/event_log.rb
app/models/geo/event_log.rb
+6
-1
app/models/geo/hashed_storage_migrated_event.rb
app/models/geo/hashed_storage_migrated_event.rb
+11
-0
spec/factories/geo/event_log.rb
spec/factories/geo/event_log.rb
+12
-0
spec/models/geo/event_log_spec.rb
spec/models/geo/event_log_spec.rb
+8
-0
spec/models/geo/hashed_storage_migrated_event_spec.rb
spec/models/geo/hashed_storage_migrated_event_spec.rb
+18
-0
No files found.
app/models/geo/event_log.rb
View file @
77683e47
...
...
@@ -22,6 +22,10 @@ module Geo
class_name:
'Geo::RepositoriesChangedEvent'
,
foreign_key: :repositories_changed_event_id
belongs_to
:hashed_storage_migrated_event
,
class_name:
'Geo::HashedStorageMigratedEvent'
,
foreign_key: :hashed_storage_migrated_event_id
def
self
.
latest_event
order
(
id: :desc
).
first
end
...
...
@@ -31,7 +35,8 @@ module Geo
repository_updated_event
||
repository_deleted_event
||
repository_renamed_event
||
repositories_changed_event
repositories_changed_event
||
hashed_storage_migrated_event
end
def
project_id
...
...
app/models/geo/hashed_storage_migrated_event.rb
0 → 100644
View file @
77683e47
module
Geo
class
HashedStorageMigratedEvent
<
ActiveRecord
::
Base
include
Geo
::
Model
belongs_to
:project
validates
:project
,
:repository_storage_name
,
:repository_storage_path
,
:old_disk_path
,
:new_disk_path
,
:old_wiki_disk_path
,
:new_wiki_disk_path
,
:new_storage_version
,
presence:
true
end
end
spec/factories/geo/event_log.rb
View file @
77683e47
...
...
@@ -73,4 +73,16 @@ FactoryGirl.define do
old_path
{
project
.
path
}
new_path
{
project
.
path
+
'_new'
}
end
factory
:geo_hashed_storage_migrated_event
,
class:
Geo
::
HashedStorageMigratedEvent
do
project
{
create
(
:project
,
:repository
)
}
repository_storage_name
{
project
.
repository_storage
}
repository_storage_path
{
project
.
repository_storage_path
}
old_disk_path
{
project
.
path_with_namespace
}
new_disk_path
{
project
.
path_with_namespace
+
'_new'
}
old_wiki_disk_path
{
project
.
wiki
.
path_with_namespace
}
new_wiki_disk_path
{
project
.
wiki
.
path_with_namespace
+
'_new'
}
new_storage_version
{
Project
::
LATEST_STORAGE_VERSION
}
end
end
spec/models/geo/event_log_spec.rb
View file @
77683e47
...
...
@@ -7,6 +7,7 @@ RSpec.describe Geo::EventLog, type: :model do
it
{
is_expected
.
to
belong_to
(
:repository_deleted_event
).
class_name
(
'Geo::RepositoryDeletedEvent'
).
with_foreign_key
(
'repository_deleted_event_id'
)
}
it
{
is_expected
.
to
belong_to
(
:repository_renamed_event
).
class_name
(
'Geo::RepositoryRenamedEvent'
).
with_foreign_key
(
'repository_renamed_event_id'
)
}
it
{
is_expected
.
to
belong_to
(
:repository_updated_event
).
class_name
(
'Geo::RepositoryUpdatedEvent'
).
with_foreign_key
(
'repository_updated_event_id'
)
}
it
{
is_expected
.
to
belong_to
(
:hashed_storage_migrated_event
).
class_name
(
'Geo::HashedStorageMigratedEvent'
).
with_foreign_key
(
'hashed_storage_migrated_event_id'
)
}
end
describe
'#event'
do
...
...
@@ -48,6 +49,13 @@ RSpec.describe Geo::EventLog, type: :model do
expect
(
subject
.
event
).
to
eq
repositories_changed_event
end
it
'returns hashed_storage_migrated_event when set'
do
hashed_storage_migrated_event
=
build
(
:geo_hashed_storage_migrated_event
)
subject
.
hashed_storage_migrated_event
=
hashed_storage_migrated_event
expect
(
subject
.
event
).
to
eq
hashed_storage_migrated_event
end
end
describe
'#project_id'
do
...
...
spec/models/geo/hashed_storage_migrated_event_spec.rb
0 → 100644
View file @
77683e47
require
'spec_helper'
RSpec
.
describe
Geo
::
HashedStorageMigratedEvent
,
type: :model
do
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
end
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:repository_storage_name
)
}
it
{
is_expected
.
to
validate_presence_of
(
:repository_storage_path
)
}
it
{
is_expected
.
to
validate_presence_of
(
:old_disk_path
)
}
it
{
is_expected
.
to
validate_presence_of
(
:new_disk_path
)
}
it
{
is_expected
.
to
validate_presence_of
(
:old_wiki_disk_path
)
}
it
{
is_expected
.
to
validate_presence_of
(
:new_wiki_disk_path
)
}
it
{
is_expected
.
to
validate_presence_of
(
:new_storage_version
)
}
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