2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe 'projects/tree/_tree_row' do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:repository) { project.repository }
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
# rubocop: disable Rails/FindBy
|
|
|
|
# This is not ActiveRecord where..first
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:blob_item) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first }
|
2020-04-22 19:07:51 +05:30
|
|
|
# rubocop: enable Rails/FindBy
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
assign(:project, project)
|
|
|
|
assign(:repository, repository)
|
|
|
|
assign(:id, File.join('master', ''))
|
|
|
|
assign(:lfs_blob_ids, [])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders blob item' do
|
|
|
|
render_partial(blob_item)
|
|
|
|
|
|
|
|
expect(rendered).to have_content(blob_item.name)
|
|
|
|
expect(rendered).not_to have_selector('.label-lfs', text: 'LFS')
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'LFS blob' do
|
|
|
|
before do
|
|
|
|
assign(:lfs_blob_ids, [blob_item].map(&:id))
|
|
|
|
|
|
|
|
render_partial(blob_item)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders LFS badge' do
|
|
|
|
expect(rendered).to have_selector('.label-lfs', text: 'LFS')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
def render_partial(items)
|
|
|
|
render partial: 'projects/tree/tree_row', collection: [items].flatten
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|