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
9488990f
Commit
9488990f
authored
Mar 27, 2020
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
De-duplicate notes EE specs
- Remove file ee/spec/models/ee/note_spec.rb
parent
b617c71f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
108 deletions
+101
-108
.rubocop.yml
.rubocop.yml
+0
-2
ee/spec/models/ee/note_spec.rb
ee/spec/models/ee/note_spec.rb
+0
-106
ee/spec/models/note_spec.rb
ee/spec/models/note_spec.rb
+101
-0
No files found.
.rubocop.yml
View file @
9488990f
...
...
@@ -206,7 +206,6 @@ Gitlab/DuplicateSpecLocation:
-
ee/spec/lib/gitlab/gl_repository_spec.rb
-
ee/spec/lib/gitlab/usage_data_spec.rb
-
ee/spec/models/namespace_spec.rb
-
ee/spec/models/note_spec.rb
-
ee/spec/serializers/environment_entity_spec.rb
-
ee/spec/services/issues/create_service_spec.rb
-
ee/spec/services/merge_requests/create_service_spec.rb
...
...
@@ -217,7 +216,6 @@ Gitlab/DuplicateSpecLocation:
-
ee/spec/lib/ee/gitlab/gl_repository_spec.rb
-
ee/spec/lib/ee/gitlab/usage_data_spec.rb
-
ee/spec/models/ee/namespace_spec.rb
-
ee/spec/models/ee/note_spec.rb
-
ee/spec/serializers/ee/environment_entity_spec.rb
-
ee/spec/services/ee/issues/create_service_spec.rb
-
ee/spec/services/ee/merge_requests/create_service_spec.rb
...
...
ee/spec/models/ee/note_spec.rb
deleted
100644 → 0
View file @
b617c71f
# frozen_string_literal: true
require
'spec_helper'
describe
Note
do
include
::
EE
::
GeoHelpers
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:review
).
inverse_of
(
:notes
)
}
end
describe
'scopes'
do
describe
'.with_suggestions'
do
it
'returns the correct note'
do
note_with_suggestion
=
create
(
:note
,
suggestions:
[
create
(
:suggestion
)])
note_without_suggestion
=
create
(
:note
)
expect
(
described_class
.
with_suggestions
).
to
include
(
note_with_suggestion
)
expect
(
described_class
.
with_suggestions
).
not_to
include
(
note_without_suggestion
)
end
end
end
describe
'callbacks'
do
describe
'#notify_after_create'
do
it
'calls #after_note_created on the noteable'
do
note
=
build
(
:note
)
expect
(
note
).
to
receive
(
:notify_after_create
).
and_call_original
expect
(
note
.
noteable
).
to
receive
(
:after_note_created
).
with
(
note
)
note
.
save!
end
end
describe
'#notify_after_destroy'
do
it
'calls #after_note_destroyed on the noteable'
do
note
=
create
(
:note
)
expect
(
note
).
to
receive
(
:notify_after_destroy
).
and_call_original
expect
(
note
.
noteable
).
to
receive
(
:after_note_destroyed
).
with
(
note
)
note
.
destroy
end
it
'does not error if noteable is nil'
do
note
=
create
(
:note
)
expect
(
note
).
to
receive
(
:notify_after_destroy
).
and_call_original
expect
(
note
).
to
receive
(
:noteable
).
at_least
(
:once
).
and_return
(
nil
)
expect
{
note
.
destroy
}.
not_to
raise_error
end
end
end
context
'object storage with background upload'
do
before
do
stub_uploads_object_storage
(
AttachmentUploader
,
background_upload:
true
)
end
context
'when running in a Geo primary node'
do
let_it_be
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let_it_be
(
:secondary
)
{
create
(
:geo_node
)
}
before
do
stub_current_geo_node
(
primary
)
end
it
'creates a Geo deleted log event for attachment'
do
Sidekiq
::
Testing
.
inline!
do
expect
do
create
(
:note
,
:with_attachment
)
end
.
to
change
(
Geo
::
UploadDeletedEvent
,
:count
).
by
(
1
)
end
end
end
end
describe
'#resource_parent'
do
it
'returns group for epic notes'
do
group
=
create
(
:group
)
note
=
create
(
:note_on_epic
,
noteable:
create
(
:epic
,
group:
group
))
expect
(
note
.
resource_parent
).
to
eq
(
group
)
end
end
describe
'#for_design'
do
it
'is true when the noteable is a design'
do
note
=
build
(
:note
,
noteable:
build
(
:design
))
expect
(
note
).
to
be_for_design
end
end
describe
'.by_humans'
do
it
'excludes notes by bots and service users'
do
user_note
=
create
(
:note
)
create
(
:system_note
)
create
(
:note
,
author:
create
(
:user
,
:bot
))
create
(
:note
,
author:
create
(
:user
,
:service_user
))
expect
(
described_class
.
by_humans
).
to
match_array
([
user_note
])
end
end
end
ee/spec/models/note_spec.rb
View file @
9488990f
...
...
@@ -3,6 +3,8 @@
require
'spec_helper'
describe
Note
do
include
::
EE
::
GeoHelpers
it_behaves_like
'an editable mentionable with EE-specific mentions'
do
subject
{
create
:note
,
noteable:
issue
,
project:
issue
.
project
}
...
...
@@ -88,4 +90,103 @@ describe Note do
end
end
end
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:review
).
inverse_of
(
:notes
)
}
end
describe
'scopes'
do
describe
'.with_suggestions'
do
it
'returns the correct note'
do
note_with_suggestion
=
create
(
:note
,
suggestions:
[
create
(
:suggestion
)])
note_without_suggestion
=
create
(
:note
)
expect
(
described_class
.
with_suggestions
).
to
include
(
note_with_suggestion
)
expect
(
described_class
.
with_suggestions
).
not_to
include
(
note_without_suggestion
)
end
end
end
describe
'callbacks'
do
describe
'#notify_after_create'
do
it
'calls #after_note_created on the noteable'
do
note
=
build
(
:note
)
expect
(
note
).
to
receive
(
:notify_after_create
).
and_call_original
expect
(
note
.
noteable
).
to
receive
(
:after_note_created
).
with
(
note
)
note
.
save!
end
end
describe
'#notify_after_destroy'
do
it
'calls #after_note_destroyed on the noteable'
do
note
=
create
(
:note
)
expect
(
note
).
to
receive
(
:notify_after_destroy
).
and_call_original
expect
(
note
.
noteable
).
to
receive
(
:after_note_destroyed
).
with
(
note
)
note
.
destroy
end
it
'does not error if noteable is nil'
do
note
=
create
(
:note
)
expect
(
note
).
to
receive
(
:notify_after_destroy
).
and_call_original
expect
(
note
).
to
receive
(
:noteable
).
at_least
(
:once
).
and_return
(
nil
)
expect
{
note
.
destroy
}.
not_to
raise_error
end
end
end
context
'object storage with background upload'
do
before
do
stub_uploads_object_storage
(
AttachmentUploader
,
background_upload:
true
)
end
context
'when running in a Geo primary node'
do
let_it_be
(
:primary
)
{
create
(
:geo_node
,
:primary
)
}
let_it_be
(
:secondary
)
{
create
(
:geo_node
)
}
before
do
stub_current_geo_node
(
primary
)
end
it
'creates a Geo deleted log event for attachment'
do
Sidekiq
::
Testing
.
inline!
do
expect
do
create
(
:note
,
:with_attachment
)
end
.
to
change
(
Geo
::
UploadDeletedEvent
,
:count
).
by
(
1
)
end
end
end
end
describe
'#resource_parent'
do
it
'returns group for epic notes'
do
group
=
create
(
:group
)
note
=
create
(
:note_on_epic
,
noteable:
create
(
:epic
,
group:
group
))
expect
(
note
.
resource_parent
).
to
eq
(
group
)
end
end
describe
'#for_design'
do
it
'is true when the noteable is a design'
do
note
=
build
(
:note
,
noteable:
build
(
:design
))
expect
(
note
).
to
be_for_design
end
end
describe
'.by_humans'
do
it
'excludes notes by bots and service users'
do
user_note
=
create
(
:note
)
create
(
:system_note
)
create
(
:note
,
author:
create
(
:user
,
:bot
))
create
(
:note
,
author:
create
(
:user
,
:service_user
))
expect
(
described_class
.
by_humans
).
to
match_array
([
user_note
])
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