2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
require 'spec_helper'
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe "Internal references", :js do
|
2018-11-08 19:23:39 +05:30
|
|
|
include Spec::Support::Helpers::Features::NotesHelpers
|
|
|
|
|
|
|
|
let(:private_project_user) { private_project.owner }
|
|
|
|
let(:private_project) { create(:project, :private, :repository) }
|
|
|
|
let(:private_project_issue) { create(:issue, project: private_project) }
|
|
|
|
let(:private_project_merge_request) { create(:merge_request, source_project: private_project) }
|
|
|
|
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
|
|
|
|
context "from issue" do
|
|
|
|
before do
|
|
|
|
sign_in(private_project_user)
|
|
|
|
|
|
|
|
visit(project_issue_path(private_project, private_project_issue))
|
|
|
|
|
|
|
|
add_note("##{public_project_issue.to_reference(private_project)}")
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
context "when user doesn't have access to private project", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/257832' do
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
|
|
|
sign_in(public_project_user)
|
|
|
|
|
|
|
|
visit(project_issue_path(public_project, public_project_issue))
|
|
|
|
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_issue.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_issue_path(public_project, public_project_issue))
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it "doesn't show any references", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/257832' do
|
2018-11-08 19:23:39 +05:30
|
|
|
page.within(".issue-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_issue_path(public_project, public_project_issue))
|
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it "shows references", :sidekiq_might_not_need_inline do
|
2018-11-08 19:23:39 +05:30
|
|
|
page.within("#merge-requests .merge-requests-title") do
|
2019-03-02 22:35:43 +05:30
|
|
|
expect(page).to have_content("Related merge requests")
|
|
|
|
expect(page).to have_css(".mr-count-badge")
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
page.within("#merge-requests ul") do
|
|
|
|
expect(page).to have_content(private_project_merge_request.title)
|
2019-07-07 11:18:12 +05:30
|
|
|
expect(page).to have_css(".ic-issue-open-m")
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
context "when user doesn't have access to private project", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/257832' do
|
2018-11-08 19:23:39 +05:30
|
|
|
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
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it "doesn't show any references", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/257832' do
|
2018-11-08 19:23:39 +05:30
|
|
|
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
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it "shows references", :sidekiq_might_not_need_inline do
|
2018-11-08 19:23:39 +05:30
|
|
|
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
|