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
e898c89e
Commit
e898c89e
authored
Sep 20, 2019
by
João Cunha
Committed by
Thong Kuah
Sep 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Set `inverse_of` on Clusters <-> Applications association"
parent
d682be1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
app/models/clusters/cluster.rb
app/models/clusters/cluster.rb
+1
-1
spec/models/clusters/cluster_spec.rb
spec/models/clusters/cluster_spec.rb
+9
-0
No files found.
app/models/clusters/cluster.rb
View file @
e898c89e
...
...
@@ -39,7 +39,7 @@ module Clusters
def
self
.
has_one_cluster_application
(
name
)
# rubocop:disable Naming/PredicateName
application
=
APPLICATIONS
[
name
.
to_s
]
has_one
application
.
association_name
,
class_name:
application
.
to_s
# rubocop:disable Rails/ReflectionClassName
has_one
application
.
association_name
,
class_name:
application
.
to_s
,
inverse_of: :cluster
# rubocop:disable Rails/ReflectionClassName
end
has_one_cluster_application
:helm
...
...
spec/models/clusters/cluster_spec.rb
View file @
e898c89e
...
...
@@ -38,6 +38,15 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
it
{
is_expected
.
to
respond_to
:project
}
describe
'applications have inverse_of: :cluster option'
do
let
(
:cluster
)
{
create
(
:cluster
)
}
let!
(
:helm
)
{
create
(
:clusters_applications_helm
,
cluster:
cluster
)
}
it
'does not do a third query when referencing cluster again'
do
expect
{
cluster
.
application_helm
.
cluster
}.
not_to
exceed_query_limit
(
2
)
end
end
describe
'.enabled'
do
subject
{
described_class
.
enabled
}
...
...
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