BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9c30b0e9
Unverified
Commit
9c30b0e9
authored
Mar 13, 2017
by
Douwe Maan
Committed by
Luke "Jared" Bennett
Apr 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some specs
parent
336016fa
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
44 additions
and
21 deletions
+44
-21
notes.js
app/assets/javascripts/notes.js
+2
-2
notes_controller.rb
app/controllers/projects/notes_controller.rb
+2
-0
notes_helper.rb
app/helpers/notes_helper.rb
+1
-3
_notes.html.haml
app/views/projects/notes/_notes.html.haml
+1
-1
merge_requests.rb
features/steps/project/merge_requests.rb
+3
-0
notes_controller_spec.rb
spec/controllers/projects/notes_controller_spec.rb
+2
-1
notes.rb
spec/factories/notes.rb
+13
-0
diff_discussion_spec.rb
spec/models/diff_discussion_spec.rb
+7
-1
merge_request_spec.rb
spec/models/merge_request_spec.rb
+10
-10
note_spec.rb
spec/models/note_spec.rb
+2
-2
issues_spec.rb
spec/requests/api/issues_spec.rb
+1
-1
No files found.
app/assets/javascripts/notes.js
View file @
9c30b0e9
...
...
@@ -192,7 +192,7 @@ require('./task_list');
};
Notes
.
prototype
.
refresh
=
function
()
{
if
(
!
document
.
hidden
&&
document
.
URL
.
indexOf
(
this
.
noteable_url
)
===
0
)
{
if
(
!
document
.
hidden
)
{
return
this
.
getContent
();
}
};
...
...
@@ -371,7 +371,7 @@ require('./task_list');
discussionContainer
.
append
(
note_html
);
}
if
(
typeof
gl
.
diffNotesCompileComponents
!==
'undefined'
&&
note
.
discussion_
id
)
{
if
(
typeof
gl
.
diffNotesCompileComponents
!==
'undefined'
&&
note
.
discussion_
resolvable
)
{
gl
.
diffNotesCompileComponents
();
this
.
renderDiscussionAvatar
(
diffAvatarContainer
,
note
);
}
...
...
app/controllers/projects/notes_controller.rb
View file @
9c30b0e9
...
...
@@ -169,6 +169,8 @@ class Projects::NotesController < Projects::ApplicationController
discussion
=
note
.
to_discussion
(
noteable
)
unless
discussion
.
render_as_individual_notes?
attrs
.
merge!
(
discussion_resolvable:
discussion
.
resolvable?
,
diff_discussion_html:
diff_discussion_html
(
discussion
),
discussion_html:
discussion_html
(
discussion
),
...
...
app/helpers/notes_helper.rb
View file @
9c30b0e9
...
...
@@ -54,17 +54,15 @@ module NotesHelper
if
use_legacy_diff_note
new_note
=
LegacyDiffNote
.
new
(
@new_diff_note_attrs
.
merge
(
line_code:
line_code
))
discussion_id
=
new_note
.
discussion_id
else
new_note
=
DiffNote
.
new
(
@new_diff_note_attrs
.
merge
(
position:
position
))
discussion_id
=
new_note
.
discussion_id
data
[
:position
]
=
position
.
to_json
end
data
.
merge
(
note_type:
new_note
.
type
,
discussion_id:
discussion_id
discussion_id:
new_note
.
discussion_class
.
discussion_id
(
new_note
)
)
end
...
...
app/views/projects/notes/_notes.html.haml
View file @
9c30b0e9
-
if
@discussions
.
present?
-
if
defined?
(
@discussions
)
-
@discussions
.
each
do
|
discussion
|
-
if
discussion
.
render_as_individual_notes?
=
render
partial:
"projects/notes/note"
,
collection:
discussion
.
notes
,
as: :note
...
...
features/steps/project/merge_requests.rb
View file @
9c30b0e9
...
...
@@ -347,6 +347,9 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
end
step
'I should see a discussion by user "John Doe" has started on diff'
do
# Trigger a refresh of notes
execute_script
(
"$(document).trigger('visibilitychange');"
)
wait_for_ajax
page
.
within
(
".notes .discussion"
)
do
page
.
should
have_content
"
#{
user_exists
(
"John Doe"
).
name
}
#{
user_exists
(
"John Doe"
).
to_reference
}
started a discussion"
page
.
should
have_content
sample_commit
.
line_code_path
...
...
spec/controllers/projects/notes_controller_spec.rb
View file @
9c30b0e9
...
...
@@ -58,7 +58,8 @@ describe Projects::NotesController do
noteable_id:
merge_request
.
id
.
to_s
,
noteable_type:
'MergeRequest'
,
merge_request_diff_head_sha:
'sha'
,
in_reply_to_discussion_id:
nil
in_reply_to_discussion_id:
nil
,
new_discussion:
nil
}
expect
(
Notes
::
CreateService
).
to
receive
(
:new
).
with
(
project
,
user
,
service_params
).
and_return
(
double
(
execute:
true
))
...
...
spec/factories/notes.rb
View file @
9c30b0e9
...
...
@@ -117,5 +117,18 @@ FactoryGirl.define do
trait
:with_svg_attachment
do
attachment
{
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/unsanitized.svg"
,
"image/svg+xml"
)
}
end
transient
do
in_reply_to
nil
end
before
(
:create
)
do
|
note
,
evaluator
|
discussion
=
evaluator
.
in_reply_to
next
unless
discussion
discussion
=
discussion
.
to_discussion
if
discussion
.
is_a?
(
Note
)
next
unless
discussion
note
.
assign_attributes
(
discussion
.
reply_attributes
)
end
end
end
spec/models/diff_discussion_spec.rb
View file @
9c30b0e9
require
'spec_helper'
describe
DiffDiscussion
,
model:
true
do
# TODO: Test
subject
{
described_class
.
new
([
first_note
,
second_note
,
third_note
])
}
let
(
:first_note
)
{
create
(
:diff_note_on_merge_request
)
}
let
(
:second_note
)
{
create
(
:diff_note_on_merge_request
)
}
let
(
:third_note
)
{
create
(
:diff_note_on_merge_request
)
}
# TODO: Test
describe
"#truncated_diff_lines"
do
let
(
:truncated_lines
)
{
subject
.
truncated_diff_lines
}
...
...
spec/models/merge_request_spec.rb
View file @
9c30b0e9
...
...
@@ -1234,15 +1234,7 @@ describe MergeRequest, models: true do
end
describe
'#resolvable_discussions'
do
before
do
allow
(
first_discussion
).
to
receive
(
:to_be_resolved?
).
and_return
(
true
)
allow
(
second_discussion
).
to
receive
(
:to_be_resolved?
).
and_return
(
false
)
allow
(
third_discussion
).
to
receive
(
:to_be_resolved?
).
and_return
(
false
)
end
it
'includes only discussions that need to be resolved'
do
expect
(
subject
.
resolvable_discussions
).
to
eq
([
first_discussion
])
end
# TODO: Test
end
describe
"#discussions_resolvable?"
do
...
...
@@ -1372,7 +1364,15 @@ describe MergeRequest, models: true do
end
describe
"#discussions_to_be_resolved"
do
# TODO: Test
before
do
allow
(
first_discussion
).
to
receive
(
:to_be_resolved?
).
and_return
(
true
)
allow
(
second_discussion
).
to
receive
(
:to_be_resolved?
).
and_return
(
false
)
allow
(
third_discussion
).
to
receive
(
:to_be_resolved?
).
and_return
(
false
)
end
it
'includes only discussions that need to be resolved'
do
expect
(
subject
.
discussions_to_be_resolved
).
to
eq
([
first_discussion
])
end
end
describe
'#discussions_can_be_resolved_by?'
do
...
...
spec/models/note_spec.rb
View file @
9c30b0e9
...
...
@@ -414,7 +414,7 @@ describe Note, models: true do
describe
'#to_discussion'
do
subject
{
create
(
:discussion_note_on_merge_request
)
}
let!
(
:note2
)
{
create
(
:discussion_note_on_merge_request
,
project:
subject
.
project
,
noteable:
subject
.
noteable
,
in_reply_to
_discussion_id:
subject
.
discussion_id
)
}
let!
(
:note2
)
{
create
(
:discussion_note_on_merge_request
,
project:
subject
.
project
,
noteable:
subject
.
noteable
,
in_reply_to
:
subject
)
}
it
"returns a discussion with just this note"
do
discussion
=
subject
.
to_discussion
...
...
@@ -429,7 +429,7 @@ describe Note, models: true do
let!
(
:note2
)
{
create
(
:diff_note_on_merge_request
,
project:
note1
.
project
,
noteable:
note1
.
noteable
)
}
context
'when the note is part of a discussion'
do
subject
{
create
(
:discussion_note_on_merge_request
,
project:
note1
.
project
,
noteable:
note1
.
noteable
,
in_reply_to
_discussion_id:
note1
.
discussion_id
)
}
subject
{
create
(
:discussion_note_on_merge_request
,
project:
note1
.
project
,
noteable:
note1
.
noteable
,
in_reply_to
:
note1
)
}
it
"returns the discussion this note is in"
do
discussion
=
subject
.
discussion
...
...
spec/requests/api/issues_spec.rb
View file @
9c30b0e9
...
...
@@ -953,7 +953,7 @@ describe API::Issues, api: true do
end
context
'resolving discussions'
do
let
(
:discussion
)
{
Discussion
.
for_diff_notes
([
create
(
:diff_note_on_merge_request
)]).
first
}
let
(
:discussion
)
{
create
(
:diff_note_on_merge_request
).
to_discussion
}
let
(
:merge_request
)
{
discussion
.
noteable
}
let
(
:project
)
{
merge_request
.
source_project
}
...
...
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