Commit f4e234d9 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'blackst0ne-replace-spinach-project-merge-requests-references.feature' into 'master'

Replace the `project/merge_requests/references.feature` spinach test with an rspec analog

See merge request gitlab-org/gitlab-ce!18794
parents 9532ca43 5373a5b1
---
title: 'Replace the `project/merge_requests/references.feature` spinach test with an rspec analog'
merge_request: 18794
author: '@blackst0ne'
type: other
@project_merge_requests
Feature: Project Merge Requests References
Background:
Given I sign in as "John Doe"
And public project "Community"
And "John Doe" owns public project "Community"
And project "Community" has "Community fix" open merge request
And I logout
And I sign in as "Mary Jane"
And private project "Enterprise"
And "Mary Jane" owns private project "Enterprise"
And project "Enterprise" has "Enterprise issue" open issue
And project "Enterprise" has "Enterprise fix" open merge request
And I visit issue page "Enterprise issue"
And I leave a comment referencing issue "Community fix"
And I visit merge request page "Enterprise fix"
And I leave a comment referencing issue "Community fix"
And I logout
@javascript
Scenario: Viewing the public issue as a "John Doe"
Given I sign in as "John Doe"
When I visit issue page "Community fix"
Then I should see no notes at all
@javascript
Scenario: Viewing the public issue as "Mary Jane"
Given I sign in as "Mary Jane"
When I visit issue page "Community fix"
And I should see a note linking to "Enterprise fix" merge request
And I should see a note linking to "Enterprise issue" issue
......@@ -22,22 +22,10 @@ module SharedAuthentication
sign_in(@user)
end
step 'I sign in as "John Doe"' do
gitlab_sign_in(user_exists("John Doe"))
end
step 'I sign in as "Mary Jane"' do
gitlab_sign_in(user_exists("Mary Jane"))
end
step 'I should be redirected to sign in page' do
expect(current_path).to eq new_user_session_path
end
step "I logout" do
gitlab_sign_out
end
step "I logout directly" do
gitlab_sign_out
end
......
......@@ -5,29 +5,6 @@ module SharedIssuable
find('.js-issuable-edit', visible: true).click
end
step 'project "Community" has "Community fix" open merge request' do
create_issuable_for_project(
project_name: 'Community',
type: :merge_request,
title: 'Community fix'
)
end
step 'project "Enterprise" has "Enterprise issue" open issue' do
create_issuable_for_project(
project_name: 'Enterprise',
title: 'Enterprise issue'
)
end
step 'project "Enterprise" has "Enterprise fix" open merge request' do
create_issuable_for_project(
project_name: 'Enterprise',
type: :merge_request,
title: 'Enterprise fix'
)
end
step 'I leave a comment referencing issue "Community issue"' do
leave_reference_comment(
issuable: Issue.find_by(title: 'Community issue'),
......@@ -35,44 +12,6 @@ module SharedIssuable
)
end
step 'I leave a comment referencing issue "Community fix"' do
leave_reference_comment(
issuable: MergeRequest.find_by(title: 'Community fix'),
from_project_name: 'Enterprise'
)
end
step 'I visit issue page "Enterprise issue"' do
issue = Issue.find_by(title: 'Enterprise issue')
visit project_issue_path(issue.project, issue)
end
step 'I visit merge request page "Enterprise fix"' do
mr = MergeRequest.find_by(title: 'Enterprise fix')
visit project_merge_request_path(mr.target_project, mr)
end
step 'I visit issue page "Community fix"' do
mr = MergeRequest.find_by(title: 'Community fix')
visit project_merge_request_path(mr.target_project, mr)
end
step 'I should see a note linking to "Enterprise fix" merge request' do
visible_note(
issuable: MergeRequest.find_by(title: 'Enterprise fix'),
from_project_name: 'Community',
user_name: 'Mary Jane'
)
end
step 'I should see a note linking to "Enterprise issue" issue' do
visible_note(
issuable: Issue.find_by(title: 'Enterprise issue'),
from_project_name: 'Community',
user_name: 'Mary Jane'
)
end
step 'I click link "Edit" for the merge request' do
edit_issuable
end
......
......@@ -18,8 +18,4 @@ module SharedNote
expect(find('.js-md-preview')).to have_content('Nothing to preview.')
end
end
step 'I should see no notes at all' do
expect(page).not_to have_css('.note')
end
end
......@@ -42,10 +42,6 @@ module SharedProject
# Visibility level
# ----------------------------------------
step 'private project "Enterprise"' do
create(:project, :private, :repository, name: 'Enterprise')
end
step 'I should see project "Enterprise"' do
expect(page).to have_content "Enterprise"
end
......@@ -70,10 +66,6 @@ module SharedProject
end
end
step 'public project "Community"' do
create(:project, :public, :repository, name: 'Community')
end
step 'I should see project "Community"' do
expect(page).to have_content "Community"
end
......@@ -89,13 +81,6 @@ module SharedProject
)
end
step '"Mary Jane" owns private project "Enterprise"' do
user_owns_project(
user_name: 'Mary Jane',
project_name: 'Enterprise'
)
end
step '"John Doe" owns internal project "Internal"' do
user_owns_project(
user_name: 'John Doe',
......@@ -104,14 +89,6 @@ module SharedProject
)
end
step '"John Doe" owns public project "Community"' do
user_owns_project(
user_name: 'John Doe',
project_name: 'Community',
visibility: :public
)
end
step 'public empty project "Empty Public Project"' do
create :project_empty_repo, :public, name: "Empty Public Project"
end
......
......@@ -10,6 +10,7 @@ describe "Internal references", :js do
let(:public_project_user) { public_project.owner }
let(:public_project) { create(:project, :public, :repository) }
let(:public_project_issue) { create(:issue, project: public_project) }
let(:public_project_merge_request) { create(:merge_request, source_project: public_project) }
context "when referencing to open issue" do
context "from private project" do
......@@ -77,4 +78,63 @@ describe "Internal references", :js do
end
end
end
context "when referencing to open merge request" do
context "from private project" do
context "from issue" do
before do
sign_in(private_project_user)
visit(project_issue_path(private_project, private_project_issue))
add_note("##{public_project_merge_request.to_reference(private_project)}")
end
context "when user doesn't have access to private project" do
before do
sign_in(public_project_user)
visit(project_merge_request_path(public_project, public_project_merge_request))
end
it { expect(page).not_to have_css(".note") }
end
end
context "from merge request" do
before do
sign_in(private_project_user)
visit(project_merge_request_path(private_project, private_project_merge_request))
add_note("##{public_project_merge_request.to_reference(private_project)}")
end
context "when user doesn't have access to private project" do
before do
sign_in(public_project_user)
visit(project_merge_request_path(public_project, public_project_merge_request))
end
it "doesn't show any references" do
page.within(".merge-request-details") do
expect(page).not_to have_content("#merge-requests .merge-requests-title")
end
end
end
context "when user has access to private project" do
before do
visit(project_merge_request_path(public_project, public_project_merge_request))
end
it "shows references" do
expect(page).to have_content("mentioned in merge request #{private_project_merge_request.to_reference(public_project)}")
.and have_content(private_project_user.name)
end
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment