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
9739eea3
Commit
9739eea3
authored
Oct 29, 2019
by
James Edwards-Jones
Committed by
Douglas Barbosa Alexandre
Oct 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SCIM pagination startIndex handles string input
Adds tests and splits a method to simplify testing
parent
42b27577
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
5 deletions
+28
-5
ee/app/models/concerns/scim_paginatable.rb
ee/app/models/concerns/scim_paginatable.rb
+8
-2
ee/changelogs/unreleased/jej-fix-scim-pagination-integer-handling.yml
...s/unreleased/jej-fix-scim-pagination-integer-handling.yml
+5
-0
ee/spec/lib/ee/api/helpers/scim_pagination_spec.rb
ee/spec/lib/ee/api/helpers/scim_pagination_spec.rb
+1
-1
ee/spec/models/concerns/scim_paginatable_spec.rb
ee/spec/models/concerns/scim_paginatable_spec.rb
+14
-2
No files found.
ee/app/models/concerns/scim_paginatable.rb
View file @
9739eea3
...
...
@@ -5,10 +5,16 @@ module ScimPaginatable
class_methods
do
def
scim_paginate
(
start_index
:,
count
:)
one_based_index
=
[
start_index
.
presence
||
1
,
1
].
max
one_based_index
=
[
start_index
.
to_i
,
1
].
max
zero_based_index
=
one_based_index
-
1
offset
(
zero_based_index
).
limit
(
count
)
scim_paginate_with_offset_and_limit
(
offset:
zero_based_index
,
limit:
count
.
to_i
)
end
private
def
scim_paginate_with_offset_and_limit
(
offset
:,
limit
:)
offset
(
offset
).
limit
(
limit
)
end
end
end
ee/changelogs/unreleased/jej-fix-scim-pagination-integer-handling.yml
0 → 100644
View file @
9739eea3
---
title
:
SCIM pagination startIndex handles string input
merge_request
:
19331
author
:
type
:
fixed
ee/spec/lib/ee/api/helpers/scim_pagination_spec.rb
View file @
9739eea3
...
...
@@ -59,7 +59,7 @@ describe ::EE::API::Helpers::ScimPagination do
end
it
'uses a 1-based index'
do
query
=
{
startIndex:
1
}
query
=
{
startIndex:
'1'
}
result
=
pagination_class
.
new
(
query
).
scim_paginate
(
resource
)
...
...
ee/spec/models/concerns/scim_paginatable_spec.rb
View file @
9739eea3
...
...
@@ -16,9 +16,21 @@ describe ScimPaginatable do
end
it
'translates a 1-based index to an offset of 0'
do
expect
(
paginatable_class
).
to
receive
(
:
offset
).
with
(
0
).
and_return
(
double
(
limit:
double
)
)
expect
(
paginatable_class
).
to
receive
(
:
scim_paginate_with_offset_and_limit
).
with
(
offset:
0
,
limit:
count
)
paginatable_class
.
scim_paginate
(
start_index:
start_index
,
count:
count
)
paginatable_class
.
scim_paginate
(
start_index:
1
,
count:
count
)
end
it
'handles string input'
do
expect
(
paginatable_class
).
to
receive
(
:scim_paginate_with_offset_and_limit
).
with
(
offset:
start_index
-
1
,
limit:
count
)
paginatable_class
.
scim_paginate
(
start_index:
start_index
.
to_s
,
count:
count
.
to_s
)
end
it
'defaults to offset of 0'
do
expect
(
paginatable_class
).
to
receive
(
:scim_paginate_with_offset_and_limit
).
with
(
offset:
0
,
limit:
count
)
paginatable_class
.
scim_paginate
(
start_index:
''
,
count:
count
)
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