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
eff9d44d
Commit
eff9d44d
authored
Jan 24, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor spec to use 4-phase test
parent
a23dea74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
23 deletions
+33
-23
spec/services/error_tracking/issue_update_service_spec.rb
spec/services/error_tracking/issue_update_service_spec.rb
+33
-23
No files found.
spec/services/error_tracking/issue_update_service_spec.rb
View file @
eff9d44d
...
...
@@ -7,16 +7,19 @@ describe ErrorTracking::IssueUpdateService do
let
(
:arguments
)
{
{
issue_id:
1234
,
status:
'resolved'
}
}
subject
{
described_class
.
new
(
project
,
user
,
arguments
)
}
subject
(
:update_service
)
{
described_class
.
new
(
project
,
user
,
arguments
)
}
shared_examples
'does not perform close issue flow'
do
it
'does not call the close issue service'
do
update_service
.
execute
expect
(
issue_close_service
)
.
not_to
receive
(
:execute
)
.
not_to
have_received
(
:execute
)
end
it
'does not create system note'
do
expect
(
SystemNoteService
).
not_to
receive
(
:close_after_error_tracking_resolve
)
update_service
.
execute
end
end
...
...
@@ -31,13 +34,13 @@ describe ErrorTracking::IssueUpdateService do
end
it
'returns the response'
do
expect
(
result
).
to
eq
(
update_issue_response
.
merge
(
status: :success
,
closed_issue_iid:
nil
))
expect
(
update_service
.
execute
).
to
eq
(
update_issue_response
.
merge
(
status: :success
,
closed_issue_iid:
nil
))
end
it
'updates any related issue'
do
expect
(
subject
).
to
receive
(
:update_related_issue
)
expect
(
update_service
).
to
receive
(
:update_related_issue
)
result
update_service
.
execute
end
context
'related issue and resolving'
do
...
...
@@ -48,39 +51,46 @@ describe ErrorTracking::IssueUpdateService do
let
(
:issue_close_service
)
{
spy
(
:issue_close_service
)
}
before
do
allow_
any_instance_of
(
SentryIssueFinder
)
.
to
receive
(
:execut
e
)
.
and_return
(
sentry_issue
)
allow_
next_instance_of
(
SentryIssueFinder
)
do
|
finder
|
allow
(
finder
).
to
receive
(
:execute
).
and_return
(
sentry_issu
e
)
end
allow
(
Issues
::
CloseService
)
.
to
receive
(
:new
)
.
and_return
(
issue_close_service
)
end
after
do
result
allow
(
issue_close_service
)
.
to
receive
(
:execute
)
.
and_return
(
issue
)
end
it
'closes the issue'
do
update_service
.
execute
expect
(
issue_close_service
)
.
to
receive
(
:execute
)
.
to
have_received
(
:execute
)
.
with
(
issue
,
system_note:
false
)
.
and_return
(
issue
)
end
it
'creates a system note'
do
expect
(
SystemNoteService
).
to
receive
(
:close_after_error_tracking_resolve
)
end
context
'issues gets closed'
do
let
(
:closed_issue
)
{
create
(
:issue
,
:closed
,
project:
project
)
}
it
'returns a response with closed issue'
do
closed_issue
=
create
(
:issue
,
:closed
,
project:
project
)
before
do
expect
(
issue_close_service
)
.
to
receive
(
:execute
)
.
with
(
issue
,
system_note:
false
)
.
and_return
(
closed_issue
)
end
expect
(
issue_close_service
)
.
to
receive
(
:execute
)
.
with
(
issue
,
system_note:
false
)
.
and_return
(
closed_issue
)
it
'creates a system note'
do
expect
(
SystemNoteService
).
to
receive
(
:close_after_error_tracking_resolve
)
update_service
.
execute
end
expect
(
result
).
to
eq
(
status: :success
,
updated:
true
,
closed_issue_iid:
closed_issue
.
iid
)
it
'returns a response with closed issue'
do
expect
(
update_service
.
execute
).
to
eq
(
status: :success
,
updated:
true
,
closed_issue_iid:
closed_issue
.
iid
)
end
end
context
'issue is already closed'
do
...
...
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