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
9a4cab44
Commit
9a4cab44
authored
Dec 01, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unique validation in app/models/clusters/cluster.rb
parent
0ab64ac7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
app/models/clusters/cluster.rb
app/models/clusters/cluster.rb
+10
-1
No files found.
app/models/clusters/cluster.rb
View file @
9a4cab44
...
...
@@ -26,8 +26,8 @@ module Clusters
accepts_nested_attributes_for
:provider_gcp
,
update_only:
true
accepts_nested_attributes_for
:platform_kubernetes
,
update_only:
true
validates
:environment_scope
,
uniqueness:
{
scope: :project_id
}
validates
:name
,
cluster_name:
true
validate
:unique_environment_scope
validate
:restrict_modification
,
on: :update
delegate
:status
,
to: :provider
,
allow_nil:
true
...
...
@@ -93,6 +93,15 @@ module Clusters
private
def
unique_environment_scope
if
project
.
clusters
.
where
(
environment_scope:
environment_scope
).
any?
errors
.
add
(
:base
,
"cannot add duplicated environment scope"
)
return
false
end
true
end
def
restrict_modification
if
provider
&
.
on_creation?
errors
.
add
(
:base
,
"cannot modify during creation"
)
...
...
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