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
4828758b
Commit
4828758b
authored
Dec 21, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
df1d25cc
0a0c9282
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
41 additions
and
38 deletions
+41
-38
app/models/concerns/discussion_on_diff.rb
app/models/concerns/discussion_on_diff.rb
+1
-0
app/views/notify/_note_email.html.haml
app/views/notify/_note_email.html.haml
+3
-7
app/views/notify/_note_email.text.erb
app/views/notify/_note_email.text.erb
+1
-1
changelogs/unreleased/dm-note-email-image-diff-discussion.yml
...gelogs/unreleased/dm-note-email-image-diff-discussion.yml
+5
-0
config/initializers/zz_metrics.rb
config/initializers/zz_metrics.rb
+3
-0
doc/development/instrumentation.md
doc/development/instrumentation.md
+1
-1
spec/factories/notes.rb
spec/factories/notes.rb
+15
-0
spec/initializers/zz_metrics_spec.rb
spec/initializers/zz_metrics_spec.rb
+1
-1
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+2
-10
spec/models/concerns/discussion_on_diff_spec.rb
spec/models/concerns/discussion_on_diff_spec.rb
+8
-2
spec/models/diff_note_spec.rb
spec/models/diff_note_spec.rb
+1
-16
No files found.
app/models/concerns/discussion_on_diff.rb
View file @
4828758b
...
@@ -39,6 +39,7 @@ module DiscussionOnDiff
...
@@ -39,6 +39,7 @@ module DiscussionOnDiff
# Returns an array of at most 16 highlighted lines above a diff note
# Returns an array of at most 16 highlighted lines above a diff note
def
truncated_diff_lines
(
highlight:
true
,
diff_limit:
nil
)
def
truncated_diff_lines
(
highlight:
true
,
diff_limit:
nil
)
return
[]
unless
on_text?
return
[]
if
diff_line
.
nil?
&&
first_note
.
is_a?
(
LegacyDiffNote
)
return
[]
if
diff_line
.
nil?
&&
first_note
.
is_a?
(
LegacyDiffNote
)
diff_limit
=
[
diff_limit
,
NUMBER_OF_TRUNCATED_DIFF_LINES
].
compact
.
min
diff_limit
=
[
diff_limit
,
NUMBER_OF_TRUNCATED_DIFF_LINES
].
compact
.
min
...
...
app/views/notify/_note_email.html.haml
View file @
4828758b
...
@@ -4,17 +4,13 @@
...
@@ -4,17 +4,13 @@
-
note_style
=
local_assigns
.
fetch
(
:note_style
,
""
)
-
note_style
=
local_assigns
.
fetch
(
:note_style
,
""
)
-
discussion
=
note
.
discussion
if
note
.
part_of_discussion?
-
discussion
=
note
.
discussion
if
note
.
part_of_discussion?
-
diff_discussion
=
discussion
&
.
diff_discussion?
-
on_image
=
discussion
.
on_image?
if
diff_discussion
-
if
discussion
-
if
discussion
-
phrase_end_char
=
on_image
?
"."
:
":"
%p
{
style:
"color: #777777;"
}
%p
{
style:
"color: #777777;"
}
=
succeed
phrase_end_char
do
=
succeed
':'
do
=
link_to
note
.
author_name
,
user_url
(
note
.
author
)
=
link_to
note
.
author_name
,
user_url
(
note
.
author
)
-
if
di
ff_discussion
-
if
di
scussion
&
.
diff_discussion?
-
if
discussion
.
new_discussion?
-
if
discussion
.
new_discussion?
started a new discussion
started a new discussion
-
else
-
else
...
@@ -31,7 +27,7 @@
...
@@ -31,7 +27,7 @@
%p
.details
%p
.details
#{
link_to
note
.
author_name
,
user_url
(
note
.
author
)
}
commented:
#{
link_to
note
.
author_name
,
user_url
(
note
.
author
)
}
commented:
-
if
di
ff_discussion
&&
!
on_image
-
if
di
scussion
&
.
diff_discussion?
&&
discussion
.
on_text?
=
content_for
:head
do
=
content_for
:head
do
=
stylesheet_link_tag
'mailers/highlighted_diff_email'
=
stylesheet_link_tag
'mailers/highlighted_diff_email'
...
...
app/views/notify/_note_email.text.erb
View file @
4828758b
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<%
end
-%>
<%
end
-%>
<%
if
discussion
&
.
diff_discussion?
-%>
<%
if
discussion
&
.
diff_discussion?
&&
discussion
.
on_text?
-%>
<%
discussion
.
truncated_diff_lines
(
highlight:
false
,
diff_limit:
diff_limit
).
each
do
|
line
|
-%>
<%
discussion
.
truncated_diff_lines
(
highlight:
false
,
diff_limit:
diff_limit
).
each
do
|
line
|
-%>
<%=
">
#{
line
.
text
}
\n
"
-%>
<%=
">
#{
line
.
text
}
\n
"
-%>
<%
end
-%>
<%
end
-%>
...
...
changelogs/unreleased/dm-note-email-image-diff-discussion.yml
0 → 100644
View file @
4828758b
---
title
:
Fix notification email for image diff notes
merge_request
:
author
:
type
:
fixed
config/initializers/
8
_metrics.rb
→
config/initializers/
zz
_metrics.rb
View file @
4828758b
# This file was prefixed with zz_ because we want to load it the last!
# See: https://gitlab.com/gitlab-org/gitlab-ce/issues/55611
# Autoload all classes that we want to instrument, and instrument the methods we
# Autoload all classes that we want to instrument, and instrument the methods we
# need. This takes the Gitlab::Metrics::Instrumentation module as an argument so
# need. This takes the Gitlab::Metrics::Instrumentation module as an argument so
# that we can stub it for testing, as it is only called when metrics are
# that we can stub it for testing, as it is only called when metrics are
...
...
doc/development/instrumentation.md
View file @
4828758b
...
@@ -35,7 +35,7 @@ Using this method is in general preferred over directly calling the various
...
@@ -35,7 +35,7 @@ Using this method is in general preferred over directly calling the various
instrumentation methods.
instrumentation methods.
Method instrumentation should be added in the initializer
Method instrumentation should be added in the initializer
`config/initializers/
8
_metrics.rb`
.
`config/initializers/
zz
_metrics.rb`
.
### Examples
### Examples
...
...
spec/factories/notes.rb
View file @
4828758b
...
@@ -64,6 +64,21 @@ FactoryBot.define do
...
@@ -64,6 +64,21 @@ FactoryBot.define do
resolved_at
{
Time
.
now
}
resolved_at
{
Time
.
now
}
resolved_by
{
create
(
:user
)
}
resolved_by
{
create
(
:user
)
}
end
end
factory
:image_diff_note_on_merge_request
do
position
do
Gitlab
::
Diff
::
Position
.
new
(
old_path:
"files/images/any_image.png"
,
new_path:
"files/images/any_image.png"
,
width:
10
,
height:
10
,
x:
1
,
y:
1
,
diff_refs:
diff_refs
,
position_type:
"image"
)
end
end
end
end
factory
:diff_note_on_commit
,
traits:
[
:on_commit
],
class:
DiffNote
do
factory
:diff_note_on_commit
,
traits:
[
:on_commit
],
class:
DiffNote
do
...
...
spec/initializers/
8
_metrics_spec.rb
→
spec/initializers/
zz
_metrics_spec.rb
View file @
4828758b
...
@@ -16,7 +16,7 @@ describe 'instrument_classes' do
...
@@ -16,7 +16,7 @@ describe 'instrument_classes' do
end
end
it
'can autoload and instrument all files'
do
it
'can autoload and instrument all files'
do
require_relative
'../../config/initializers/
8
_metrics'
require_relative
'../../config/initializers/
zz
_metrics'
expect
{
instrument_classes
(
config
)
}.
not_to
raise_error
expect
{
instrument_classes
(
config
)
}.
not_to
raise_error
end
end
end
end
spec/mailers/notify_spec.rb
View file @
4828758b
...
@@ -890,22 +890,14 @@ describe Notify do
...
@@ -890,22 +890,14 @@ describe Notify do
shared_examples
'an email for a note on a diff discussion'
do
|
model
|
shared_examples
'an email for a note on a diff discussion'
do
|
model
|
let
(
:note
)
{
create
(
model
,
author:
note_author
)
}
let
(
:note
)
{
create
(
model
,
author:
note_author
)
}
context
'when note is
on image
'
do
context
'when note is
not on text
'
do
before
do
before
do
allow_any_instance_of
(
DiffDiscussion
).
to
receive
(
:on_
image?
).
and_return
(
tru
e
)
allow_any_instance_of
(
DiffDiscussion
).
to
receive
(
:on_
text?
).
and_return
(
fals
e
)
end
end
it
'does not include diffs with character-level highlighting'
do
it
'does not include diffs with character-level highlighting'
do
is_expected
.
not_to
have_body_text
'<span class="p">}</span></span>'
is_expected
.
not_to
have_body_text
'<span class="p">}</span></span>'
end
end
it
'ends the intro with a dot'
do
is_expected
.
to
have_body_text
"
#{
note
.
diff_file
.
file_path
}
</a>."
end
end
it
'ends the intro with a colon'
do
is_expected
.
to
have_body_text
"
#{
note
.
diff_file
.
file_path
}
</a>:"
end
end
it
'includes diffs with character-level highlighting'
do
it
'includes diffs with character-level highlighting'
do
...
...
spec/models/concerns/discussion_on_diff_spec.rb
View file @
4828758b
...
@@ -50,11 +50,17 @@ describe DiscussionOnDiff do
...
@@ -50,11 +50,17 @@ describe DiscussionOnDiff do
end
end
context
"when the diff line does not exist on a legacy diff note"
do
context
"when the diff line does not exist on a legacy diff note"
do
subject
{
create
(
:legacy_diff_note_on_merge_request
).
to_discussion
}
it
"returns an empty array"
do
it
"returns an empty array"
do
legacy_note
=
LegacyDiffNote
.
new
expect
(
truncated_lines
).
to
eq
([])
end
end
allow
(
subject
).
to
receive
(
:first_note
).
and_return
(
legacy_note
)
context
'when the discussion is on an image'
do
subject
{
create
(
:image_diff_note_on_merge_request
).
to_discussion
}
it
'returns an empty array'
do
expect
(
truncated_lines
).
to
eq
([])
expect
(
truncated_lines
).
to
eq
([])
end
end
end
end
...
...
spec/models/diff_note_spec.rb
View file @
4828758b
...
@@ -337,24 +337,9 @@ describe DiffNote do
...
@@ -337,24 +337,9 @@ describe DiffNote do
end
end
describe
"image diff notes"
do
describe
"image diff notes"
do
let
(
:path
)
{
"files/images/any_image.png"
}
subject
{
build
(
:image_diff_note_on_merge_request
,
project:
project
,
noteable:
merge_request
)
}
let!
(
:position
)
do
Gitlab
::
Diff
::
Position
.
new
(
old_path:
path
,
new_path:
path
,
width:
10
,
height:
10
,
x:
1
,
y:
1
,
diff_refs:
merge_request
.
diff_refs
,
position_type:
"image"
)
end
describe
"validations"
do
describe
"validations"
do
subject
{
build
(
:diff_note_on_merge_request
,
project:
project
,
position:
position
,
noteable:
merge_request
)
}
it
{
is_expected
.
not_to
validate_presence_of
(
:line_code
)
}
it
{
is_expected
.
not_to
validate_presence_of
(
:line_code
)
}
it
"does not validate diff line"
do
it
"does not validate diff line"
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