Commit 9d7cb7e7 authored by a_luna's avatar a_luna

Fix for markdown viewer

ApplicationController#renderer initialization receives a Warden::Proxy
to avoid Devise errors.
parent c2502887
# frozen_string_literal: true # frozen_string_literal: true
class SnippetBlobPresenter < BlobPresenter class SnippetBlobPresenter < BlobPresenter
include Gitlab::Routing
def rich_data def rich_data
return if blob.binary? return if blob.binary?
return unless blob.rich_viewer return unless blob.rich_viewer
...@@ -35,22 +33,16 @@ class SnippetBlobPresenter < BlobPresenter ...@@ -35,22 +33,16 @@ class SnippetBlobPresenter < BlobPresenter
end end
def render_rich_partial def render_rich_partial
renderer.render("projects/blob/viewers/#{blob.rich_viewer.partial_name}", renderer.render("projects/blob/viewers/_#{blob.rich_viewer.partial_name}",
viewer: blob.rich_viewer, locals: { viewer: blob.rich_viewer, blob: blob, blob_raw_path: raw_path },
blob: blob, layout: false)
blow_raw_path: raw_path)
end end
def renderer def renderer
ActionView::Base.new(build_lookup_context, { snippet: snippet }, ActionController::Base.new).tap do |renderer| proxy = Warden::Proxy.new({}, Warden::Manager.new({})).tap do |i|
renderer.extend ApplicationController._helpers i.set_user(current_user, scope: :user)
renderer.class_eval do
include Rails.application.routes.url_helpers
end
end end
end
def build_lookup_context ApplicationController.renderer.new('warden' => proxy)
ActionView::Base.build_lookup_context(ActionController::Base.view_paths)
end end
end end
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