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:
Diffstat (limited to 'spec/models/note_spec.rb')
-rw-r--r--spec/models/note_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index e99d77dc0a0..0fc689b9f6c 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -795,6 +795,24 @@ RSpec.describe Note, feature_category: :team_planning do
expect(note.system_note_visible_for?(nil)).to be_truthy
end
end
+
+ context 'when referenced resource is not present' do
+ let(:note) do
+ create :note, noteable: ext_issue, project: ext_proj, note: "mentioned in merge request !1", system: true
+ end
+
+ it "returns true for other users" do
+ expect(note.system_note_visible_for?(private_user)).to be_truthy
+ end
+
+ it "returns true if user visible reference count set" do
+ note.user_visible_reference_count = 0
+ note.total_reference_count = 0
+
+ expect(note).not_to receive(:reference_mentionables)
+ expect(note.system_note_visible_for?(ext_issue.author)).to be_truthy
+ end
+ end
end
describe '#system_note_with_references?' do
@@ -1588,6 +1606,24 @@ RSpec.describe Note, feature_category: :team_planning do
.with("/#{noteable.project.namespace.to_param}/#{noteable.project.to_param}/noteable/#{noteable.class.name.underscore}/#{noteable.id}/notes")
end
+ it 'broadcasts an Action Cable event for the noteable' do
+ expect(Noteable::NotesChannel).to receive(:broadcast_to).with(note.noteable, event: 'updated')
+
+ note.save!
+ end
+
+ context 'when action_cable_notes is disabled' do
+ before do
+ stub_feature_flags(action_cable_notes: false)
+ end
+
+ it 'does not broadcast an Action Cable event' do
+ expect(Noteable::NotesChannel).not_to receive(:broadcast_to)
+
+ note.save!
+ end
+ end
+
it "expires cache for note's issue when note is saved" do
expect_expiration(note.noteable)