debian-mirror-gitlab/spec/features/issuables/markdown_references/internal_references_spec.rb

138 lines
4.8 KiB
Ruby
Raw Normal View History

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
2022-04-04 11:22:00 +05:30
let(:private_project_user) { private_project.first_owner }
2018-11-08 19:23:39 +05:30
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) }
2022-04-04 11:22:00 +05:30
let(:public_project_user) { public_project.first_owner }
2018-11-08 19:23:39 +05:30
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
2021-12-11 22:18:48 +05:30
expect(page).not_to have_text 'Related merge requests'
2018-11-08 19:23:39 +05:30
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
2021-12-11 22:18:48 +05:30
expect(page).to have_text 'Related merge requests 1'
2018-11-08 19:23:39 +05:30
2021-12-11 22:18:48 +05:30
page.within('.related-items-list') do
2018-11-08 19:23:39 +05:30
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
2021-12-11 22:18:48 +05:30
expect(page).not_to have_text 'Related merge requests'
2018-11-08 19:23:39 +05:30
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