Commit b545cf40 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'rename-banzai-redactors' into 'master'

Rename Redactor classes to ReferenceRedactor

See merge request gitlab-org/gitlab-ce!30408
parents b8d876f1 cea7ba51
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -12,7 +12,7 @@ module Banzai
def self.internal_link_filters
[
Filter::RedactorFilter,
Filter::ReferenceRedactorFilter,
Filter::InlineMetricsRedactorFilter,
Filter::RelativeLinkFilter,
Filter::IssuableStateFilter,
......
......@@ -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`.
......
......@@ -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
......
require 'spec_helper'
describe Banzai::Filter::RedactorFilter do
describe Banzai::Filter::ReferenceRedactorFilter do
include ActionView::Helpers::UrlHelper
include FilterSpecHelper
......
......@@ -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
......
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)) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment