Commit f12cee01 authored by Francisco Javier López's avatar Francisco Javier López Committed by Rémy Coutable

Extracted code to EE directory

parent 1e51c542
......@@ -14,10 +14,6 @@ class BlobEntity < Grape::Entity
expose :url, if: -> (*) { request.respond_to?(:ref) } do |blob|
project_blob_path(request.project, File.join(request.ref, blob.path))
end
expose :file_lock, if: -> (*) { request.respond_to?(:ref) }, using: FileLockEntity do |blob|
if request.project.root_ref?(request.ref)
request.project.find_path_lock(blob.path, exact_match: true)
end
end
end
BlobEntity.prepend(EE::BlobEntity)
# frozen_string_literal: true
module EE
module BlobEntity
extend ActiveSupport::Concern
prepended do
expose :file_lock, if: -> (*) { request.respond_to?(:ref) }, using: FileLockEntity do |blob|
if request.project.root_ref?(request.ref)
request.project.find_path_lock(blob.path, exact_match: true)
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe BlobEntity do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:blob) { project.commit('master').diffs.diff_files.first.blob }
let(:request) { EntityRequest.new(project: project, ref: 'master') }
let(:entity) do
described_class.new(blob, request: request)
end
context 'as json' do
subject { entity.as_json }
it 'exposes needed attributes' do
expect(subject).to include(:file_lock)
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