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
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
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
@project_merge_requests
Feature
:
Project Merge Requests
Background
:
Given
I sign in as a user
And
I own project
"Shop"
And
project
"Shop"
have
"Bug NS-04"
open merge request
And
project
"Shop"
have
"Feature NS-03"
closed merge request
And
I visit project
"Shop"
merge requests page
Scenario
:
I
should see open merge requests
Then
I should see
"Bug NS-04"
in merge requests
And
I should not see
"Feature NS-03"
in merge requests
Scenario
:
I
should see CI status for merge requests
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
Given
"Bug NS-05"
has CI status
When
I visit project
"Shop"
merge requests page
Then
I should see merge request
"Bug NS-05"
with CI status
Scenario
:
I
should not see target branch name when it is project's default branch
Then
I should see
"Bug NS-04"
in merge requests
And
I should not see
"master"
branch
Scenario
:
I
should see target branch when it is different from default
Given
project
"Shop"
have
"Bug NS-06"
open merge request
When
I visit project
"Shop"
merge requests page
Then
I should see
"feature_conflict"
branch
@javascript
Scenario
:
I
should not see the numbers of diverged commits if the branch is rebased on the target
Given
project
"Shop"
have
"Bug NS-07"
open merge request with rebased branch
When
I visit merge request page
"Bug NS-07"
Then
I should not see the diverged commits count
@javascript
Scenario
:
I
should see the numbers of diverged commits if the branch diverged from the target
Given
project
"Shop"
have
"Bug NS-08"
open merge request with diverged branch
When
I visit merge request page
"Bug NS-08"
Then
I should see the diverged commits count
@javascript
Scenario
:
I
should see rejected merge requests
Given
I click link
"Closed"
Then
I should see
"Feature NS-03"
in merge requests
And
I should not see
"Bug NS-04"
in merge requests
@javascript
Scenario
:
I
should see all merge requests
Given
I click link
"All"
Then
I should see
"Feature NS-03"
in merge requests
And
I should see
"Bug NS-04"
in merge requests
@javascript
Scenario
:
I
visit an open merge request page
Given
I click link
"Bug NS-04"
Then
I should see merge request
"Bug NS-04"
@javascript
Scenario
:
I
visit a merged merge request page
Given
project
"Shop"
have
"Feature NS-05"
merged merge request
And
I click link
"Merged"
And
I click link
"Feature NS-05"
Then
I should see merge request
"Feature NS-05"
@javascript
Scenario
:
I
close merge request page
Given
I click link
"Bug NS-04"
And
I click link
"Close"
Then
I should see closed merge request
"Bug NS-04"
@javascript
Scenario
:
I
reopen merge request page
Given
I click link
"Bug NS-04"
And
I click link
"Close"
Then
I should see closed merge request
"Bug NS-04"
When
I click link
"Reopen"
Then
I should see reopened merge request
"Bug NS-04"
@javascript
Scenario
:
I
submit new unassigned merge request
Given
I click link
"New Merge Request"
And
I submit new merge request
"Wiki Feature"
Then
I should see merge request
"Wiki Feature"
@javascript
Scenario
:
I
comment on a merge request
Given
I visit merge request page
"Bug NS-04"
And
I leave a comment like
"XML attached"
Then
I should see comment
"XML attached"
@javascript
Scenario
:
Visiting Merge Requests after being sorted the list
Given
I visit project
"Shop"
merge requests page
And
I sort the list by
"Last updated"
And
I visit my project's home page
And
I visit project
"Shop"
merge requests page
Then
The list should be sorted by
"Last updated"
@javascript
Scenario
:
Visiting Merge Requests from a different Project after sorting
Given
I visit project
"Shop"
merge requests page
And
I sort the list by
"Last updated"
And
I visit dashboard merge requests page
Then
The list should be sorted by
"Last updated"
@javascript
Scenario
:
Sort merge requests by upvotes
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
project
"Shop"
have
"Bug NS-06"
open merge request
And
merge request
"Bug NS-04"
have 2 upvotes and 1 downvote
And
merge request
"Bug NS-06"
have 1 upvote and 2 downvotes
And
I sort the list by
"Popularity"
Then
The list should be sorted by
"Popularity"
@javascript
Scenario
:
I
comment on a merge request diff
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the Changes tab
And
I leave a comment like
"Line is wrong"
on diff
And
I switch to the merge request's comments tab
Then
I should see a discussion has started on diff
And
I should see a badge of
"1"
next to the discussion link
@javascript
Scenario
:
I
see a new comment on merge request diff from another user in the discussion tab
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
user
"John Doe"
leaves a comment like
"Line is wrong"
on diff
Then
I should see a discussion by user
"John Doe"
has started on diff
And
I should see a badge of
"1"
next to the discussion link
@javascript
Scenario
:
I
edit a comment on a merge request diff
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the Changes tab
And
I leave a comment like
"Line is wrong"
on diff
And
I change the comment
"Line is wrong"
to
"Typo, please fix"
on diff
Then
I should not see a diff comment saying
"Line is wrong"
And
I should see a diff comment saying
"Typo, please fix"
@javascript
Scenario
:
I
delete a comment on a merge request diff
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the Changes tab
And
I leave a comment like
"Line is wrong"
on diff
And
I should see a badge of
"1"
next to the discussion link
And
I delete the comment
"Line is wrong"
on diff
And
I click on the Discussion tab
Then
I should not see any discussion
And
I should see a badge of
"0"
next to the discussion link
@javascript
Scenario
:
I
comment on a line of a commit in merge request
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the commit in the merge request
And
I leave a comment like
"Line is wrong"
on diff in commit
And
I switch to the merge request's comments tab
Then
I should see a discussion has started on commit diff
@javascript
Scenario
:
I
comment on a commit in merge request
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the commit in the merge request
And
I leave a comment on the diff page in commit
And
I switch to the merge request's comments tab
Then
I should see a discussion has started on commit
@javascript
Scenario
:
I
accept merge request with custom commit message
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
merge request
"Bug NS-05"
is mergeable
And
I visit merge request page
"Bug NS-05"
And
merge request is mergeable
Then
I modify merge commit message
And
I accept this merge request
Then
I should see merged request
# Markdown
@javascript
Scenario
:
Headers inside the description should have ids generated for them.
When
I visit merge request page
"Bug NS-04"
Then
Header
"Description header"
should have correct id and link
@javascript
Scenario
:
Headers inside comments should not have ids generated for them.
Given
I visit merge request page
"Bug NS-04"
And
I leave a comment with a header containing
"Comment with a header"
Then
The comment with the header should not have an ID
# Toggling inline comments
@javascript
Scenario
:
I
hide comments on a merge request diff with comments in a single file
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the Changes tab
And
I leave a comment like
"Line is wrong"
on line 39 of the third file
And
I click link
"Hide inline discussion"
of the third file
Then
I should not see a comment like
"Line is wrong here"
in the third file
@javascript
Scenario
:
I
show comments on a merge request diff with comments in a single file
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the Changes tab
And
I leave a comment like
"Line is wrong"
on line 39 of the third file
Then
I should see a comment like
"Line is wrong"
in the third file
@javascript
Scenario
:
I
hide comments on a merge request diff with comments in multiple files
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the Changes tab
And
I leave a comment like
"Line is correct"
on line 12 of the second file
And
I leave a comment like
"Line is wrong"
on line 39 of the third file
And
I click link
"Hide inline discussion"
of the third file
Then
I should not see a comment like
"Line is wrong here"
in the third file
And
I should still see a comment like
"Line is correct"
in the second file
@javascript
Scenario
:
I
show comments on a merge request diff with comments in multiple files
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the Changes tab
And
I leave a comment like
"Line is correct"
on line 12 of the second file
And
I leave a comment like
"Line is wrong"
on line 39 of the third file
And
I click link
"Hide inline discussion"
of the third file
And
I click link
"Show inline discussion"
of the third file
Then
I should see a comment like
"Line is wrong"
in the third file
And
I should still see a comment like
"Line is correct"
in the second file
@javascript
Scenario
:
I
unfold diff
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the Changes tab
And
I unfold diff
Then
I should see additional file lines
@javascript
Scenario
:
I
unfold diff in Side-by-Side view
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the Changes tab
And
I click Side-by-side Diff tab
And
I unfold diff
Then
I should see additional file lines
@javascript
Scenario
:
I
show comments on a merge request side-by-side diff with comments in multiple files
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the Changes tab
And
I leave a comment like
"Line is correct"
on line 12 of the second file
And
I leave a comment like
"Line is wrong"
on line 39 of the third file
And
I click Side-by-side Diff tab
Then
I should see comments on the side-by-side diff page
@javascript
Scenario
:
I
view diffs on a merge request
Given
project
"Shop"
have
"Bug NS-05"
open merge request with diffs inside
And
I visit merge request page
"Bug NS-05"
And
I click on the Changes tab
Then
I should see the proper Inline and Side-by-side links
# Description preview
@javascript
Scenario
:
I
can't preview without text
Given
I visit merge request page
"Bug NS-04"
And
I click link
"Edit"
for the merge request
And
I haven't written any description text
Then
The Markdown preview tab should say there is nothing to do
@javascript
Scenario
:
I
can preview with text
Given
I visit merge request page
"Bug NS-04"
And
I click link
"Edit"
for the merge request
And I write a description like "
:
+1
:
Nice"
Then
The Markdown preview tab should display rendered Markdown
@javascript
Scenario
:
I
preview a merge request description
Given
I visit merge request page
"Bug NS-04"
And
I click link
"Edit"
for the merge request
And I preview a description text like "Bug fixed
:
smile
:
"
Then
I should see the Markdown preview
And
I should not see the Markdown text field
@javascript
Scenario
:
I
can edit after preview
Given
I visit merge request page
"Bug NS-04"
And
I click link
"Edit"
for the merge request
And I preview a description text like "Bug fixed
:
smile
:
"
Then
I should see the Markdown write tab
@javascript
Scenario
:
I
can unsubscribe from merge request
Given
I visit merge request page
"Bug NS-04"
Then
I should see that I am subscribed
When
I click button
"Unsubscribe"
Then
I should see that I am unsubscribed
@javascript
Scenario
:
I
can change the target branch
Given
I visit merge request page
"Bug NS-04"
And
I click link
"Edit"
for the merge request
When
I click the
"Target branch"
dropdown
And
I select a new target branch
Then
I should see new target branch changes
@javascript
Scenario
:
I
can close merge request after commenting
Given
I visit merge request page
"Bug NS-04"
And
I leave a comment like
"XML attached"
Then
I should see comment
"XML attached"
And
I click link
"Close"
Then
I should see closed merge request
"Bug NS-04"
features/steps/project/merge_requests.rb
deleted
100644 → 0
View file @
664cd27f
class
Spinach::Features::ProjectMergeRequests
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedIssuable
include
SharedProject
include
SharedNote
include
SharedPaths
include
SharedMarkdown
include
SharedDiffNote
include
SharedUser
include
WaitForRequests
after
do
wait_for_requests
if
javascript_test?
end
step
'I click link "New Merge Request"'
do
page
.
within
'.nav-controls'
do
page
.
has_link?
(
'New Merge Request'
)
?
click_link
(
"New Merge Request"
)
:
click_link
(
'New merge request'
)
end
end
step
'I click link "Bug NS-04"'
do
click_link
"Bug NS-04"
end
step
'I click link "Feature NS-05"'
do
click_link
"Feature NS-05"
end
step
'I click link "All"'
do
find
(
'.issues-state-filters [data-state="all"] span'
,
text:
'All'
).
click
# Waits for load
expect
(
find
(
'.issues-state-filters > .active'
)).
to
have_content
'All'
end
step
'I click link "Merged"'
do
find
(
'#state-merged'
).
trigger
(
'click'
)
end
step
'I click link "Closed"'
do
find
(
'.issues-state-filters [data-state="closed"] span'
,
text:
'Closed'
).
click
end
step
'I should see merge request "Wiki Feature"'
do
page
.
within
'.merge-request'
do
expect
(
page
).
to
have_content
"Wiki Feature"
end
wait_for_requests
end
step
'I should see closed merge request "Bug NS-04"'
do
expect
(
page
).
to
have_content
"Bug NS-04"
expect
(
page
).
to
have_content
"Closed by"
wait_for_requests
end
step
'I should see merge request "Bug NS-04"'
do
expect
(
page
).
to
have_content
"Bug NS-04"
wait_for_requests
end
step
'I should see merge request "Feature NS-05"'
do
expect
(
page
).
to
have_content
"Feature NS-05"
wait_for_requests
end
step
'I should not see "master" branch'
do
expect
(
find
(
'.issuable-info'
)).
not_to
have_content
"master"
end
step
'I should see "feature_conflict" branch'
do
expect
(
page
).
to
have_content
"feature_conflict"
end
step
'I should see "Bug NS-04" in merge requests'
do
expect
(
page
).
to
have_content
"Bug NS-04"
end
step
'I should see "Feature NS-03" in merge requests'
do
expect
(
page
).
to
have_content
"Feature NS-03"
end
step
'I should not see "Feature NS-03" in merge requests'
do
expect
(
page
).
not_to
have_content
"Feature NS-03"
end
step
'I should not see "Bug NS-04" in merge requests'
do
expect
(
page
).
not_to
have_content
"Bug NS-04"
end
step
'I should see that I am subscribed'
do
expect
(
find
(
'.issuable-subscribe-button span'
)).
to
have_content
'Unsubscribe'
end
step
'I should see that I am unsubscribed'
do
expect
(
find
(
'.issuable-subscribe-button span'
)).
to
have_content
'Subscribe'
end
step
'I click button "Unsubscribe"'
do
click_on
"Unsubscribe"
wait_for_requests
end
step
'I click link "Close"'
do
first
(
:css
,
'.close-mr-link'
).
click
end
step
'I submit new merge request "Wiki Feature"'
do
find
(
'.js-source-branch'
).
click
find
(
'.dropdown-source-branch .dropdown-content a'
,
text:
'fix'
).
click
find
(
'.js-target-branch'
).
click
first
(
'.dropdown-target-branch .dropdown-content a'
,
text:
'feature'
).
click
click_button
"Compare branches"
fill_in
"merge_request_title"
,
with:
"Wiki Feature"
click_button
"Submit merge request"
end
step
'project "Shop" have "Bug NS-04" open merge request'
do
create
(
:merge_request
,
title:
"Bug NS-04"
,
source_project:
project
,
target_project:
project
,
source_branch:
'fix'
,
target_branch:
'merge-test'
,
author:
project
.
users
.
first
,
description:
"# Description header"
)
end
step
'project "Shop" have "Bug NS-06" open merge request'
do
create
(
:merge_request
,
title:
"Bug NS-06"
,
source_project:
project
,
target_project:
project
,
source_branch:
'fix'
,
target_branch:
'feature_conflict'
,
author:
project
.
users
.
first
,
description:
"# Description header"
)
end
step
'project "Shop" have "Bug NS-05" open merge request with diffs inside'
do
create
(
:merge_request_with_diffs
,
title:
"Bug NS-05"
,
source_project:
project
,
target_project:
project
,
author:
project
.
users
.
first
,
source_branch:
'merge-test'
)
end
step
'project "Shop" have "Feature NS-05" merged merge request'
do
create
(
:merged_merge_request
,
title:
"Feature NS-05"
,
source_project:
project
,
target_project:
project
,
author:
project
.
users
.
first
)
end
step
'project "Shop" have "Bug NS-07" open merge request with rebased branch'
do
create
(
:merge_request
,
:rebased
,
title:
"Bug NS-07"
,
source_project:
project
,
target_project:
project
,
author:
project
.
users
.
first
)
end
step
'project "Shop" have "Bug NS-08" open merge request with diverged branch'
do
create
(
:merge_request
,
:diverged
,
title:
"Bug NS-08"
,
source_project:
project
,
target_project:
project
,
author:
project
.
users
.
first
)
end
step
'project "Shop" have "Feature NS-03" closed merge request'
do
create
(
:closed_merge_request
,
title:
"Feature NS-03"
,
source_project:
project
,
target_project:
project
,
author:
project
.
users
.
first
)
end
step
'project "Community" has "Bug CO-01" open merge request with diffs inside'
do
project
=
Project
.
find_by
(
name:
"Community"
)
create
(
:merge_request_with_diffs
,
title:
"Bug CO-01"
,
source_project:
project
,
target_project:
project
,
author:
project
.
users
.
first
)
end
step
'merge request "Bug NS-04" have 2 upvotes and 1 downvote'
do
merge_request
=
MergeRequest
.
find_by
(
title:
'Bug NS-04'
)
create_list
(
:award_emoji
,
2
,
awardable:
merge_request
)
create
(
:award_emoji
,
:downvote
,
awardable:
merge_request
)
end
step
'merge request "Bug NS-06" have 1 upvote and 2 downvotes'
do
awardable
=
MergeRequest
.
find_by
(
title:
'Bug NS-06'
)
create
(
:award_emoji
,
awardable:
awardable
)
create_list
(
:award_emoji
,
2
,
:downvote
,
awardable:
awardable
)
end
step
'The list should be sorted by "Least popular"'
do
page
.
within
'.mr-list'
do
page
.
within
'li.merge-request:nth-child(1)'
do
expect
(
page
).
to
have_content
'Bug NS-06'
expect
(
page
).
to
have_content
'1 2'
end
page
.
within
'li.merge-request:nth-child(2)'
do
expect
(
page
).
to
have_content
'Bug NS-04'
expect
(
page
).
to
have_content
'2 1'
end
page
.
within
'li.merge-request:nth-child(3)'
do
expect
(
page
).
to
have_content
'Bug NS-05'
expect
(
page
).
not_to
have_content
'0 0'
end
end
end
step
'The list should be sorted by "Popularity"'
do
page
.
within
'.mr-list'
do
page
.
within
'li.merge-request:nth-child(1)'
do
expect
(
page
).
to
have_content
'Bug NS-04'
expect
(
page
).
to
have_content
'2 1'
end
page
.
within
'li.merge-request:nth-child(2)'
do
expect
(
page
).
to
have_content
'Bug NS-06'
expect
(
page
).
to
have_content
'1 2'
end
page
.
within
'li.merge-request:nth-child(3)'
do
expect
(
page
).
to
have_content
'Bug NS-05'
expect
(
page
).
not_to
have_content
'0 0'
end
end
end
step
'I click on the Changes tab'
do
page
.
within
'.merge-request-tabs'
do
click_link
'Changes'
end
# Waits for load
expect
(
page
).
to
have_css
(
'.tab-content #diffs.active'
)
end
step
'I should see the proper Inline and Side-by-side links'
do
expect
(
page
).
to
have_css
(
'#parallel-diff-btn'
,
count:
1
)
expect
(
page
).
to
have_css
(
'#inline-diff-btn'
,
count:
1
)
end
step
'I switch to the merge request\'s comments tab'
do
visit
project_merge_request_path
(
project
,
merge_request
)
end
step
'I click on the commit in the merge request'
do
page
.
within
'.merge-request-tabs'
do
click_link
'Commits'
end
page
.
within
'.commits'
do
click_link
Commit
.
truncate_sha
(
sample_commit
.
id
)
end
end
step
'I leave a comment on the diff page'
do
init_diff_note
leave_comment
"One comment to rule them all"
end
step
'I leave a comment on the diff page in commit'
do
click_diff_line
(
sample_commit
.
line_code
)
leave_comment
"One comment to rule them all"
end
step
'I leave a comment like "Line is wrong" on diff'
do
init_diff_note
leave_comment
"Line is wrong"
end
step
'user "John Doe" leaves a comment like "Line is wrong" on diff'
do
mr
=
MergeRequest
.
find_by
(
title:
"Bug NS-05"
)
create
(
:diff_note_on_merge_request
,
project:
project
,
noteable:
mr
,
author:
user_exists
(
"John Doe"
),
note:
'Line is wrong'
)
end
step
'I leave a comment like "Line is wrong" on diff in commit'
do
click_diff_line
(
sample_commit
.
line_code
)
leave_comment
"Line is wrong"
end
step
'I change the comment "Line is wrong" to "Typo, please fix" on diff'
do
page
.
within
(
'.diff-file:nth-of-type(5) .note'
)
do
find
(
'.js-note-edit'
).
click
page
.
within
(
'.current-note-edit-form'
,
visible:
true
)
do
fill_in
'note_note'
,
with:
'Typo, please fix'
click_button
'Save comment'
end
expect
(
page
).
not_to
have_button
'Save comment'
,
disabled:
true
,
visible:
true
end
end
step
'I should not see a diff comment saying "Line is wrong"'
do
page
.
within
(
'.diff-file:nth-of-type(5) .note'
)
do
expect
(
page
).
not_to
have_visible_content
'Line is wrong'
end
end
step
'I should see a diff comment saying "Typo, please fix"'
do
page
.
within
(
'.diff-file:nth-of-type(5) .note'
)
do
expect
(
page
).
to
have_visible_content
'Typo, please fix'
end
end
step
'I delete the comment "Line is wrong" on diff'
do
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
end
step
'I click on the Discussion tab'
do
page
.
within
'.merge-request-tabs'
do
find
(
'.notes-tab'
).
trigger
(
'click'
)
end
# Waits for load
expect
(
page
).
to
have_css
(
'.tab-content #notes.active'
)
end
step
'I should not see any discussion'
do
expect
(
page
).
not_to
have_css
(
'.notes .discussion'
)
end
step
'I should see a discussion has started on diff'
do
page
.
within
(
".notes .discussion"
)
do
page
.
should
have_content
"
#{
current_user
.
name
}
#{
current_user
.
to_reference
}
started a discussion"
page
.
should
have_content
sample_commit
.
line_code_path
page
.
should
have_content
"Line is wrong"
end
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_requests
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
page
.
should
have_content
"Line is wrong"
end
end
step
'I should see a badge of "1" next to the discussion link'
do
expect_discussion_badge_to_have_counter
(
"1"
)
wait_for_requests
end
step
'I should see a badge of "0" next to the discussion link'
do
expect_discussion_badge_to_have_counter
(
"0"
)
wait_for_requests
end
step
'I should see a discussion has started on commit diff'
do
page
.
within
(
".notes .discussion"
)
do
page
.
should
have_content
"
#{
current_user
.
name
}
#{
current_user
.
to_reference
}
started a discussion on commit"
page
.
should
have_content
sample_commit
.
line_code_path
page
.
should
have_content
"Line is wrong"
wait_for_requests
end
end
step
'I should see a discussion has started on commit'
do
page
.
within
(
".notes .discussion"
)
do
page
.
should
have_content
"
#{
current_user
.
name
}
#{
current_user
.
to_reference
}
started a discussion on commit"
page
.
should
have_content
"One comment to rule them all"
wait_for_requests
end
end
step
'merge request is mergeable'
do
expect
(
page
).
to
have_button
'Merge'
end
step
'I modify merge commit message'
do
click_button
"Modify commit message"
fill_in
'Commit message'
,
with:
'wow such merge'
end
step
'merge request "Bug NS-05" is mergeable'
do
merge_request
.
mark_as_mergeable
end
step
'I accept this merge request'
do
page
.
within
'.mr-state-widget'
do
click_button
"Merge"
end
end
step
'I should see merged request'
do
page
.
within
'.status-box'
do
expect
(
page
).
to
have_content
"Merged"
wait_for_requests
end
end
step
'I click link "Reopen"'
do
first
(
:css
,
'.reopen-mr-link'
).
trigger
(
'click'
)
end
step
'I should see reopened merge request "Bug NS-04"'
do
page
.
within
'.status-box'
do
expect
(
page
).
to
have_content
"Open"
end
wait_for_requests
end
step
'I click link "Hide inline discussion" of the third file'
do
page
.
within
'.files>div:nth-child(3)'
do
find
(
'.js-toggle-diff-comments'
).
trigger
(
'click'
)
end
end
step
'I click link "Show inline discussion" of the third file'
do
page
.
within
'.files>div:nth-child(3)'
do
find
(
'.js-toggle-diff-comments'
).
trigger
(
'click'
)
end
end
step
'I should not see a comment like "Line is wrong" in the third file'
do
page
.
within
'.files>div:nth-child(3)'
do
expect
(
page
).
not_to
have_visible_content
"Line is wrong"
end
end
step
'I should see a comment like "Line is wrong" in the third file'
do
page
.
within
'.files>div:nth-child(3) .note-body > .note-text'
do
expect
(
page
).
to
have_visible_content
"Line is wrong"
wait_for_requests
end
end
step
'I should not see a comment like "Line is wrong here" in the third file'
do
page
.
within
'.files>div:nth-child(3)'
do
expect
(
page
).
not_to
have_visible_content
"Line is wrong here"
end
end
step
'I should see a comment like "Line is wrong here" in the third file'
do
page
.
within
'.files>div:nth-child(3) .note-body > .note-text'
do
expect
(
page
).
to
have_visible_content
"Line is wrong here"
end
end
step
'I leave a comment like "Line is correct" on line 12 of the second file'
do
init_diff_note_first_file
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
end
step
'I leave a comment like "Line is wrong" on line 39 of the third file'
do
init_diff_note_second_file
page
.
within
(
".js-discussion-note-form"
)
do
fill_in
"note_note"
,
with:
"Line is wrong on here"
click_button
"Comment"
end
wait_for_requests
end
step
'I should still see a comment like "Line is correct" in the second file'
do
page
.
within
'.files>div:nth-child(2) .note-body > .note-text'
do
expect
(
page
).
to
have_visible_content
"Line is correct"
end
end
step
'I unfold diff'
do
expect
(
page
).
to
have_css
(
'.js-unfold'
)
first
(
'.js-unfold'
).
click
end
step
'I should see additional file lines'
do
expect
(
first
(
'.text-file'
)).
to
have_content
(
'.bundle'
)
end
step
'I click Side-by-side Diff tab'
do
find
(
'a'
,
text:
'Side-by-side'
).
trigger
(
'click'
)
# Waits for load
expect
(
page
).
to
have_css
(
'.parallel'
)
end
step
'I should see comments on the side-by-side diff page'
do
page
.
within
'.files>div:nth-child(2) .parallel .note-body > .note-text'
do
expect
(
page
).
to
have_visible_content
"Line is correct"
wait_for_requests
end
end
step
'I fill in merge request search with "Fe"'
do
fill_in
'issuable_search'
,
with:
"Fe"
page
.
within
'.merge-requests-holder'
do
find
(
'.merge-request'
)
end
end
step
'I click the "Target branch" dropdown'
do
expect
(
page
).
to
have_content
(
'Target branch'
)
first
(
'.target_branch'
).
click
end
step
'I select a new target branch'
do
select
"feature"
,
from:
"merge_request_target_branch"
click_button
'Save'
end
step
'I should see new target branch changes'
do
expect
(
page
).
to
have_content
'Request to merge fix into feature'
expect
(
page
).
to
have_content
'changed target branch from merge-test to feature'
wait_for_requests
end
step
'I click on "Email Patches"'
do
click_link
"Email Patches"
end
step
'I click on "Plain Diff"'
do
click_link
"Plain Diff"
end
step
'I should see a patch diff'
do
expect
(
page
).
to
have_content
(
'diff --git'
)
end
step
'"Bug NS-05" has CI status'
do
project
=
merge_request
.
source_project
project
.
enable_ci
pipeline
=
create
(
:ci_pipeline
,
project:
project
,
sha:
merge_request
.
diff_head_sha
,
ref:
merge_request
.
source_branch
,
head_pipeline_of:
merge_request
)
create
:ci_build
,
pipeline:
pipeline
end
step
'I should see merge request "Bug NS-05" with CI status'
do
page
.
within
".mr-list"
do
expect
(
page
).
to
have_link
"Pipeline: pending"
end
end
step
'I should see the diverged commits count'
do
page
.
within
".mr-source-target"
do
expect
(
page
).
to
have_content
/([0-9]+ commits behind)/
end
wait_for_requests
end
step
'I should not see the diverged commits count'
do
page
.
within
".mr-source-target"
do
expect
(
page
).
not_to
have_content
/([0-9]+ commit[s]? behind)/
end
wait_for_requests
end
def
merge_request
@merge_request
||=
MergeRequest
.
find_by!
(
title:
"Bug NS-05"
)
end
def
init_diff_note
click_diff_line
(
sample_commit
.
line_code
)
end
def
leave_comment
(
message
)
page
.
within
(
".js-discussion-note-form"
,
visible:
true
)
do
fill_in
"note_note"
,
with:
message
click_button
"Comment"
end
wait_for_requests
page
.
within
(
".notes_holder"
,
visible:
true
)
do
expect
(
page
).
to
have_content
message
end
end
def
init_diff_note_first_file
click_diff_line
(
sample_compare
.
changes
[
0
][
:line_code
])
end
def
init_diff_note_second_file
click_diff_line
(
sample_compare
.
changes
[
1
][
:line_code
])
end
def
have_visible_content
(
text
)
have_css
(
"*"
,
text:
text
,
visible:
true
)
end
def
expect_discussion_badge_to_have_counter
(
value
)
page
.
within
(
".notes-tab .badge"
)
do
page
.
should
have_content
value
end
end
end
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