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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
4f8c36c0
Commit
4f8c36c0
authored
Apr 10, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs
parent
48a0e9f6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
2 deletions
+98
-2
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+12
-0
spec/factories/notes.rb
spec/factories/notes.rb
+2
-1
spec/features/merge_requests/discussion_spec.rb
spec/features/merge_requests/discussion_spec.rb
+51
-0
spec/features/merge_requests/versions_spec.rb
spec/features/merge_requests/versions_spec.rb
+16
-1
spec/models/diff_note_spec.rb
spec/models/diff_note_spec.rb
+17
-0
No files found.
app/models/merge_request_diff.rb
View file @
4f8c36c0
...
...
@@ -134,6 +134,18 @@ class MergeRequestDiff < ActiveRecord::Base
st_commits
.
map
{
|
commit
|
commit
[
:id
]
}
end
def
diff_refs
=
(
new_diff_refs
)
if
new_diff_refs
self
.
base_commit_sha
=
new_diff_refs
.
base_sha
self
.
start_commit_sha
=
new_diff_refs
.
start_sha
self
.
head_commit_sha
=
new_diff_refs
.
head_sha
else
self
.
base_commit_sha
=
nil
self
.
start_commit_sha
=
nil
self
.
head_commit_sha
=
nil
end
end
def
diff_refs
return
unless
start_commit_sha
||
base_commit_sha
...
...
spec/factories/notes.rb
View file @
4f8c36c0
...
...
@@ -40,6 +40,7 @@ FactoryGirl.define do
transient
do
line_number
14
diff_refs
{
noteable
.
try
(
:diff_refs
)
}
end
position
do
...
...
@@ -48,7 +49,7 @@ FactoryGirl.define do
new_path:
"files/ruby/popen.rb"
,
old_line:
nil
,
new_line:
line_number
,
diff_refs:
noteable
.
try
(
:diff_refs
)
diff_refs:
diff_refs
)
end
...
...
spec/features/merge_requests/discussion_spec.rb
0 → 100644
View file @
4f8c36c0
require
'spec_helper'
feature
'Merge Request Discussions'
,
feature:
true
do
before
do
login_as
:admin
end
context
"Diff discussions"
do
let
(
:merge_request
)
{
create
(
:merge_request
,
importing:
true
)
}
let
(
:project
)
{
merge_request
.
source_project
}
let!
(
:old_merge_request_diff
)
{
merge_request
.
merge_request_diffs
.
create
(
diff_refs:
outdated_diff_refs
)
}
let!
(
:new_merge_request_diff
)
{
merge_request
.
merge_request_diffs
.
create
}
let!
(
:outdated_discussion
)
{
create
(
:diff_note_on_merge_request
,
project:
project
,
noteable:
merge_request
,
position:
outdated_position
).
to_discussion
}
let!
(
:active_discussion
)
{
create
(
:diff_note_on_merge_request
,
noteable:
merge_request
,
project:
project
).
to_discussion
}
let
(
:outdated_position
)
do
Gitlab
::
Diff
::
Position
.
new
(
old_path:
"files/ruby/popen.rb"
,
new_path:
"files/ruby/popen.rb"
,
old_line:
nil
,
new_line:
9
,
diff_refs:
outdated_diff_refs
)
end
let
(
:outdated_diff_refs
)
{
project
.
commit
(
"874797c3a73b60d2187ed6e2fcabd289ff75171e"
).
diff_refs
}
before
(
:each
)
do
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
end
context
'active discussions'
do
it
'shows a link to the diff'
do
within
(
".discussion[data-discussion-id='
#{
active_discussion
.
id
}
']"
)
do
path
=
diffs_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
,
anchor:
active_discussion
.
line_code
)
expect
(
page
).
to
have_link
(
'the diff'
,
href:
path
)
end
end
end
context
'outdated discussions'
do
it
'shows a link to the outdated diff'
do
within
(
".discussion[data-discussion-id='
#{
outdated_discussion
.
id
}
']"
)
do
path
=
diffs_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
,
diff_id:
old_merge_request_diff
.
id
,
anchor:
outdated_discussion
.
line_code
)
expect
(
page
).
to
have_link
(
'an outdated diff'
,
href:
path
)
end
end
end
end
end
spec/features/merge_requests/
merge_request_
versions_spec.rb
→
spec/features/merge_requests/versions_spec.rb
View file @
4f8c36c0
...
...
@@ -36,9 +36,24 @@ feature 'Merge Request versions', js: true, feature: true do
expect
(
page
).
to
have_content
'5 changed files'
end
it
'show the message about disabled comment
s
'
do
it
'show the message about disabled comment
creation
'
do
expect
(
page
).
to
have_content
'comment creation is disabled'
end
it
'shows comments that were last relevant at that version'
do
position
=
Gitlab
::
Diff
::
Position
.
new
(
old_path:
".gitmodules"
,
new_path:
".gitmodules"
,
old_line:
nil
,
new_line:
4
,
diff_refs:
merge_request_diff1
.
diff_refs
)
outdated_diff_note
=
create
(
:diff_note_on_merge_request
,
project:
project
,
noteable:
merge_request
,
position:
position
)
outdated_diff_note
.
position
=
outdated_diff_note
.
original_position
outdated_diff_note
.
save!
expect
(
page
).
to
have_css
(
".diffs .notes[data-discussion-id='
#{
outdated_diff_note
.
discussion_id
}
']"
)
end
end
describe
'compare with older version'
do
...
...
spec/models/diff_note_spec.rb
View file @
4f8c36c0
...
...
@@ -155,6 +155,23 @@ describe DiffNote, models: true do
end
end
describe
'#latest_merge_request_diff'
do
context
'when active'
do
it
'returns the current merge request diff'
do
expect
(
subject
.
latest_merge_request_diff
).
to
eq
(
merge_request
.
merge_request_diff
)
end
end
context
'when outdated'
do
let!
(
:old_merge_request_diff
)
{
merge_request
.
merge_request_diff
}
let!
(
:new_merge_request_diff
)
{
merge_request
.
merge_request_diffs
.
create
(
diff_refs:
commit
.
diff_refs
)
}
it
'returns the latest merge request diff that this diff note applied to'
do
expect
(
subject
.
latest_merge_request_diff
).
to
eq
(
old_merge_request_diff
)
end
end
end
describe
"creation"
do
describe
"updating of position"
do
context
"when noteable is a commit"
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