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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
a02e2243
Commit
a02e2243
authored
Apr 20, 2019
by
Jacob Vosmaer
Committed by
Stan Hu
Apr 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix wrong use of ActiveRecord in PoolRepository
parent
9c2b37d7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
8 deletions
+16
-8
app/models/pool_repository.rb
app/models/pool_repository.rb
+3
-2
app/models/project.rb
app/models/project.rb
+3
-5
changelogs/unreleased/jv-dedup-activerecord.yml
changelogs/unreleased/jv-dedup-activerecord.yml
+6
-0
spec/factories/pool_repositories.rb
spec/factories/pool_repositories.rb
+1
-0
spec/models/pool_repository_spec.rb
spec/models/pool_repository_spec.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+2
-0
No files found.
app/models/pool_repository.rb
View file @
a02e2243
...
...
@@ -7,7 +7,7 @@ class PoolRepository < ApplicationRecord
include
Shardable
include
AfterCommitQueue
has_one
:source_project
,
class_name:
'Project'
belongs_to
:source_project
,
class_name:
'Project'
validates
:source_project
,
presence:
true
has_many
:member_projects
,
class_name:
'Project'
...
...
@@ -99,7 +99,8 @@ class PoolRepository < ApplicationRecord
end
def
inspect
"#<
#{
self
.
class
.
name
}
id:
#{
id
}
state:
#{
state
}
disk_path:
#{
disk_path
}
source_project:
#{
source_project
.
full_path
}
>"
source
=
source_project
?
source_project
.
full_path
:
'nil'
"#<
#{
self
.
class
.
name
}
id:
#{
id
}
state:
#{
state
}
disk_path:
#{
disk_path
}
source_project:
#{
source
}
>"
end
private
...
...
app/models/project.rb
View file @
a02e2243
...
...
@@ -2131,13 +2131,11 @@ class Project < ApplicationRecord
end
def
create_new_pool_repository
pool
=
begin
create_pool_repository!
(
shard:
Shard
.
by_name
(
repository_storage
),
source_project:
self
)
rescue
ActiveRecord
::
RecordNotUnique
pool_repository
(
true
)
end
pool
=
PoolRepository
.
safe_find_or_create_by!
(
shard:
Shard
.
by_name
(
repository_storage
),
source_project:
self
)
update!
(
pool_repository:
pool
)
pool
.
schedule
unless
pool
.
scheduled?
pool
end
...
...
changelogs/unreleased/jv-dedup-activerecord.yml
0 → 100644
View file @
a02e2243
---
title
:
Fix wrong use of ActiveRecord in PoolRepository
merge_request
:
27464
author
:
type
:
fixed
spec/factories/pool_repositories.rb
View file @
a02e2243
...
...
@@ -5,6 +5,7 @@ FactoryBot.define do
before
(
:create
)
do
|
pool
|
pool
.
source_project
=
create
(
:project
,
:repository
)
pool
.
source_project
.
update!
(
pool_repository:
pool
)
end
trait
:scheduled
do
...
...
spec/models/pool_repository_spec.rb
View file @
a02e2243
...
...
@@ -5,7 +5,7 @@ require 'spec_helper'
describe
PoolRepository
do
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:shard
)
}
it
{
is_expected
.
to
have_one
(
:source_project
)
}
it
{
is_expected
.
to
belong_to
(
:source_project
)
}
it
{
is_expected
.
to
have_many
(
:member_projects
)
}
end
...
...
spec/models/project_spec.rb
View file @
a02e2243
...
...
@@ -4702,6 +4702,8 @@ describe Project do
it
'returns that pool repository'
do
expect
(
subject
).
not_to
be_empty
expect
(
subject
[
:pool_repository
]).
to
be_persisted
expect
(
project
.
reload
.
pool_repository
).
to
eq
(
subject
[
:pool_repository
])
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