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
1adcbbb4
Commit
1adcbbb4
authored
Sep 27, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix validation
parent
5a8eddc7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
6 deletions
+20
-6
app/models/ldap_group_link.rb
app/models/ldap_group_link.rb
+14
-6
spec/models/ldap_group_link_spec.rb
spec/models/ldap_group_link_spec.rb
+6
-0
No files found.
app/models/ldap_group_link.rb
View file @
1adcbbb4
...
@@ -4,17 +4,25 @@ class LdapGroupLink < ActiveRecord::Base
...
@@ -4,17 +4,25 @@ class LdapGroupLink < ActiveRecord::Base
BLANK_ATTRIBUTES
=
%w[cn filter]
.
freeze
BLANK_ATTRIBUTES
=
%w[cn filter]
.
freeze
validates
:cn
,
:group_access
,
:group_id
,
presence:
true
,
unless: :filter
with_options
if: :cn
do
|
link
|
validates
:cn
,
uniqueness:
{
scope:
[
:group_id
,
:provider
]
},
unless: :filter
link
.
validates
:cn
,
:group_access
,
:group_id
,
presence:
true
,
unless: :filter
validates
:filter
,
:group_access
,
:group_id
,
presence:
true
,
unless: :cn
link
.
validates
:cn
,
uniqueness:
{
scope:
[
:group_id
,
:provider
]
},
if: :cn
validates
:filter
,
uniqueness:
{
scope:
[
:group_id
,
:provider
]
},
unless: :cn
link
.
validates
:filter
,
absence:
true
validates
:filter
,
ldap_filter:
true
,
unless: :cn
end
with_options
if: :filter
do
|
link
|
link
.
validates
:filter
,
:group_access
,
:group_id
,
presence:
true
link
.
validates
:filter
,
uniqueness:
{
scope:
[
:group_id
,
:provider
]
}
link
.
validates
:filter
,
ldap_filter:
true
link
.
validates
:cn
,
absence:
true
end
validates
:group_access
,
inclusion:
{
in:
Gitlab
::
Access
.
all_values
}
validates
:group_access
,
inclusion:
{
in:
Gitlab
::
Access
.
all_values
}
validates
:provider
,
presence:
true
validates
:provider
,
presence:
true
scope
:with_provider
,
->
(
provider
)
{
where
(
provider:
provider
)
}
scope
:with_provider
,
->
(
provider
)
{
where
(
provider:
provider
)
}
before_
save
:nullify_blank_attributes
before_
validation
:nullify_blank_attributes
def
access_field
def
access_field
group_access
group_access
...
...
spec/models/ldap_group_link_spec.rb
View file @
1adcbbb4
...
@@ -20,6 +20,12 @@ describe LdapGroupLink do
...
@@ -20,6 +20,12 @@ describe LdapGroupLink do
group_link
.
provider
=
'ldapalt'
group_link
.
provider
=
'ldapalt'
expect
(
group_link
).
to
be_valid
expect
(
group_link
).
to
be_valid
end
end
it
'is invalid when a filter is also present'
do
link
=
build
(
:ldap_group_link
,
filter:
'(a=b)'
,
group_id:
1
,
provider:
'ldapmain'
,
cn:
'group1'
)
expect
(
link
).
not_to
be_valid
end
end
end
describe
'filter'
do
describe
'filter'
do
...
...
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