2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe BlobEntity do
|
2018-11-08 19:23:39 +05:30
|
|
|
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 }
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'contains needed attributes' do
|
|
|
|
expect(subject).to include({
|
|
|
|
id: blob.id,
|
|
|
|
path: blob.path,
|
|
|
|
name: blob.name,
|
|
|
|
mode: "100644",
|
|
|
|
readable_text: true,
|
2021-01-03 14:25:43 +05:30
|
|
|
icon: "doc-text",
|
2020-03-13 15:44:24 +05:30
|
|
|
url: "/#{project.full_path}/-/blob/master/bar/branch-test.txt"
|
2019-12-26 22:10:19 +05:30
|
|
|
})
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|