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
632bd367
Commit
632bd367
authored
Sep 08, 2020
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid hardcoding ids in worker specs
Prefer non_existing_record_id helper over hardcoded ids.
parent
a1cc510f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
23 deletions
+23
-23
ee/spec/workers/new_epic_worker_spec.rb
ee/spec/workers/new_epic_worker_spec.rb
+6
-6
spec/workers/create_pipeline_worker_spec.rb
spec/workers/create_pipeline_worker_spec.rb
+2
-2
spec/workers/new_issue_worker_spec.rb
spec/workers/new_issue_worker_spec.rb
+7
-7
spec/workers/new_merge_request_worker_spec.rb
spec/workers/new_merge_request_worker_spec.rb
+8
-8
No files found.
ee/spec/workers/new_epic_worker_spec.rb
View file @
632bd367
...
...
@@ -10,13 +10,13 @@ RSpec.describe NewEpicWorker do
it
'does not call Services'
do
expect
(
NotificationService
).
not_to
receive
(
:new
)
worker
.
perform
(
99
,
create
(
:user
).
id
)
worker
.
perform
(
non_existing_record_id
,
create
(
:user
).
id
)
end
it
'logs an error'
do
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
'NewEpicWorker: couldn\'t find Epic with ID=99, skipping job'
)
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
"NewEpicWorker: couldn't find Epic with ID=
#{
non_existing_record_id
}
, skipping job"
)
worker
.
perform
(
99
,
create
(
:user
).
id
)
worker
.
perform
(
non_existing_record_id
,
create
(
:user
).
id
)
end
end
...
...
@@ -24,13 +24,13 @@ RSpec.describe NewEpicWorker do
it
'does not call Services'
do
expect
(
NotificationService
).
not_to
receive
(
:new
)
worker
.
perform
(
create
(
:epic
).
id
,
99
)
worker
.
perform
(
create
(
:epic
).
id
,
non_existing_record_id
)
end
it
'logs an error'
do
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
'NewEpicWorker: couldn\'t find User with ID=99, skipping job'
)
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
"NewEpicWorker: couldn't find User with ID=
#{
non_existing_record_id
}
, skipping job"
)
worker
.
perform
(
create
(
:epic
).
id
,
99
)
worker
.
perform
(
create
(
:epic
).
id
,
non_existing_record_id
)
end
end
...
...
spec/workers/create_pipeline_worker_spec.rb
View file @
632bd367
...
...
@@ -9,7 +9,7 @@ RSpec.describe CreatePipelineWorker do
context
'when a project not found'
do
it
'does not call the Service'
do
expect
(
Ci
::
CreatePipelineService
).
not_to
receive
(
:new
)
expect
{
worker
.
perform
(
99
,
create
(
:user
).
id
,
'master'
,
:web
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
worker
.
perform
(
non_existing_record_id
,
create
(
:user
).
id
,
'master'
,
:web
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
...
...
@@ -18,7 +18,7 @@ RSpec.describe CreatePipelineWorker do
it
'does not call the Service'
do
expect
(
Ci
::
CreatePipelineService
).
not_to
receive
(
:new
)
expect
{
worker
.
perform
(
project
.
id
,
99
,
project
.
default_branch
,
:web
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
expect
{
worker
.
perform
(
project
.
id
,
non_existing_record_id
,
project
.
default_branch
,
:web
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
...
...
spec/workers/new_issue_worker_spec.rb
View file @
632bd367
...
...
@@ -11,13 +11,13 @@ RSpec.describe NewIssueWorker do
expect
(
EventCreateService
).
not_to
receive
(
:new
)
expect
(
NotificationService
).
not_to
receive
(
:new
)
worker
.
perform
(
99
,
create
(
:user
).
id
)
worker
.
perform
(
non_existing_record_id
,
create
(
:user
).
id
)
end
it
'logs an error'
do
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
'NewIssueWorker: couldn\'t find Issue with ID=99, skipping job'
)
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
"NewIssueWorker: couldn't find Issue with ID=
#{
non_existing_record_id
}
, skipping job"
)
worker
.
perform
(
99
,
create
(
:user
).
id
)
worker
.
perform
(
non_existing_record_id
,
create
(
:user
).
id
)
end
end
...
...
@@ -26,15 +26,15 @@ RSpec.describe NewIssueWorker do
expect
(
EventCreateService
).
not_to
receive
(
:new
)
expect
(
NotificationService
).
not_to
receive
(
:new
)
worker
.
perform
(
create
(
:issue
).
id
,
99
)
worker
.
perform
(
create
(
:issue
).
id
,
non_existing_record_id
)
end
it
'logs an error'
do
issue
=
create
(
:issue
)
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
'NewIssueWorker: couldn\'t find User with ID=99, skipping job'
)
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
"NewIssueWorker: couldn't find User with ID=
#{
non_existing_record_id
}
, skipping job"
)
worker
.
perform
(
issue
.
id
,
99
)
worker
.
perform
(
issue
.
id
,
non_existing_record_id
)
end
end
...
...
@@ -50,7 +50,7 @@ RSpec.describe NewIssueWorker do
it
'creates a notification for the mentioned user'
do
expect
(
Notify
).
to
receive
(
:new_issue_email
).
with
(
mentioned
.
id
,
issue
.
id
,
NotificationReason
::
MENTIONED
)
.
and_return
(
double
(
deliver_later:
true
))
.
and_return
(
double
(
deliver_later:
true
))
worker
.
perform
(
issue
.
id
,
user
.
id
)
end
...
...
spec/workers/new_merge_request_worker_spec.rb
View file @
632bd367
...
...
@@ -11,15 +11,15 @@ RSpec.describe NewMergeRequestWorker do
expect
(
EventCreateService
).
not_to
receive
(
:new
)
expect
(
NotificationService
).
not_to
receive
(
:new
)
worker
.
perform
(
99
,
create
(
:user
).
id
)
worker
.
perform
(
non_existing_record_id
,
create
(
:user
).
id
)
end
it
'logs an error'
do
user
=
create
(
:user
)
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
'NewMergeRequestWorker: couldn\'t find MergeRequest with ID=99, skipping job'
)
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
"NewMergeRequestWorker: couldn't find MergeRequest with ID=
#{
non_existing_record_id
}
, skipping job"
)
worker
.
perform
(
99
,
user
.
id
)
worker
.
perform
(
non_existing_record_id
,
user
.
id
)
end
end
...
...
@@ -28,15 +28,15 @@ RSpec.describe NewMergeRequestWorker do
expect
(
EventCreateService
).
not_to
receive
(
:new
)
expect
(
NotificationService
).
not_to
receive
(
:new
)
worker
.
perform
(
create
(
:merge_request
).
id
,
99
)
worker
.
perform
(
create
(
:merge_request
).
id
,
non_existing_record_id
)
end
it
'logs an error'
do
merge_request
=
create
(
:merge_request
)
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
'NewMergeRequestWorker: couldn\'t find User with ID=99, skipping job'
)
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
"NewMergeRequestWorker: couldn't find User with ID=
#{
non_existing_record_id
}
, skipping job"
)
worker
.
perform
(
merge_request
.
id
,
99
)
worker
.
perform
(
merge_request
.
id
,
non_existing_record_id
)
end
end
...
...
@@ -54,8 +54,8 @@ RSpec.describe NewMergeRequestWorker do
it
'creates a notification for the mentioned user'
do
expect
(
Notify
).
to
receive
(
:new_merge_request_email
)
.
with
(
mentioned
.
id
,
merge_request
.
id
,
NotificationReason
::
MENTIONED
)
.
and_return
(
double
(
deliver_later:
true
))
.
with
(
mentioned
.
id
,
merge_request
.
id
,
NotificationReason
::
MENTIONED
)
.
and_return
(
double
(
deliver_later:
true
))
worker
.
perform
(
merge_request
.
id
,
user
.
id
)
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