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
Tatuya Kamada
gitlab-ce
Commits
54bfe707
Commit
54bfe707
authored
Oct 05, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more tests to check conflicts resolution
parent
c4142cf9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
51 deletions
+101
-51
app/assets/javascripts/merge_conflict_data_provider.js.es6
app/assets/javascripts/merge_conflict_data_provider.js.es6
+1
-1
app/assets/javascripts/merge_conflicts/merge_conflict_store.js.es6
...s/javascripts/merge_conflicts/merge_conflict_store.js.es6
+3
-1
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+1
-0
spec/features/merge_requests/conflicts_spec.rb
spec/features/merge_requests/conflicts_spec.rb
+96
-49
No files found.
app/assets/javascripts/merge_conflict_data_provider.js.es6
View file @
54bfe707
...
@@ -290,7 +290,7 @@ class MergeConflictDataProvider {
...
@@ -290,7 +290,7 @@ class MergeConflictDataProvider {
isReadyToCommit() {
isReadyToCommit() {
const vi = this.vueInstance;
const vi = this.vueInstance;
const files = this.vueInstance.conflictsData.files;
const files = this.vueInstance.conflictsData.files;
const hasCommitMessage =
$.trim(this.vueInstance.conflictsData.commitMessage).length
;
const hasCommitMessage =
this.vueInstance.conflictsData.commitMessage.trim()
;
let unresolved = 0;
let unresolved = 0;
for (let i = 0, l = files.length; i < l; i++) {
for (let i = 0, l = files.length; i < l; i++) {
...
...
app/assets/javascripts/merge_conflicts/merge_conflict_store.js.es6
View file @
54bfe707
...
@@ -321,7 +321,8 @@
...
@@ -321,7 +321,8 @@
let numberConflicts = 0;
let numberConflicts = 0;
let resolvedConflicts = Object.keys(file.resolutionData).length
let resolvedConflicts = Object.keys(file.resolutionData).length
// We only check if
// We only check for conflicts type 'text'
// since conflicts `text_editor` can´t be resolved in interactive mode
if (file.type === CONFLICT_TYPES.TEXT) {
if (file.type === CONFLICT_TYPES.TEXT) {
for (let j = 0, k = file.sections.length; j < k; j++) {
for (let j = 0, k = file.sections.length; j < k; j++) {
if (file.sections[j].conflict) {
if (file.sections[j].conflict) {
...
@@ -334,6 +335,7 @@
...
@@ -334,6 +335,7 @@
}
}
}
}
} else if (file.resolveMode === EDIT_RESOLVE_MODE) {
} else if (file.resolveMode === EDIT_RESOLVE_MODE) {
// Unlikely to happen since switching to Edit mode saves content automatically.
// Unlikely to happen since switching to Edit mode saves content automatically.
// Checking anyway in case the save strategy changes in the future
// Checking anyway in case the save strategy changes in the future
if (!file.content) {
if (!file.content) {
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
54bfe707
...
@@ -659,6 +659,7 @@ describe Projects::MergeRequestsController do
...
@@ -659,6 +659,7 @@ describe Projects::MergeRequestsController do
id:
merge_request
.
iid
id:
merge_request
.
iid
expect
(
merge_request
.
reload
.
title
).
to
eq
(
merge_request
.
wipless_title
)
expect
(
merge_request
.
reload
.
title
).
to
eq
(
merge_request
.
wipless_title
)
end
end
end
describe
'GET conflict_for_path'
do
describe
'GET conflict_for_path'
do
...
...
spec/features/merge_requests/conflicts_spec.rb
View file @
54bfe707
...
@@ -12,74 +12,121 @@ feature 'Merge request conflict resolution', js: true, feature: true do
...
@@ -12,74 +12,121 @@ feature 'Merge request conflict resolution', js: true, feature: true do
end
end
end
end
context
'when a merge request can be resolved in the UI'
do
shared_examples
"conflicts are resolved in Interactive mode"
do
let
(
:merge_request
)
{
create_merge_request
(
'conflict-resolvable'
)
}
it
'conflicts are resolved in Interactive mode'
do
within
find
(
'.files-wrapper .diff-file'
,
text:
'files/ruby/popen.rb'
)
do
click_button
'Use ours'
end
before
do
within
find
(
'.files-wrapper .diff-file'
,
text:
'files/ruby/regex.rb'
)
do
project
.
team
<<
[
user
,
:developer
]
all
(
'button'
,
text:
'Use ours'
).
each
do
|
button
|
login_as
(
user
)
button
.
click
end
end
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
click_button
'Commit conflict resolution'
end
wait_for_ajax
it
'shows a link to the conflict resolution page'
do
expect
(
page
).
to
have_content
(
'All merge conflicts were resolved'
)
expect
(
page
).
to
have_link
(
'conflicts'
,
href:
/\/conflicts\Z/
)
merge_request
.
reload_diff
end
context
'visiting the conflicts resolution page'
do
click_on
'Changes'
before
{
click_link
(
'conflicts'
,
href:
/\/conflicts\Z/
)
}
wait_for_ajax
it
'shows the conflicts'
do
within
find
(
'.diff-file'
,
text:
'files/ruby/popen.rb'
)
do
begin
expect
(
page
).
to
have_selector
(
'.line_content.new'
,
text:
"vars = { 'PWD' => path }"
)
expect
(
find
(
'#conflicts'
)).
to
have_content
(
'popen.rb'
)
expect
(
page
).
to
have_selector
(
'.line_content.new'
,
text:
"options = { chdir: path }"
)
rescue
Capybara
::
Poltergeist
::
JavascriptError
retry
end
end
end
context
'when in inline mode'
do
within
find
(
'.diff-file'
,
text:
'files/ruby/regex.rb'
)
do
it
'resolves files manually'
do
expect
(
page
).
to
have_selector
(
'.line_content.new'
,
text:
"def username_regexp"
)
within
find
(
'.files-wrapper .diff-file'
,
text:
'files/ruby/popen.rb'
)
do
expect
(
page
).
to
have_selector
(
'.line_content.new'
,
text:
"def project_name_regexp"
)
click_button
'Edit inline'
expect
(
page
).
to
have_selector
(
'.line_content.new'
,
text:
"def path_regexp"
)
wait_for_ajax
expect
(
page
).
to
have_selector
(
'.line_content.new'
,
text:
"def archive_formats_regexp"
)
execute_script
(
'ace.edit($(".files-wrapper .diff-file pre")[0]).setValue("One morning");'
)
expect
(
page
).
to
have_selector
(
'.line_content.new'
,
text:
"def git_reference_regexp"
)
end
expect
(
page
).
to
have_selector
(
'.line_content.new'
,
text:
"def default_regexp"
)
end
within
find
(
'.files-wrapper .diff-file'
,
text:
'files/ruby/regex.rb'
)
do
end
click_button
'Edit inline'
end
wait_for_ajax
execute_script
(
'ace.edit($(".files-wrapper .diff-file pre")[1]).setValue("Gregor Samsa woke from troubled dreams");'
)
end
click_button
'Commit conflict resolution'
wait_for_ajax
expect
(
page
).
to
have_content
(
'All merge conflicts were resolved'
)
merge_request
.
reload_diff
click_on
'Changes'
shared_examples
"conflicts are resolved in Edit inline mode"
do
wait_for_ajax
it
'conflicts are resolved in Edit inline mode'
do
expect
(
find
(
'#conflicts'
)).
to
have_content
(
'popen.rb'
)
expect
(
page
).
to
have_content
(
'One morning'
)
within
find
(
'.files-wrapper .diff-file'
,
text:
'files/ruby/popen.rb'
)
do
expect
(
page
).
to
have_content
(
'Gregor Samsa woke from troubled dreams'
)
click_button
'Edit inline'
end
wait_for_ajax
execute_script
(
'ace.edit($(".files-wrapper .diff-file pre")[0]).setValue("One morning");'
)
end
end
within
find
(
'.files-wrapper .diff-file'
,
text:
'files/ruby/regex.rb'
)
do
click_button
'Edit inline'
wait_for_ajax
execute_script
(
'ace.edit($(".files-wrapper .diff-file pre")[1]).setValue("Gregor Samsa woke from troubled dreams");'
)
end
click_button
'Commit conflict resolution'
wait_for_ajax
expect
(
page
).
to
have_content
(
'All merge conflicts were resolved'
)
merge_request
.
reload_diff
click_on
'Changes'
wait_for_ajax
expect
(
page
).
to
have_content
(
'One morning'
)
expect
(
page
).
to
have_content
(
'Gregor Samsa woke from troubled dreams'
)
end
end
end
end
context
'when a merge request can be resolved in the UI'
do
context
'can be resolved in the UI'
do
let
(
:merge_request
)
{
create_merge_request
(
'conflict-contains-conflict-markers'
)
}
before
do
before
do
project
.
team
<<
[
user
,
:developer
]
project
.
team
<<
[
user
,
:developer
]
login_as
(
user
)
login_as
(
user
)
end
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
context
'the conflicts are resolvable'
do
let
(
:merge_request
)
{
create_merge_request
(
'conflict-resolvable'
)
}
before
{
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
}
it
'shows a link to the conflict resolution page'
do
expect
(
page
).
to
have_link
(
'conflicts'
,
href:
/\/conflicts\Z/
)
end
context
'in Inline view mode'
do
before
{
click_link
(
'conflicts'
,
href:
/\/conflicts\Z/
)
}
include_examples
"conflicts are resolved in Interactive mode"
include_examples
"conflicts are resolved in Edit inline mode"
end
context
'in Parallel view mode'
do
before
do
click_link
(
'conflicts'
,
href:
/\/conflicts\Z/
)
click_button
'Side-by-side'
end
include_examples
"conflicts are resolved in Interactive mode"
include_examples
"conflicts are resolved in Edit inline mode"
end
end
end
context
'a conflict contain markers'
do
context
'the conflict contain markers'
do
before
{
click_link
(
'conflicts'
,
href:
/\/conflicts\Z/
)
}
let
(
:merge_request
)
{
create_merge_request
(
'conflict-contains-conflict-markers'
)
}
before
do
visit
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
click_link
(
'conflicts'
,
href:
/\/conflicts\Z/
)
end
it
'conflicts can not be resolved in Interactive mode'
do
within
find
(
'.files-wrapper .diff-file'
,
text:
'files/markdown/ruby-style-guide.md'
)
do
expect
(
page
).
not_to
have_content
'Interactive mode'
expect
(
page
).
not_to
have_content
'Edit inline'
end
end
it
'
resolves files manually
'
do
it
'
conflicts are resolved in Edit inline mode
'
do
within
find
(
'.files-wrapper .diff-file'
,
text:
'files/markdown/ruby-style-guide.md'
)
do
within
find
(
'.files-wrapper .diff-file'
,
text:
'files/markdown/ruby-style-guide.md'
)
do
wait_for_ajax
wait_for_ajax
execute_script
(
'ace.edit($(".files-wrapper .diff-file pre")[0]).setValue("Gregor Samsa woke from troubled dreams");'
)
execute_script
(
'ace.edit($(".files-wrapper .diff-file pre")[0]).setValue("Gregor Samsa woke from troubled dreams");'
)
...
@@ -94,7 +141,7 @@ feature 'Merge request conflict resolution', js: true, feature: true do
...
@@ -94,7 +141,7 @@ feature 'Merge request conflict resolution', js: true, feature: true do
click_on
'Changes'
click_on
'Changes'
wait_for_ajax
wait_for_ajax
find
(
'.
nothing-here-block'
,
visible:
true
).
click
find
(
'.
click-to-expand'
).
click
wait_for_ajax
wait_for_ajax
expect
(
page
).
to
have_content
(
'Gregor Samsa woke from troubled dreams'
)
expect
(
page
).
to
have_content
(
'Gregor Samsa woke from troubled dreams'
)
...
...
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