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.rb42
1 files changed, 35 insertions, 7 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index c1de8125c0d..bcfcfa05ddf 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Note do
+RSpec.describe Note, feature_category: :team_planning do
include RepoHelpers
describe 'associations' do
@@ -799,20 +799,22 @@ RSpec.describe Note do
describe '#system_note_with_references?' do
it 'falsey for user-generated notes' do
- note = create(:note, system: false)
+ note = build_stubbed(:note, system: false)
expect(note.system_note_with_references?).to be_falsy
end
context 'when the note might contain cross references' do
SystemNoteMetadata.new.cross_reference_types.each do |type|
- let(:note) { create(:note, :system) }
- let!(:metadata) { create(:system_note_metadata, note: note, action: type) }
+ context "with #{type}" do
+ let(:note) { build_stubbed(:note, :system) }
+ let!(:metadata) { build_stubbed(:system_note_metadata, note: note, action: type) }
- it 'delegates to the cross-reference regex' do
- expect(note).to receive(:matches_cross_reference_regex?).and_return(false)
+ it 'delegates to the cross-reference regex' do
+ expect(note).to receive(:matches_cross_reference_regex?).and_return(false)
- note.system_note_with_references?
+ note.system_note_with_references?
+ end
end
end
end
@@ -1666,6 +1668,32 @@ RSpec.describe Note do
end
end
end
+
+ describe '.without_hidden' do
+ subject { described_class.without_hidden }
+
+ context 'when a note with a banned author exists' do
+ let_it_be(:banned_user) { create(:banned_user).user }
+ let_it_be(:banned_note) { create(:note, author: banned_user) }
+
+ context 'when the :hidden_notes feature is disabled' do
+ before do
+ stub_feature_flags(hidden_notes: false)
+ end
+
+ it { is_expected.to include(banned_note, note1) }
+ end
+
+ context 'when the :hidden_notes feature is enabled' do
+ before do
+ stub_feature_flags(hidden_notes: true)
+ end
+
+ it { is_expected.not_to include(banned_note) }
+ it { is_expected.to include(note1) }
+ end
+ end
+ end
end
describe 'banzai_render_context' do