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
04ac2ea4
Commit
04ac2ea4
authored
Jan 31, 2020
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set default before_or_after for keyset conditions
and add relevant specs
parent
db2c101c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
7 deletions
+29
-7
lib/gitlab/graphql/connections/keyset/conditions/base_condition.rb
...b/graphql/connections/keyset/conditions/base_condition.rb
+2
-0
spec/lib/gitlab/graphql/connections/keyset/conditions/not_null_condition_spec.rb
.../connections/keyset/conditions/not_null_condition_spec.rb
+11
-1
spec/lib/gitlab/graphql/connections/keyset/conditions/null_condition_spec.rb
...phql/connections/keyset/conditions/null_condition_spec.rb
+16
-6
No files found.
lib/gitlab/graphql/connections/keyset/conditions/base_condition.rb
View file @
04ac2ea4
...
...
@@ -8,6 +8,8 @@ module Gitlab
class
BaseCondition
def
initialize
(
arel_table
,
order_list
,
values
,
operators
,
before_or_after
)
@arel_table
,
@order_list
,
@values
,
@operators
,
@before_or_after
=
arel_table
,
order_list
,
values
,
operators
,
before_or_after
@before_or_after
=
:after
unless
[
:after
,
:before
].
include?
(
@before_or_after
)
end
def
build
...
...
spec/lib/gitlab/graphql/connections/keyset/conditions/not_null_condition_spec.rb
View file @
04ac2ea4
...
...
@@ -28,7 +28,7 @@ describe Gitlab::Graphql::Connections::Keyset::Conditions::NotNullCondition do
let
(
:order_list
)
{
%w(relative_position id)
}
let
(
:values
)
{
[
1500
,
500
]
}
context
'when :after
'
do
shared_examples
':after condition
'
do
it
'generates :after sql'
do
expected_sql
=
<<~
SQL
("issues"."relative_position" > 1500)
...
...
@@ -44,6 +44,10 @@ describe Gitlab::Graphql::Connections::Keyset::Conditions::NotNullCondition do
end
end
context
'when :after'
do
it_behaves_like
':after condition'
end
context
'when :before'
do
let
(
:before_or_after
)
{
:before
}
...
...
@@ -60,6 +64,12 @@ describe Gitlab::Graphql::Connections::Keyset::Conditions::NotNullCondition do
expect
(
condition
.
build
.
squish
).
to
eq
expected_sql
.
squish
end
end
context
'when :foo'
do
let
(
:before_or_after
)
{
:foo
}
it_behaves_like
':after condition'
end
end
end
end
spec/lib/gitlab/graphql/connections/keyset/conditions/null_condition_spec.rb
View file @
04ac2ea4
...
...
@@ -13,20 +13,24 @@ describe Gitlab::Graphql::Connections::Keyset::Conditions::NullCondition do
let
(
:arel_table
)
{
Issue
.
arel_table
}
let
(
:order_list
)
{
%w(relative_position id)
}
context
'when :after
'
do
shared_examples
':after condition
'
do
it
'generates sql'
do
expected_sql
=
<<~
SQL
(
"issues"."relative_position" IS NULL
AND
"issues"."id" > 500
)
(
"issues"."relative_position" IS NULL
AND
"issues"."id" > 500
)
SQL
expect
(
condition
.
build
.
squish
).
to
eq
expected_sql
.
squish
end
end
context
'when :after'
do
it_behaves_like
':after condition'
end
context
'when :before'
do
let
(
:before_or_after
)
{
:before
}
...
...
@@ -43,6 +47,12 @@ describe Gitlab::Graphql::Connections::Keyset::Conditions::NullCondition do
expect
(
condition
.
build
.
squish
).
to
eq
expected_sql
.
squish
end
end
context
'when :foo'
do
let
(
:before_or_after
)
{
:foo
}
it_behaves_like
':after condition'
end
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