Rename Redactor classes to ReferenceRedactor

This commit is contained in:
Sarah Yasonik 2019-07-16 20:19:08 +00:00 committed by Douglas Barbosa Alexandre
parent b8d876f132
commit cea7ba513c
9 changed files with 13 additions and 13 deletions

View file

@ -53,7 +53,7 @@ def instrument_classes(instrumentation)
instrumentation.instrument_methods(Banzai::Querying)
instrumentation.instrument_instance_methods(Banzai::ObjectRenderer)
instrumentation.instrument_instance_methods(Banzai::Redactor)
instrumentation.instrument_instance_methods(Banzai::ReferenceRedactor)
[Issuable, Mentionable, Participable].each do |klass|
instrumentation.instrument_instance_methods(klass)

View file

@ -7,12 +7,12 @@ module Banzai
#
# Expected to be run in its own post-processing pipeline.
#
class RedactorFilter < HTML::Pipeline::Filter
class ReferenceRedactorFilter < HTML::Pipeline::Filter
def call
unless context[:skip_redaction]
context = RenderContext.new(project, current_user)
Redactor.new(context).redact([doc])
ReferenceRedactor.new(context).redact([doc])
end
doc

View file

@ -72,7 +72,7 @@ module Banzai
#
# Returns an Array containing the redacted documents.
def redact_documents(documents)
redactor = Redactor.new(context)
redactor = ReferenceRedactor.new(context)
redactor.redact(documents)
end

View file

@ -12,7 +12,7 @@ module Banzai
def self.internal_link_filters
[
Filter::RedactorFilter,
Filter::ReferenceRedactorFilter,
Filter::InlineMetricsRedactorFilter,
Filter::RelativeLinkFilter,
Filter::IssuableStateFilter,

View file

@ -3,7 +3,7 @@
module Banzai
# Class for removing Markdown references a certain user is not allowed to
# view.
class Redactor
class ReferenceRedactor
attr_reader :context
# context - An instance of `Banzai::RenderContext`.

View file

@ -134,7 +134,7 @@ module Banzai
#
# This method is used to perform state-dependent changes to a String of
# HTML, such as removing references that the current user doesn't have
# permission to make (`RedactorFilter`).
# permission to make (`ReferenceRedactorFilter`).
#
# html - String to process
# context - Hash of options to customize output

View file

@ -1,6 +1,6 @@
require 'spec_helper'
describe Banzai::Filter::RedactorFilter do
describe Banzai::Filter::ReferenceRedactorFilter do
include ActionView::Helpers::UrlHelper
include FilterSpecHelper

View file

@ -22,8 +22,8 @@ describe Banzai::ObjectRenderer do
expect(object.user_visible_reference_count).to eq 0
end
it 'calls Banzai::Redactor to perform redaction' do
expect_any_instance_of(Banzai::Redactor).to receive(:redact).and_call_original
it 'calls Banzai::ReferenceRedactor to perform redaction' do
expect_any_instance_of(Banzai::ReferenceRedactor).to receive(:redact).and_call_original
renderer.render([object], :note)
end
@ -82,8 +82,8 @@ describe Banzai::ObjectRenderer do
expect(cacheless_thing.redacted_title_html).to eq("Merge branch 'branch-merged' into 'master'")
end
it 'calls Banzai::Redactor to perform redaction' do
expect_any_instance_of(Banzai::Redactor).to receive(:redact).and_call_original
it 'calls Banzai::ReferenceRedactor to perform redaction' do
expect_any_instance_of(Banzai::ReferenceRedactor).to receive(:redact).and_call_original
renderer.render([cacheless_thing], :title)
end

View file

@ -1,6 +1,6 @@
require 'spec_helper'
describe Banzai::Redactor do
describe Banzai::ReferenceRedactor do
let(:user) { create(:user) }
let(:project) { build(:project) }
let(:redactor) { described_class.new(Banzai::RenderContext.new(project, user)) }