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
c2d28963
Commit
c2d28963
authored
Dec 13, 2021
by
Adam Cohen
Committed by
Mikołaj Wawrzyniak
Dec 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve GraphQL tests that use nil checks
parent
b8597825
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
7 deletions
+23
-7
spec/graphql/types/admin/analytics/usage_trends/measurement_type_spec.rb
...pes/admin/analytics/usage_trends/measurement_type_spec.rb
+9
-3
spec/graphql/types/ci/job_token_scope_type_spec.rb
spec/graphql/types/ci/job_token_scope_type_spec.rb
+6
-2
spec/graphql/types/issue_type_spec.rb
spec/graphql/types/issue_type_spec.rb
+8
-2
No files found.
spec/graphql/types/admin/analytics/usage_trends/measurement_type_spec.rb
View file @
c2d28963
...
...
@@ -36,8 +36,14 @@ RSpec.describe GitlabSchema.types['UsageTrendsMeasurement'] do
end
context
'when the user is not admin'
do
it
'returns no data'
do
expect
(
subject
.
dig
(
'data'
,
'usageTrendsMeasurements'
)).
to
be_nil
it
'returns an error'
do
expected_err
=
"The resource that you are attempting to access does not exist or you don't have permission to perform this action"
expect
(
subject
[
"errors"
].
first
[
"message"
]).
to
eq
(
expected_err
)
end
it
'does not return usageTrendsMeasurements data'
do
expect
(
subject
[
"data"
][
"usageTrendsMeasurements"
]).
to
be_nil
end
end
...
...
@@ -48,7 +54,7 @@ RSpec.describe GitlabSchema.types['UsageTrendsMeasurement'] do
stub_application_setting
(
admin_mode:
false
)
end
it
'returns data'
do
it
'returns
usageTrendsMeasurements
data'
do
expect
(
subject
.
dig
(
'data'
,
'usageTrendsMeasurements'
,
'nodes'
)).
not_to
be_empty
end
end
...
...
spec/graphql/types/ci/job_token_scope_type_spec.rb
View file @
c2d28963
...
...
@@ -12,7 +12,7 @@ RSpec.describe GitlabSchema.types['CiJobTokenScopeType'] do
end
describe
'query'
do
let
_it_be
(
:project
)
{
create
(
:project
,
ci_job_token_scope_enabled:
true
).
tap
(
&
:save!
)
}
let
(
:project
)
{
create
(
:project
,
ci_job_token_scope_enabled:
true
).
tap
(
&
:save!
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let
(
:query
)
do
...
...
@@ -65,8 +65,12 @@ RSpec.describe GitlabSchema.types['CiJobTokenScopeType'] do
project
.
ci_cd_settings
.
update!
(
job_token_scope_enabled:
false
)
end
it
'does not return an error'
do
expect
(
subject
[
'errors'
]).
to
be_nil
end
it
'returns nil'
do
expect
(
subject
.
dig
(
'data'
,
'project'
,
'ciJobTokenScope'
)
).
to
be_nil
expect
(
subject
[
'data'
][
'project'
][
'ciJobTokenScope'
]
).
to
be_nil
end
end
end
...
...
spec/graphql/types/issue_type_spec.rb
View file @
c2d28963
...
...
@@ -66,10 +66,16 @@ RSpec.describe GitlabSchema.types['Issue'] do
end
context
'when user does not have the permission'
do
it
'returns no data'
do
before
do
allow
(
Ability
).
to
receive
(
:allowed?
).
with
(
user
,
:read_project
,
project
).
and_return
(
false
)
end
expect
(
subject
.
dig
(
:data
,
:project
)).
to
eq
(
nil
)
it
'does not return an error'
do
expect
(
subject
[
'errors'
]).
to
be_nil
end
it
'returns no data'
do
expect
(
subject
[
'data'
][
'project'
]).
to
be_nil
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