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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

148 lines
4.8 KiB
Ruby
Raw Permalink 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
2023-03-04 22:38:38 +05:30
RSpec.describe "Internal references", :js, feature_category: :team_planning do
2023-06-20 00:43:36 +05:30
include Features::NotesHelpers
2018-11-08 19:23:39 +05:30
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))
2023-01-13 00:05:48 +05:30
wait_for_requests
2018-11-08 19:23:39 +05:30
add_note("##{public_project_issue.to_reference(private_project)}")
end
2023-01-13 00:05:48 +05:30
context "when user doesn't have access to private project" 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))
2023-01-13 00:05:48 +05:30
wait_for_requests
2018-11-08 19:23:39 +05:30
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))
2023-01-13 00:05:48 +05:30
wait_for_requests
2018-11-08 19:23:39 +05:30
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))
2023-01-13 00:05:48 +05:30
wait_for_requests
2018-11-08 19:23:39 +05:30
end
2023-01-13 00:05:48 +05:30
it "doesn't show any references" 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))
2023-01-13 00:05:48 +05:30
wait_for_requests
2018-11-08 19:23:39 +05:30
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))
2023-01-13 00:05:48 +05:30
wait_for_requests
2018-11-08 19:23:39 +05:30
add_note("##{public_project_merge_request.to_reference(private_project)}")
end
2023-01-13 00:05:48 +05:30
context "when user doesn't have access to private project" 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))
2023-01-13 00:05:48 +05:30
wait_for_requests
2018-11-08 19:23:39 +05:30
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))
2023-01-13 00:05:48 +05:30
wait_for_requests
2018-11-08 19:23:39 +05:30
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))
2023-01-13 00:05:48 +05:30
wait_for_requests
2018-11-08 19:23:39 +05:30
end
2023-01-13 00:05:48 +05:30
it "doesn't show any references" 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))
2023-01-13 00:05:48 +05:30
wait_for_requests
2018-11-08 19:23:39 +05:30
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