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
Jérome Perrin
gitlab-ce
Commits
2fc45e4d
Commit
2fc45e4d
authored
Oct 05, 2017
by
Vitaliy @blackst0ne Klachkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace the 'project/merge_requests.feature' spinach test with an rspec analog
parent
664cd27f
Changes
22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
773 additions
and
986 deletions
+773
-986
changelogs/unreleased/replace_project_merge_requests-feature.yml
...ogs/unreleased/replace_project_merge_requests-feature.yml
+5
-0
features/project/merge_requests.feature
features/project/merge_requests.feature
+0
-324
features/steps/project/merge_requests.rb
features/steps/project/merge_requests.rb
+0
-632
spec/features/merge_requests/user_posts_diff_notes_spec.rb
spec/features/merge_requests/user_posts_diff_notes_spec.rb
+2
-30
spec/features/projects/merge_requests/user_accepts_merge_request_spec.rb
...rojects/merge_requests/user_accepts_merge_request_spec.rb
+19
-0
spec/features/projects/merge_requests/user_closes_merge_request_spec.rb
...projects/merge_requests/user_closes_merge_request_spec.rb
+21
-0
spec/features/projects/merge_requests/user_comments_on_commit_spec.rb
...s/projects/merge_requests/user_comments_on_commit_spec.rb
+19
-0
spec/features/projects/merge_requests/user_comments_on_diff_spec.rb
...res/projects/merge_requests/user_comments_on_diff_spec.rb
+172
-0
spec/features/projects/merge_requests/user_comments_on_merge_request_spec.rb
...cts/merge_requests/user_comments_on_merge_request_spec.rb
+50
-0
spec/features/projects/merge_requests/user_creates_merge_request_spec.rb
...rojects/merge_requests/user_creates_merge_request_spec.rb
+32
-0
spec/features/projects/merge_requests/user_edits_merge_request_spec.rb
.../projects/merge_requests/user_edits_merge_request_spec.rb
+25
-0
spec/features/projects/merge_requests/user_manages_subscription_spec.rb
...projects/merge_requests/user_manages_subscription_spec.rb
+32
-0
spec/features/projects/merge_requests/user_reopens_merge_request_spec.rb
...rojects/merge_requests/user_reopens_merge_request_spec.rb
+22
-0
spec/features/projects/merge_requests/user_sorts_merge_requests_spec.rb
...projects/merge_requests/user_sorts_merge_requests_spec.rb
+63
-0
spec/features/projects/merge_requests/user_views_all_merge_requests_spec.rb
...ects/merge_requests/user_views_all_merge_requests_spec.rb
+15
-0
spec/features/projects/merge_requests/user_views_closed_merge_requests_spec.rb
...s/merge_requests/user_views_closed_merge_requests_spec.rb
+15
-0
spec/features/projects/merge_requests/user_views_diffs_spec.rb
...features/projects/merge_requests/user_views_diffs_spec.rb
+46
-0
spec/features/projects/merge_requests/user_views_merged_merge_requests_spec.rb
...s/merge_requests/user_views_merged_merge_requests_spec.rb
+15
-0
spec/features/projects/merge_requests/user_views_open_merge_request_spec.rb
...ects/merge_requests/user_views_open_merge_request_spec.rb
+92
-0
spec/features/projects/merge_requests/user_views_open_merge_requests_spec.rb
...cts/merge_requests/user_views_open_merge_requests_spec.rb
+72
-0
spec/support/helpers/merge_request_diff_helpers.rb
spec/support/helpers/merge_request_diff_helpers.rb
+28
-0
spec/support/shared_examples/features/comments_on_merge_request_files_shared_examples.rb
...atures/comments_on_merge_request_files_shared_examples.rb
+28
-0
No files found.
changelogs/unreleased/replace_project_merge_requests-feature.yml
0 → 100644
View file @
2fc45e4d
---
title
:
Replace the 'project/merge_requests.feature' spinach test with an rspec analog
merge_request
:
14621
author
:
Vitaliy @blackst0ne Klachkov
type
:
other
features/project/merge_requests.feature
deleted
100644 → 0
View file @
664cd27f
This diff is collapsed.
Click to expand it.
features/steps/project/merge_requests.rb
deleted
100644 → 0
View file @
664cd27f
This diff is collapsed.
Click to expand it.
spec/features/merge_requests/user_posts_diff_notes_spec.rb
View file @
2fc45e4d
require
'spec_helper'
feature
'Merge requests > User posts diff notes'
,
:js
do
include
MergeRequestDiffHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:project
)
{
merge_request
.
source_project
}
...
...
@@ -244,36 +246,6 @@ feature 'Merge requests > User posts diff notes', :js do
expect
(
line
[
:num
]).
not_to
have_css
comment_button_class
end
def
get_line_components
(
line_holder
,
diff_side
=
nil
)
if
diff_side
.
nil?
get_inline_line_components
(
line_holder
)
else
get_parallel_line_components
(
line_holder
,
diff_side
)
end
end
def
get_inline_line_components
(
line_holder
)
{
content:
line_holder
.
find
(
'.line_content'
,
match: :first
),
num:
line_holder
.
find
(
'.diff-line-num'
,
match: :first
)
}
end
def
get_parallel_line_components
(
line_holder
,
diff_side
=
nil
)
side_index
=
diff_side
==
'left'
?
0
:
1
# Wait for `.line_content`
line_holder
.
find
(
'.line_content'
,
match: :first
)
# Wait for `.diff-line-num`
line_holder
.
find
(
'.diff-line-num'
,
match: :first
)
{
content:
line_holder
.
all
(
'.line_content'
)[
side_index
],
num:
line_holder
.
all
(
'.diff-line-num'
)[
side_index
]
}
end
def
click_diff_line
(
line_holder
,
diff_side
=
nil
)
line
=
get_line_components
(
line_holder
,
diff_side
)
line
[
:content
].
hover
expect
(
line
[
:num
]).
to
have_css
comment_button_class
line
[
:num
].
find
(
comment_button_class
).
trigger
'click'
end
def
write_comment_on_line
(
line_holder
,
diff_side
)
click_diff_line
(
line_holder
,
diff_side
)
...
...
spec/features/projects/merge_requests/user_accepts_merge_request_spec.rb
View file @
2fc45e4d
...
...
@@ -62,4 +62,23 @@ describe 'User accepts a merge request', :js do
wait_for_requests
end
end
context
'when modifying the merge commit message'
do
before
do
merge_request
.
mark_as_mergeable
visit
(
merge_request_path
(
merge_request
))
end
it
'accepts a merge request'
do
click_button
(
'Modify commit message'
)
fill_in
(
'Commit message'
,
with:
'wow such merge'
)
click_button
(
'Merge'
)
page
.
within
(
'.status-box'
)
do
expect
(
page
).
to
have_content
(
'Merged'
)
end
end
end
end
spec/features/projects/merge_requests/user_closes_merge_request_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User closes a merge requests'
,
:js
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
merge_request_path
(
merge_request
))
end
it
'closes a merge request'
do
click_link
(
'Close merge request'
,
match: :first
)
expect
(
page
).
to
have_content
(
merge_request
.
title
)
expect
(
page
).
to
have_content
(
'Closed by'
)
end
end
spec/features/projects/merge_requests/user_comments_on_commit_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User comments on a commit'
,
:js
do
include
MergeRequestDiffHelpers
include
RepoHelpers
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
project_commit_path
(
project
,
sample_commit
.
id
))
end
include_examples
'comment on merge request file'
end
spec/features/projects/merge_requests/user_comments_on_diff_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User comments on a diff'
,
:js
do
include
MergeRequestDiffHelpers
include
RepoHelpers
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:merge_request
)
do
create
(
:merge_request_with_diffs
,
source_project:
project
,
target_project:
project
,
source_branch:
'merge-test'
)
end
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
diffs_project_merge_request_path
(
project
,
merge_request
))
end
context
'when viewing comments'
do
context
'when toggling inline comments'
do
context
'in a single file'
do
it
'hides a comment'
do
click_diff_line
(
find
(
"[id='
#{
sample_compare
.
changes
[
1
][
:line_code
]
}
']"
))
page
.
within
(
'.js-discussion-note-form'
)
do
fill_in
(
'note_note'
,
with:
'Line is wrong'
)
click_button
(
'Comment'
)
end
page
.
within
(
'.files > div:nth-child(3)'
)
do
expect
(
page
).
to
have_content
(
'Line is wrong'
)
find
(
'.js-toggle-diff-comments'
).
trigger
(
'click'
)
expect
(
page
).
not_to
have_content
(
'Line is wrong'
)
end
end
end
context
'in multiple files'
do
it
'toggles comments'
do
click_diff_line
(
find
(
"[id='
#{
sample_compare
.
changes
[
0
][
:line_code
]
}
']"
))
page
.
within
(
'.js-discussion-note-form'
)
do
fill_in
(
'note_note'
,
with:
'Line is correct'
)
click_button
(
'Comment'
)
end
wait_for_requests
page
.
within
(
'.files > div:nth-child(2) .note-body > .note-text'
)
do
expect
(
page
).
to
have_content
(
'Line is correct'
)
end
click_diff_line
(
find
(
"[id='
#{
sample_compare
.
changes
[
1
][
:line_code
]
}
']"
))
page
.
within
(
'.js-discussion-note-form'
)
do
fill_in
(
'note_note'
,
with:
'Line is wrong'
)
click_button
(
'Comment'
)
end
wait_for_requests
# Hide the comment.
page
.
within
(
'.files > div:nth-child(3)'
)
do
find
(
'.js-toggle-diff-comments'
).
trigger
(
'click'
)
expect
(
page
).
not_to
have_content
(
'Line is wrong'
)
end
# At this moment a user should see only one comment.
# The other one should be hidden.
page
.
within
(
'.files > div:nth-child(2) .note-body > .note-text'
)
do
expect
(
page
).
to
have_content
(
'Line is correct'
)
end
# Show the comment.
page
.
within
(
'.files > div:nth-child(3)'
)
do
find
(
'.js-toggle-diff-comments'
).
trigger
(
'click'
)
end
# Now both the comments should be shown.
page
.
within
(
'.files > div:nth-child(3) .note-body > .note-text'
)
do
expect
(
page
).
to
have_content
(
'Line is wrong'
)
end
page
.
within
(
'.files > div:nth-child(2) .note-body > .note-text'
)
do
expect
(
page
).
to
have_content
(
'Line is correct'
)
end
# Check the same comments in the side-by-side view.
click_link
(
'Side-by-side'
)
wait_for_requests
page
.
within
(
'.files > div:nth-child(3) .parallel .note-body > .note-text'
)
do
expect
(
page
).
to
have_content
(
'Line is wrong'
)
end
page
.
within
(
'.files > div:nth-child(2) .parallel .note-body > .note-text'
)
do
expect
(
page
).
to
have_content
(
'Line is correct'
)
end
end
end
end
end
context
'when adding comments'
do
include_examples
'comment on merge request file'
end
context
'when editing comments'
do
it
'edits a comment'
do
click_diff_line
(
find
(
"[id='
#{
sample_commit
.
line_code
}
']"
))
page
.
within
(
'.js-discussion-note-form'
)
do
fill_in
(
:note_note
,
with:
'Line is wrong'
)
click_button
(
'Comment'
)
end
page
.
within
(
'.diff-file:nth-of-type(5) .note'
)
do
find
(
'.js-note-edit'
).
click
page
.
within
(
'.current-note-edit-form'
)
do
fill_in
(
'note_note'
,
with:
'Typo, please fix'
)
click_button
(
'Save comment'
)
end
expect
(
page
).
not_to
have_button
(
'Save comment'
,
disabled:
true
)
end
page
.
within
(
'.diff-file:nth-of-type(5) .note'
)
do
expect
(
page
).
to
have_content
(
'Typo, please fix'
).
and
have_no_content
(
'Line is wrong'
)
end
end
end
context
'when deleting comments'
do
it
'deletes a comment'
do
click_diff_line
(
find
(
"[id='
#{
sample_commit
.
line_code
}
']"
))
page
.
within
(
'.js-discussion-note-form'
)
do
fill_in
(
:note_note
,
with:
'Line is wrong'
)
click_button
(
'Comment'
)
end
page
.
within
(
'.notes-tab .badge'
)
do
expect
(
page
).
to
have_content
(
'1'
)
end
page
.
within
(
'.diff-file:nth-of-type(5) .note'
)
do
find
(
'.more-actions'
).
click
find
(
'.more-actions .dropdown-menu li'
,
match: :first
)
find
(
'.js-note-delete'
).
click
end
page
.
within
(
'.merge-request-tabs'
)
do
find
(
'.notes-tab'
).
trigger
(
'click'
)
end
wait_for_requests
expect
(
page
).
not_to
have_css
(
'.notes .discussion'
)
page
.
within
(
'.notes-tab .badge'
)
do
expect
(
page
).
to
have_content
(
'0'
)
end
end
end
end
spec/features/projects/merge_requests/user_comments_on_merge_request_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User comments on a merge request'
,
:js
do
include
RepoHelpers
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
merge_request_path
(
merge_request
))
end
it
'adds a comment'
do
page
.
within
(
'.js-main-target-form'
)
do
fill_in
(
:note_note
,
with:
'# Comment with a header'
)
click_button
(
'Comment'
)
end
wait_for_requests
page
.
within
(
'.note'
)
do
expect
(
page
).
to
have_content
(
'Comment with a header'
)
expect
(
page
).
not_to
have_css
(
'#comment-with-a-header'
)
end
end
it
'loads new comment'
do
# Add new comment in background in order to check
# if it's going to be loaded automatically for current user.
create
(
:diff_note_on_merge_request
,
project:
project
,
noteable:
merge_request
,
author:
user
,
note:
'Line is wrong'
)
# Trigger a refresh of notes.
execute_script
(
"$(document).trigger('visibilitychange');"
)
wait_for_requests
page
.
within
(
'.notes .discussion'
)
do
expect
(
page
).
to
have_content
(
"
#{
user
.
name
}
#{
user
.
to_reference
}
started a discussion"
)
expect
(
page
).
to
have_content
(
sample_commit
.
line_code_path
)
expect
(
page
).
to
have_content
(
'Line is wrong'
)
end
page
.
within
(
'.notes-tab .badge'
)
do
expect
(
page
).
to
have_content
(
'1'
)
end
end
end
spec/features/projects/merge_requests/user_creates_merge_request_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User creates a merge request'
,
:js
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
project_new_merge_request_path
(
project
))
end
it
'creates a merge request'
do
find
(
'.js-source-branch'
).
click
click_link
(
'fix'
)
find
(
'.js-target-branch'
).
click
click_link
(
'feature'
)
click_button
(
'Compare branches'
)
fill_in
(
'merge_request_title'
,
with:
'Wiki Feature'
)
click_button
(
'Submit merge request'
)
page
.
within
(
'.merge-request'
)
do
expect
(
page
).
to
have_content
(
'Wiki Feature'
)
end
wait_for_requests
end
end
spec/features/projects/merge_requests/user_edits_merge_request_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User edits a merge request'
,
:js
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
edit_project_merge_request_path
(
project
,
merge_request
))
end
it
'changes the target branch'
do
expect
(
page
).
to
have_content
(
'Target branch'
)
first
(
'.target_branch'
).
click
select
(
'merge-test'
,
from:
'merge_request_target_branch'
,
visible:
false
)
click_button
(
'Save changes'
)
expect
(
page
).
to
have_content
(
"Request to merge
#{
merge_request
.
source_branch
}
into merge-test"
)
expect
(
page
).
to
have_content
(
"changed target branch from
#{
merge_request
.
target_branch
}
to merge-test"
)
end
end
spec/features/projects/merge_requests/user_manages_subscription_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User manages subscription'
,
:js
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
merge_request_path
(
merge_request
))
end
it
'toggles subscription'
do
subscribe_button
=
find
(
'.issuable-subscribe-button span'
)
expect
(
subscribe_button
).
to
have_content
(
'Subscribe'
)
click_on
(
'Subscribe'
)
wait_for_requests
expect
(
subscribe_button
).
to
have_content
(
'Unsubscribe'
)
click_on
(
'Unsubscribe'
)
wait_for_requests
expect
(
subscribe_button
).
to
have_content
(
'Subscribe'
)
end
end
spec/features/projects/merge_requests/user_reopens_merge_request_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User reopens a merge requests'
,
:js
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
let!
(
:merge_request
)
{
create
(
:closed_merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
merge_request_path
(
merge_request
))
end
it
'reopens a merge request'
do
click_link
(
'Reopen merge request'
,
match: :first
)
page
.
within
(
'.status-box'
)
do
expect
(
page
).
to
have_content
(
'Open'
)
end
end
end
spec/features/projects/merge_requests/user_sorts_merge_requests_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User sorts merge requests'
do
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let!
(
:merge_request2
)
do
create
(
:merge_request_with_diffs
,
source_project:
project
,
target_project:
project
,
source_branch:
'merge-test'
)
end
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
project_merge_requests_path
(
project
))
end
it
'keeps the sort option'
do
find
(
'button.dropdown-toggle'
).
click
page
.
within
(
'.content ul.dropdown-menu.dropdown-menu-align-right li'
)
do
click_link
(
'Last updated'
)
end
visit
(
merge_requests_dashboard_path
(
assignee_id:
user
.
id
))
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'Last updated'
)
visit
(
project_merge_requests_path
(
project
))
expect
(
find
(
'.issues-filters'
)).
to
have_content
(
'Last updated'
)
end
context
'when merge requests have awards'
do
before
do
create_list
(
:award_emoji
,
2
,
awardable:
merge_request
)
create
(
:award_emoji
,
:downvote
,
awardable:
merge_request
)
create
(
:award_emoji
,
awardable:
merge_request2
)
create_list
(
:award_emoji
,
2
,
:downvote
,
awardable:
merge_request2
)
end
it
'sorts by popularity'
do
find
(
'button.dropdown-toggle'
).
click
page
.
within
(
'.content ul.dropdown-menu.dropdown-menu-align-right li'
)
do
click_link
(
'Popularity'
)
end
page
.
within
(
'.mr-list'
)
do
page
.
within
(
'li.merge-request:nth-child(1)'
)
do
expect
(
page
).
to
have_content
(
merge_request
.
title
)
expect
(
page
).
to
have_content
(
'2 1'
)
end
page
.
within
(
'li.merge-request:nth-child(2)'
)
do
expect
(
page
).
to
have_content
(
merge_request2
.
title
)
expect
(
page
).
to
have_content
(
'1 2'
)
end
end
end
end
end
spec/features/projects/merge_requests/user_views_all_merge_requests_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User views all merge requests'
do
let!
(
:closed_merge_request
)
{
create
(
:closed_merge_request
,
source_project:
project
,
target_project:
project
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
before
do
visit
(
project_merge_requests_path
(
project
,
state: :all
))
end
it
'shows all merge requests'
do
expect
(
page
).
to
have_content
(
merge_request
.
title
).
and
have_content
(
closed_merge_request
.
title
)
end
end
spec/features/projects/merge_requests/user_views_closed_merge_requests_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User views closed merge requests'
do
let!
(
:closed_merge_request
)
{
create
(
:closed_merge_request
,
source_project:
project
,
target_project:
project
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
before
do
visit
(
project_merge_requests_path
(
project
,
state: :closed
))
end
it
'shows closed merge requests'
do
expect
(
page
).
to
have_content
(
closed_merge_request
.
title
).
and
have_no_content
(
merge_request
.
title
)
end
end
spec/features/projects/merge_requests/user_views_diffs_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User views diffs'
,
:js
do
let
(
:merge_request
)
do
create
(
:merge_request_with_diffs
,
source_project:
project
,
target_project:
project
,
source_branch:
'merge-test'
)
end
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
before
do
visit
(
diffs_project_merge_request_path
(
project
,
merge_request
))
wait_for_requests
end
shared_examples
'unfold diffs'
do
it
'unfolds diffs'
do
first
(
'.js-unfold'
).
click
expect
(
first
(
'.text-file'
)).
to
have_content
(
'.bundle'
)
end
end
it
'shows diffs'
do
expect
(
page
).
to
have_css
(
'.tab-content #diffs.active'
)
expect
(
page
).
to
have_css
(
'#parallel-diff-btn'
,
count:
1
)
expect
(
page
).
to
have_css
(
'#inline-diff-btn'
,
count:
1
)
end
context
'when in the inline view'
do
include_examples
'unfold diffs'
end
context
'when in the side-by-side view'
do
before
do
click_link
(
'Side-by-side'
)
wait_for_requests
end
it
'shows diffs in parallel'
do
expect
(
page
).
to
have_css
(
'.parallel'
)
end
include_examples
'unfold diffs'
end
end
spec/features/projects/merge_requests/user_views_merged_merge_requests_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User views merged merge requests'
do
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let!
(
:merged_merge_request
)
{
create
(
:merged_merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
before
do
visit
(
project_merge_requests_path
(
project
,
state: :merged
))
end
it
'shows merged merge requests'
do
expect
(
page
).
to
have_content
(
merged_merge_request
.
title
).
and
have_no_content
(
merge_request
.
title
)
end
end
spec/features/projects/merge_requests/user_views_open_merge_request_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User views an open merge request'
do
let
(
:merge_request
)
do
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
description:
'# Description header'
)
end
context
'when a merge request does not have repository'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
before
do
visit
(
merge_request_path
(
merge_request
))
end
it
'renders both the title and the description'
do
node
=
find
(
'.wiki h1 a#user-content-description-header'
)
expect
(
node
[
:href
]).
to
end_with
(
'#description-header'
)
# Work around a weird Capybara behavior where calling `parent` on a node
# returns the whole document, not the node's actual parent element
expect
(
find
(
:xpath
,
"
#{
node
.
path
}
/.."
).
text
).
to
eq
(
merge_request
.
description
[
2
..-
1
])
expect
(
page
).
to
have_content
(
merge_request
.
title
).
and
have_content
(
merge_request
.
description
)
end
end
context
'when a merge request has repository'
,
:js
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
context
'when rendering description preview'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
visit
(
edit_project_merge_request_path
(
project
,
merge_request
))
end
it
'renders empty description preview'
do
find
(
'.gfm-form'
).
fill_in
(
:merge_request_description
,
with:
''
)
page
.
within
(
'.gfm-form'
)
do
click_link
(
'Preview'
)
expect
(
find
(
'.js-md-preview'
)).
to
have_content
(
'Nothing to preview.'
)
end
end
it
'renders description preview'
do
find
(
'.gfm-form'
).
fill_in
(
:merge_request_description
,
with:
':+1: Nice'
)
page
.
within
(
'.gfm-form'
)
do
click_link
(
'Preview'
)
expect
(
find
(
'.js-md-preview'
)).
to
have_css
(
'gl-emoji'
)
end
expect
(
find
(
'.gfm-form'
)).
to
have_css
(
'.js-md-preview'
).
and
have_link
(
'Write'
)
expect
(
find
(
'#merge_request_description'
,
visible:
false
)).
not_to
be_visible
end
end
context
'when the branch is rebased on the target'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
:rebased
,
source_project:
project
,
target_project:
project
)
}
before
do
visit
(
merge_request_path
(
merge_request
))
end
it
'does not show diverged commits count'
do
page
.
within
(
'.mr-source-target'
)
do
expect
(
page
).
not_to
have_content
(
/([0-9]+ commit[s]? behind)/
)
end
end
end
context
'when the branch is diverged on the target'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
:diverged
,
source_project:
project
,
target_project:
project
)
}
before
do
visit
(
merge_request_path
(
merge_request
))
end
it
'shows diverged commits count'
do
page
.
within
(
'.mr-source-target'
)
do
expect
(
page
).
to
have_content
(
/([0-9]+ commits behind)/
)
end
end
end
end
end
spec/features/projects/merge_requests/user_views_open_merge_requests_spec.rb
0 → 100644
View file @
2fc45e4d
require
'spec_helper'
describe
'User views open merge requests'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
context
"when the target branch is the project's default branch"
do
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let!
(
:closed_merge_request
)
{
create
(
:closed_merge_request
,
source_project:
project
,
target_project:
project
)
}
before
do
visit
(
project_merge_requests_path
(
project
))
end
it
'shows open merge requests'
do
expect
(
page
).
to
have_content
(
merge_request
.
title
).
and
have_no_content
(
closed_merge_request
.
title
)
end
it
'does not show target branch name'
do
expect
(
page
).
to
have_content
(
merge_request
.
title
)
expect
(
find
(
'.issuable-info'
)).
not_to
have_content
(
project
.
default_branch
)
end
end
context
"when the target branch is different from the project's default branch"
do
let!
(
:merge_request
)
do
create
(
:merge_request
,
source_project:
project
,
target_project:
project
,
source_branch:
'fix'
,
target_branch:
'feature_conflict'
)
end
before
do
visit
(
project_merge_requests_path
(
project
))
end
it
'shows target branch name'
do
expect
(
page
).
to
have_content
(
merge_request
.
target_branch
)
end
end
context
'when a merge request has pipelines'
do
let!
(
:build
)
{
create
:ci_build
,
pipeline:
pipeline
}
let
(
:merge_request
)
do
create
(
:merge_request_with_diffs
,
source_project:
project
,
target_project:
project
,
source_branch:
'merge-test'
)
end
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
merge_request
.
diff_head_sha
,
ref:
merge_request
.
source_branch
,
head_pipeline_of:
merge_request
)
end
before
do
project
.
enable_ci
visit
(
project_merge_requests_path
(
project
))
end
it
'shows pipeline status'
do
page
.
within
(
'.mr-list'
)
do
expect
(
page
).
to
have_link
(
'Pipeline: pending'
)
end
end
end
end
spec/support/helpers/merge_request_diff_helpers.rb
0 → 100644
View file @
2fc45e4d
module
MergeRequestDiffHelpers
def
click_diff_line
(
line_holder
,
diff_side
=
nil
)
line
=
get_line_components
(
line_holder
,
diff_side
)
line
[
:content
].
hover
line
[
:num
].
find
(
'.add-diff-note'
).
trigger
(
'click'
)
end
def
get_line_components
(
line_holder
,
diff_side
=
nil
)
if
diff_side
.
nil?
get_inline_line_components
(
line_holder
)
else
get_parallel_line_components
(
line_holder
,
diff_side
)
end
end
def
get_inline_line_components
(
line_holder
)
{
content:
line_holder
.
find
(
'.line_content'
,
match: :first
),
num:
line_holder
.
find
(
'.diff-line-num'
,
match: :first
)
}
end
def
get_parallel_line_components
(
line_holder
,
diff_side
=
nil
)
side_index
=
diff_side
==
'left'
?
0
:
1
# Wait for `.line_content`
line_holder
.
find
(
'.line_content'
,
match: :first
)
# Wait for `.diff-line-num`
line_holder
.
find
(
'.diff-line-num'
,
match: :first
)
{
content:
line_holder
.
all
(
'.line_content'
)[
side_index
],
num:
line_holder
.
all
(
'.diff-line-num'
)[
side_index
]
}
end
end
spec/support/shared_examples/features/comments_on_merge_request_files_shared_examples.rb
0 → 100644
View file @
2fc45e4d
shared_examples
'comment on merge request file'
do
it
'adds a comment'
do
click_diff_line
(
find
(
"[id='
#{
sample_commit
.
line_code
}
']"
))
page
.
within
(
'.js-discussion-note-form'
)
do
fill_in
(
:note_note
,
with:
'Line is wrong'
)
click_button
(
'Comment'
)
end
wait_for_requests
page
.
within
(
'.notes_holder'
)
do
expect
(
page
).
to
have_content
(
'Line is wrong'
)
end
visit
(
merge_request_path
(
merge_request
))
page
.
within
(
'.notes .discussion'
)
do
expect
(
page
).
to
have_content
(
"
#{
user
.
name
}
#{
user
.
to_reference
}
started a discussion"
)
expect
(
page
).
to
have_content
(
sample_commit
.
line_code_path
)
expect
(
page
).
to
have_content
(
'Line is wrong'
)
end
page
.
within
(
'.notes-tab .badge'
)
do
expect
(
page
).
to
have_content
(
'1'
)
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