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
c69dc778
Commit
c69dc778
authored
Sep 17, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use inheritance for stubbed class
- Add specs for setting parent in issues finder
parent
5ad098c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
22 deletions
+34
-22
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+30
-0
spec/lib/gitlab/graphql/loaders/issuable_loader_spec.rb
spec/lib/gitlab/graphql/loaders/issuable_loader_spec.rb
+4
-22
No files found.
spec/finders/issues_finder_spec.rb
View file @
c69dc778
...
...
@@ -3,6 +3,7 @@
require
'spec_helper'
RSpec
.
describe
IssuesFinder
do
using
RSpec
::
Parameterized
::
TableSyntax
include_context
'IssuesFinder context'
describe
'#execute'
do
...
...
@@ -1022,4 +1023,33 @@ RSpec.describe IssuesFinder do
end
end
end
describe
'#parent_param='
do
let
(
:finder
)
{
described_class
.
new
(
nil
)
}
subject
{
finder
.
parent_param
=
obj
}
where
(
:klass
,
:param
)
do
:Project
|
:project_id
:Group
|
:group_id
end
with_them
do
let
(
:obj
)
{
Object
.
const_get
(
klass
,
false
).
new
}
it
'sets the params'
do
subject
expect
(
finder
.
params
[
param
]).
to
eq
(
obj
)
end
end
context
'unexpected parent'
do
let
(
:obj
)
{
MergeRequest
.
new
}
it
'raises an error'
do
expect
{
subject
}.
to
raise_error
(
'Unexpected parent: MergeRequest'
)
end
end
end
end
spec/lib/gitlab/graphql/loaders/issuable_loader_spec.rb
View file @
c69dc778
...
...
@@ -11,33 +11,15 @@ RSpec.describe Gitlab::Graphql::Loaders::IssuableLoader do
# Dumb finder class, that only implements what we need, and has
# predictable query counts.
let
(
:finder_class
)
do
Class
.
new
do
attr_reader
:current_user
,
:params
attr_accessor
:parent
def
initialize
(
user
,
args
)
@current_user
=
user
@params
=
HashWithIndifferentAccess
.
new
(
args
.
to_h
)
end
Class
.
new
(
IssuesFinder
)
do
def
execute
params
[
:project_id
].
issues
.
where
(
iid:
params
[
:iids
])
end
def
parent_param
=
(
obj
)
@parent
=
obj
params
[
parent_param
]
=
parent
if
parent
end
private
def
parent_param
case
parent
when
Project
:project_id
when
Group
:group_id
else
raise
"Unexpected parent:
#{
parent
.
class
}
"
end
def
params_class
IssuesFinder
::
Params
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