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
28d84751
Commit
28d84751
authored
Oct 06, 2021
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor some redundant code
parent
c17e7fad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
37 deletions
+13
-37
spec/graphql/resolvers/timelog_resolver_spec.rb
spec/graphql/resolvers/timelog_resolver_spec.rb
+13
-37
No files found.
spec/graphql/resolvers/timelog_resolver_spec.rb
View file @
28d84751
...
...
@@ -11,6 +11,8 @@ RSpec.describe Resolvers::TimelogResolver do
let_it_be
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let_it_be
(
:error_class
)
{
Gitlab
::
Graphql
::
Errors
::
ArgumentError
}
let
(
:timelogs
)
{
resolve_timelogs
(
**
args
)
}
specify
do
expect
(
described_class
).
to
have_non_null_graphql_type
(
::
Types
::
TimelogType
.
connection_type
)
end
...
...
@@ -24,8 +26,6 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
start_time:
6
.
days
.
ago
,
end_time:
2
.
days
.
ago
.
noon
}
}
it
'finds all timelogs within given dates'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog1
)
end
...
...
@@ -33,8 +33,6 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{}
}
it
'finds all timelogs'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog1
,
timelog2
,
timelog3
)
end
end
...
...
@@ -43,8 +41,6 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
start_time:
2
.
days
.
ago
.
noon
}
}
it
'finds timelogs after the start_time'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog2
)
end
end
...
...
@@ -53,8 +49,6 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
end_time:
2
.
days
.
ago
.
noon
}
}
it
'finds timelogs before the end_time'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog1
,
timelog3
)
end
end
...
...
@@ -63,8 +57,6 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
start_time:
6
.
days
.
ago
,
end_date:
2
.
days
.
ago
}
}
it
'finds timelogs until the end of day of end_date'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog1
,
timelog2
)
end
end
...
...
@@ -73,8 +65,6 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
start_date:
6
.
days
.
ago
,
end_time:
2
.
days
.
ago
.
noon
}
}
it
'finds all timelogs within start_date and end_time'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog1
)
end
end
...
...
@@ -96,7 +86,7 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
start_time:
6
.
days
.
ago
,
start_date:
6
.
days
.
ago
}
}
it
'returns correct error'
do
expect
{
resolve_timelogs
(
**
args
)
}
expect
{
timelogs
}
.
to
raise_error
(
error_class
,
/Provide either a start date or time, but not both/
)
end
end
...
...
@@ -105,7 +95,7 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
end_time:
2
.
days
.
ago
,
end_date:
2
.
days
.
ago
}
}
it
'returns correct error'
do
expect
{
resolve_timelogs
(
**
args
)
}
expect
{
timelogs
}
.
to
raise_error
(
error_class
,
/Provide either an end date or time, but not both/
)
end
end
...
...
@@ -114,14 +104,14 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
start_time:
2
.
days
.
ago
,
end_time:
6
.
days
.
ago
}
}
it
'returns correct error'
do
expect
{
resolve_timelogs
(
**
args
)
}
expect
{
timelogs
}
.
to
raise_error
(
error_class
,
/Start argument must be before End argument/
)
end
end
end
end
shared_examples
"with a group"
do
shared_examples
'with a group'
do
let_it_be
(
:short_time_ago
)
{
5
.
days
.
ago
.
beginning_of_day
}
let_it_be
(
:medium_time_ago
)
{
15
.
days
.
ago
.
beginning_of_day
}
...
...
@@ -141,8 +131,6 @@ RSpec.describe Resolvers::TimelogResolver do
end
it
'finds all timelogs within given dates'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog1
)
end
...
...
@@ -150,8 +138,6 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
start_date:
short_time_ago
}
}
it
'finds timelogs until the end of day of end_date'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog1
,
timelog2
)
end
end
...
...
@@ -160,8 +146,6 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
end_date:
medium_time_ago
}
}
it
'finds timelogs until the end of day of end_date'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog3
)
end
end
...
...
@@ -170,8 +154,6 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
start_time:
short_time_ago
,
end_date:
short_time_ago
}
}
it
'finds timelogs until the end of day of end_date'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog1
,
timelog2
)
end
end
...
...
@@ -180,8 +162,6 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
start_date:
short_time_ago
,
end_time:
short_time_ago
.
noon
}
}
it
'finds all timelogs within start_date and end_time'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog1
)
end
end
...
...
@@ -191,7 +171,7 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
start_time:
short_time_ago
,
start_date:
short_time_ago
}
}
it
'returns correct error'
do
expect
{
resolve_timelogs
(
**
args
)
}
expect
{
timelogs
}
.
to
raise_error
(
error_class
,
/Provide either a start date or time, but not both/
)
end
end
...
...
@@ -200,7 +180,7 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
end_time:
short_time_ago
,
end_date:
short_time_ago
}
}
it
'returns correct error'
do
expect
{
resolve_timelogs
(
**
args
)
}
expect
{
timelogs
}
.
to
raise_error
(
error_class
,
/Provide either an end date or time, but not both/
)
end
end
...
...
@@ -209,14 +189,14 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:args
)
{
{
start_time:
short_time_ago
,
end_time:
medium_time_ago
}
}
it
'returns correct error'
do
expect
{
resolve_timelogs
(
**
args
)
}
expect
{
timelogs
}
.
to
raise_error
(
error_class
,
/Start argument must be before End argument/
)
end
end
end
end
shared_examples
"with a user"
do
shared_examples
'with a user'
do
let_it_be
(
:short_time_ago
)
{
5
.
days
.
ago
.
beginning_of_day
}
let_it_be
(
:medium_time_ago
)
{
15
.
days
.
ago
.
beginning_of_day
}
...
...
@@ -228,20 +208,18 @@ RSpec.describe Resolvers::TimelogResolver do
let_it_be
(
:timelog3
)
{
create
(
:merge_request_timelog
,
merge_request:
merge_request
,
user:
current_user
)
}
it
'blah'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
).
to
contain_exactly
(
timelog1
,
timelog3
)
end
end
context
"on a project"
do
context
'on a project'
do
let
(
:object
)
{
project
}
let
(
:extra_args
)
{
{}
}
it_behaves_like
'with a project'
end
context
"with a project filter"
do
context
'with a project filter'
do
let
(
:object
)
{
nil
}
let
(
:extra_args
)
{
{
project_id:
project
.
to_global_id
}
}
...
...
@@ -285,8 +263,6 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:extra_args
)
{
{}
}
it
'pagination returns `default_max_page_size` and sets `has_next_page` true'
do
timelogs
=
resolve_timelogs
(
**
args
)
expect
(
timelogs
.
items
.
count
).
to
be
(
100
)
expect
(
timelogs
.
has_next_page
).
to
be
(
true
)
end
...
...
@@ -298,7 +274,7 @@ RSpec.describe Resolvers::TimelogResolver do
let
(
:extra_args
)
{
{}
}
it
'returns correct error'
do
expect
{
resolve_timelogs
(
**
args
)
}
expect
{
timelogs
}
.
to
raise_error
(
error_class
,
/Provide at least one argument/
)
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