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
336c988d
Commit
336c988d
authored
Nov 29, 2016
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer the `validates ... uniqueness` syntax
- Over `validates_uniqueness_of`
parent
323ed342
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
app/models/concerns/protected_branch_access_ee.rb
app/models/concerns/protected_branch_access_ee.rb
+4
-6
No files found.
app/models/concerns/protected_branch_access_ee.rb
View file @
336c988d
...
...
@@ -10,12 +10,10 @@ module ProtectedBranchAccessEe
belongs_to
:user
belongs_to
:group
validates_uniqueness_of
:group_id
,
scope: :protected_branch
,
allow_nil:
true
validates_uniqueness_of
:user_id
,
scope: :protected_branch
,
allow_nil:
true
validates_uniqueness_of
:access_level
,
scope: :protected_branch
,
if: :role?
,
conditions:
->
{
where
(
user_id:
nil
,
group_id:
nil
)
}
validates
:group_id
,
uniqueness:
{
scope: :protected_branch
,
allow_nil:
true
}
validates
:user_id
,
uniqueness:
{
scope: :protected_branch
,
allow_nil:
true
}
validates
:access_level
,
uniqueness:
{
scope: :protected_branch
,
if: :role?
,
conditions:
->
{
where
(
user_id:
nil
,
group_id:
nil
)
}
}
scope
:by_user
,
->
(
user
)
{
where
(
user:
user
)
}
scope
:by_group
,
->
(
group
)
{
where
(
group:
group
)
}
...
...
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