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
fcea425c
Commit
fcea425c
authored
Feb 23, 2022
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add user and system note filters to note_authors association
Changelog: added
parent
c1c597bc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+9
-1
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+25
-1
No files found.
app/models/concerns/issuable.rb
View file @
fcea425c
...
@@ -73,7 +73,15 @@ module Issuable
...
@@ -73,7 +73,15 @@ module Issuable
end
end
end
end
has_many
:note_authors
,
->
{
distinct
},
through: :notes
,
source: :author
has_many
:note_authors
,
->
{
distinct
},
through: :notes
,
source: :author
do
def
user_notes
where
(
"notes.system = false"
)
end
def
system_notes
where
(
"notes.system = true"
)
end
end
has_many
:label_links
,
as: :target
,
inverse_of: :target
has_many
:label_links
,
as: :target
,
inverse_of: :target
has_many
:labels
,
through: :label_links
has_many
:labels
,
through: :label_links
...
...
spec/models/concerns/issuable_spec.rb
View file @
fcea425c
...
@@ -18,7 +18,6 @@ RSpec.describe Issuable do
...
@@ -18,7 +18,6 @@ RSpec.describe Issuable do
it
{
is_expected
.
to
have_many
(
:notes
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:notes
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:todos
)
}
it
{
is_expected
.
to
have_many
(
:todos
)
}
it
{
is_expected
.
to
have_many
(
:labels
)
}
it
{
is_expected
.
to
have_many
(
:labels
)
}
it
{
is_expected
.
to
have_many
(
:note_authors
).
through
(
:notes
)
}
context
'Notes'
do
context
'Notes'
do
let!
(
:note
)
{
create
(
:note
,
noteable:
issue
,
project:
issue
.
project
)
}
let!
(
:note
)
{
create
(
:note
,
noteable:
issue
,
project:
issue
.
project
)
}
...
@@ -28,6 +27,31 @@ RSpec.describe Issuable do
...
@@ -28,6 +27,31 @@ RSpec.describe Issuable do
expect
(
issue
.
notes
).
not_to
be_authors_loaded
expect
(
issue
.
notes
).
not_to
be_authors_loaded
expect
(
scoped_issue
.
notes
).
to
be_authors_loaded
expect
(
scoped_issue
.
notes
).
to
be_authors_loaded
end
end
describe
'note_authors'
do
let
(
:system_user
)
{
create
(
:user
)
}
let!
(
:system_note
)
{
create
(
:system_note
,
author:
system_user
,
noteable:
issue
,
project:
issue
.
project
)
}
it
{
is_expected
.
to
have_many
(
:note_authors
).
through
(
:notes
)
}
describe
'note_authors.user_notes'
do
it
'filters the authors to those of user notes'
do
authors
=
issue
.
note_authors
.
user_notes
expect
(
authors
).
to
include
(
note
.
author
)
expect
(
authors
).
not_to
include
(
system_user
)
end
end
describe
'note_authors.system_notes'
do
it
'filters the authors to those of system notes'
do
authors
=
issue
.
note_authors
.
system_notes
expect
(
authors
).
to
include
(
system_user
)
expect
(
authors
).
not_to
include
(
note
.
author
)
end
end
end
end
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