Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-26 21:10:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-26 21:10:35 +0300
commita56971e97f0385640c2f3568017bd221897b78ef (patch)
treea22308ba6707f73199e3c80523e88b6363044ca4 /spec/models
parentd3fafe0995cb26212095568f95de6692ec629157 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/bridge_spec.rb8
-rw-r--r--spec/models/note_spec.rb48
2 files changed, 43 insertions, 13 deletions
diff --git a/spec/models/ci/bridge_spec.rb b/spec/models/ci/bridge_spec.rb
index db956b26b6b..6dd3c40f228 100644
--- a/spec/models/ci/bridge_spec.rb
+++ b/spec/models/ci/bridge_spec.rb
@@ -74,18 +74,18 @@ RSpec.describe Ci::Bridge do
it "schedules downstream pipeline creation when the status is #{status}" do
bridge.status = status
- expect(bridge).to receive(:schedule_downstream_pipeline!)
-
bridge.enqueue!
+
+ expect(::Ci::CreateCrossProjectPipelineWorker.jobs.last['args']).to eq([bridge.id])
end
end
it "schedules downstream pipeline creation when the status is waiting for resource" do
bridge.status = :waiting_for_resource
- expect(bridge).to receive(:schedule_downstream_pipeline!)
-
bridge.enqueue_waiting_for_resource!
+
+ expect(::Ci::CreateCrossProjectPipelineWorker.jobs.last['args']).to eq([bridge.id])
end
it 'raises error when the status is failed' do
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 0afdae2fc93..e26355b1eb4 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -500,15 +500,15 @@ RSpec.describe Note do
let_it_be(:ext_issue) { create(:issue, project: ext_proj) }
shared_examples "checks references" do
- it "returns true" do
+ it "returns false" do
expect(note.system_note_with_references_visible_for?(ext_issue.author)).to be_falsy
end
- it "returns false" do
+ it "returns true" do
expect(note.system_note_with_references_visible_for?(private_user)).to be_truthy
end
- it "returns false if user visible reference count set" do
+ it "returns true if user visible reference count set" do
note.user_visible_reference_count = 1
note.total_reference_count = 1
@@ -516,7 +516,15 @@ RSpec.describe Note do
expect(note.system_note_with_references_visible_for?(ext_issue.author)).to be_truthy
end
- it "returns true if ref count is 0" do
+ it "returns false if user visible reference count set but does not match total reference count" do
+ note.user_visible_reference_count = 1
+ note.total_reference_count = 2
+
+ expect(note).not_to receive(:reference_mentionables)
+ expect(note.system_note_with_references_visible_for?(ext_issue.author)).to be_falsy
+ end
+
+ it "returns false if ref count is 0" do
note.user_visible_reference_count = 0
expect(note).not_to receive(:reference_mentionables)
@@ -562,13 +570,35 @@ RSpec.describe Note do
end
it_behaves_like "checks references"
+ end
- it "returns true if user visible reference count set and there is a private reference" do
- note.user_visible_reference_count = 1
- note.total_reference_count = 2
+ context "when there is a private issue and user reference" do
+ let_it_be(:ext_issue2) { create(:issue, project: ext_proj) }
- expect(note).not_to receive(:reference_mentionables)
- expect(note.system_note_with_references_visible_for?(ext_issue.author)).to be_falsy
+ let(:note) do
+ create :note,
+ noteable: ext_issue2, project: ext_proj,
+ note: "mentioned in #{private_issue.to_reference(ext_proj)} and pinged user #{private_user.to_reference}",
+ system: true
+ end
+
+ it_behaves_like "checks references"
+ end
+
+ context "when there is a publicly visible user reference" do
+ let(:note) do
+ create :note,
+ noteable: ext_issue, project: ext_proj,
+ note: "mentioned in #{ext_proj.owner.to_reference}",
+ system: true
+ end
+
+ it "returns true for other users" do
+ expect(note.system_note_with_references_visible_for?(ext_issue.author)).to be_truthy
+ end
+
+ it "returns true for anonymous users" do
+ expect(note.system_note_with_references_visible_for?(nil)).to be_truthy
end
end
end